Files
magerbeton 12c0603966
release / release (push) Canceled after 27h55m13s
ci: drop actions/upload-artifact, tolerate existing releases
upload-artifact@v4 talks to GitHub's artifact service and times out on
Gitea. Distribution happens via release assets anyway. Also reuse an
existing release for a tag instead of failing on a 409.
2026-08-23 17:05:03 +02:00

65 lines
2.2 KiB
YAML

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
- 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}"
RELEASE_ID="$(curl -sf -H "Authorization: token ${GITEA_TOKEN}" \
"${API}/releases/tags/${TAG}" \
| python3 -c 'import sys,json;print(json.load(sys.stdin)["id"])' || true)"
if [ -z "$RELEASE_ID" ]; then
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"])')"
fi
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