From 2ea57d69732db9f5ef5fcfc847165092a57fceb4 Mon Sep 17 00:00:00 2001 From: Salastil <46979341+Salastil@users.noreply.github.com> Date: Sun, 23 Nov 2025 02:43:57 -0500 Subject: [PATCH] Build releases on tagged pushes --- .github/workflows/release.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index afe47df..353a7c0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,9 @@ name: Build release binaries on: release: types: [published] + push: + tags: + - "v*" permissions: contents: write @@ -95,6 +98,7 @@ jobs: if: startsWith(github.server_url, 'https://github.com') uses: softprops/action-gh-release@v2 with: + tag_name: ${{ github.ref_name }} files: dist/* - name: Publish release assets on Gitea @@ -102,11 +106,37 @@ jobs: env: API_URL: ${{ github.api_url }} REPOSITORY: ${{ github.repository }} - RELEASE_ID: ${{ github.event.release.id }} TOKEN: ${{ secrets.CI_TOKEN || secrets.GITHUB_TOKEN || github.token }} + RELEASE_ID: ${{ github.event.release.id }} + TAG_NAME: ${{ github.ref_name }} run: | set -euo pipefail shopt -s nullglob + + if [ -z "${RELEASE_ID:-}" ]; then + echo "Creating release ${TAG_NAME} on Gitea" + response=$(curl -sfSL -X POST \ + -H "Authorization: token ${TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"draft\":false,\"prerelease\":false}" \ + "${API_URL}/repos/${REPOSITORY}/releases") + + RELEASE_ID=$(python - "$response" <<'PY' +import json, sys +try: + data = json.loads(sys.argv[1]) + print(data.get("id", "")) +except Exception: + sys.exit(1) +PY +) + + if [ -z "${RELEASE_ID}" ]; then + echo "Failed to create release" >&2 + exit 1 + fi + fi + for file in dist/*; do name=$(basename "${file}") curl -sfSL -X POST \