From 57a82fa36a9bea34223c5bc7c4f08fcfdba27e9a Mon Sep 17 00:00:00 2001 From: lauralani Date: Mon, 10 Apr 2023 20:13:20 +0200 Subject: [PATCH] add tag ci --- .woodpecker/build-and-release.yml | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .woodpecker/build-and-release.yml diff --git a/.woodpecker/build-and-release.yml b/.woodpecker/build-and-release.yml new file mode 100644 index 0000000..1fd7d4a --- /dev/null +++ b/.woodpecker/build-and-release.yml @@ -0,0 +1,57 @@ +when: + event: tag + +matrix: + include: + - GOOS: linux + GOARCH: amd64 + - GOOS: linux + GOARCH: arm + GOARM: 6 + - GOOS: linux + GOARCH: arm64 + +pipeline: + build: + secrets: + - FORGEJO_APIKEY + image: golang:1.20-alpine + environment: + - APP_NAME=ipam + - FORGE=https://codeberg.org + commands: + - apk add --update --no-cache xz curl jq + - go mod download + - go build -o output/$APP_NAME-${CI_COMMIT_TAG##v}-${GOOS}-${GOARCH}${GOARM} main.go + - cd output + - xz --keep --compress $APP_NAME-${CI_COMMIT_TAG##v}-${GOOS}-${GOARCH}${GOARM} + - sha256sum $APP_NAME-${CI_COMMIT_TAG##v}-${GOOS}-${GOARCH}${GOARM} >> $APP_NAME-${CI_COMMIT_TAG##v}-${GOOS}-${GOARCH}${GOARM}.sha256 + - sha256sum $APP_NAME-${CI_COMMIT_TAG##v}-${GOOS}-${GOARCH}${GOARM}.xz >> $APP_NAME-${CI_COMMIT_TAG##v}-${GOOS}-${GOARCH}${GOARM}.xz.sha256 + - |- + export RELEASE_ID=`curl --location "$FORGE/api/v1/repos/$CI_REPO/releases?limit=10" \ + --header 'Accept: application/json' -s -S \ + --fail-with-body | jq -r ".[] | select (.tag_name==\"$CI_COMMIT_TAG\").id"` + - |- + curl --location "$FORGE/api/v1/repos/$CI_REPO/releases/$RELEASE_ID/assets" \ + --header "Authorization: token $FORGEJO_APIKEY" \ + --header 'Content-Type: multipart/form-data' -s -S \ + --form "attachment=@$APP_NAME-${CI_COMMIT_TAG##v}-${GOOS}-${GOARCH}${GOARM};type=application/octet-stream" \ + --fail-with-body + - |- + curl --location "$FORGE/api/v1/repos/$CI_REPO/releases/$RELEASE_ID/assets" \ + --header "Authorization: token $FORGEJO_APIKEY" \ + --header 'Content-Type: multipart/form-data' -s -S \ + --form "attachment=@$APP_NAME-${CI_COMMIT_TAG##v}-${GOOS}-${GOARCH}${GOARM}.xz;type=application/octet-stream" \ + --fail-with-body + - |- + curl --location "$FORGE/api/v1/repos/$CI_REPO/releases/$RELEASE_ID/assets" \ + --header "Authorization: token $FORGEJO_APIKEY" \ + --header 'Content-Type: multipart/form-data' -s -S \ + --form "attachment=@$APP_NAME-${CI_COMMIT_TAG##v}-${GOOS}-${GOARCH}${GOARM}.sha256;type=application/octet-stream" \ + --fail-with-body + - |- + curl --location "$FORGE/api/v1/repos/$CI_REPO/releases/$RELEASE_ID/assets" \ + --header "Authorization: token $FORGEJO_APIKEY" \ + --header 'Content-Type: multipart/form-data' -s -S \ + --form "attachment=@$APP_NAME-${CI_COMMIT_TAG##v}-${GOOS}-${GOARCH}${GOARM}.xz.sha256;type=application/octet-stream" \ + --fail-with-body \ No newline at end of file