From 3ef1e5626f989d8724095b8c3b2b0d8645de4147 Mon Sep 17 00:00:00 2001 From: magerbeton Date: Sun, 23 Aug 2026 16:37:59 +0200 Subject: [PATCH] ci: add multi-platform release build via Gitea Actions Builds tea for linux/amd64, linux/arm64, darwin/amd64, darwin/arm64 and windows/amd64 on tag push and publishes them as a Gitea release. --- .gitea/workflows/release.yml | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 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..17becd9 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,65 @@ +name: release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: write + releases: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: build + run: | + set -e + VERSION="${GITHUB_REF_NAME#v}" + SDK="$(go list -f '{{.Version}}' -m gitea.dev/sdk)" + mkdir -p dist + for target in "linux amd64" "linux arm64" "darwin amd64" "darwin arm64" "windows amd64"; do + GOOS="${target% *}" + GOARCH="${target#* }" + EXT="" + if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi + GOOS="$GOOS" GOARCH="$GOARCH" CGO_ENABLED=0 go build -trimpath \ + -ldflags "-X 'gitea.dev/tea/modules/version.Version=${VERSION}' -X 'gitea.dev/tea/modules/version.SDK=${SDK}' -s -w" \ + -o "dist/tea-${GOOS}-${GOARCH}${EXT}" . + done + cd dist + for f in tea-*; do + sha256sum "$f" > "$f.sha256" + done + - uses: actions/upload-artifact@v4 + with: + name: tea-binaries + path: dist/* + if-no-files-found: error + - name: create release + upload assets + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + set -e + TAG="${GITHUB_REF_NAME}" + API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" + RESPONSE="$(curl -sf -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + "${API}/releases" \ + -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\"}")" + RELEASE_ID="$(printf '%s' "$RESPONSE" | python3 -c 'import sys,json;print(json.load(sys.stdin)["id"])')" + for f in dist/tea-*; do + curl -sf -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -F "attachment=@${f}" \ + "${API}/releases/${RELEASE_ID}/assets" >/dev/null + done \ No newline at end of file