From 928ffa893430b88c292be4e6bf38f785dbdf2301 Mon Sep 17 00:00:00 2001 From: Marco Torres Morgado Date: Tue, 24 Feb 2026 16:56:21 +0000 Subject: [PATCH] ci: add release workflow for x86_64 builds --- .gitea/workflows/release.yml | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..2c32644 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Build + run: CGO_ENABLED=0 go build -ldflags="-s -w" -o snitch . + + - name: Create Release + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + VERSION="${{ github.ref_name }}" + VER="${VERSION#v}" + + # Package binary + tar czf "snitch_${VER}_linux_amd64.tar.gz" snitch + + # Create release + RELEASE_ID=$(curl -s -X POST "https://gitea.bitua.io/api/v1/repos/bitua/snitch/releases" \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\": \"${VERSION}\", \"name\": \"${VERSION}\"}" | jq -r .id) + + if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then + echo "Failed to create release" + exit 1 + fi + + echo "Created release ID: $RELEASE_ID" + + # Upload asset + curl -s -X POST "https://gitea.bitua.io/api/v1/repos/bitua/snitch/releases/${RELEASE_ID}/assets?name=snitch_${VER}_linux_amd64.tar.gz" \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -F "attachment=@snitch_${VER}_linux_amd64.tar.gz" + + echo "Release ${VERSION} complete!"