diff --git a/.gitea/workflows/auto-tag.yml b/.gitea/workflows/auto-tag.yml index b0cb65f9..81215b3b 100644 --- a/.gitea/workflows/auto-tag.yml +++ b/.gitea/workflows/auto-tag.yml @@ -18,7 +18,8 @@ jobs: env: RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} run: | - apk add --no-cache curl jq + set -eu + apk add --no-cache curl jq git API="http://172.0.0.29:3000/api/v1/repos/$GITHUB_REPOSITORY" @@ -39,10 +40,20 @@ jobs: echo "Latest tag: ${LATEST:-none} → Next: $NEXT" - # Create the new tag pointing at the commit that triggered this push - curl -sf -X POST "$API/tags" \ - -H "Authorization: token $RELEASE_TOKEN" \ - -H "Content-Type: application/json" \ - -d "{\"tag_name\":\"$NEXT\",\"message\":\"Release $NEXT\",\"target\":\"$GITHUB_SHA\"}" + # Create and push the tag via git so the tag push event triggers release.yml. + git init + git remote add origin "http://oauth2:${RELEASE_TOKEN}@172.0.0.29:3000/${GITHUB_REPOSITORY}.git" + git fetch --depth=1 origin "$GITHUB_SHA" + git checkout FETCH_HEAD + git config user.name "gitea-actions[bot]" + git config user.email "gitea-actions@local" - echo "Tag $NEXT created successfully" + if git ls-remote --exit-code --tags origin "refs/tags/$NEXT" >/dev/null 2>&1; then + echo "Tag $NEXT already exists; skipping." + exit 0 + fi + + git tag -a "$NEXT" -m "Release $NEXT" + git push origin "refs/tags/$NEXT" + + echo "Tag $NEXT pushed successfully" diff --git a/docs/wiki/CICD-Pipeline.md b/docs/wiki/CICD-Pipeline.md index 279892cb..d351ae0d 100644 --- a/docs/wiki/CICD-Pipeline.md +++ b/docs/wiki/CICD-Pipeline.md @@ -69,6 +69,9 @@ steps: **Triggers:** Git tags matching `v*` +Auto tags are created by `.gitea/workflows/auto-tag.yml` using `git tag` + `git push` +(not the tag API endpoint), so the tag push event reliably triggers this workflow. + ``` Jobs (run in parallel): build-linux-amd64 → cargo tauri build (x86_64-unknown-linux-gnu) diff --git a/tests/unit/autoTagWorkflowTrigger.test.ts b/tests/unit/autoTagWorkflowTrigger.test.ts new file mode 100644 index 00000000..8abf1913 --- /dev/null +++ b/tests/unit/autoTagWorkflowTrigger.test.ts @@ -0,0 +1,17 @@ +import { describe, expect, it } from "vitest"; +import { readFileSync } from "node:fs"; +import path from "node:path"; + +const autoTagWorkflowPath = path.resolve( + process.cwd(), + ".gitea/workflows/auto-tag.yml", +); + +describe("auto-tag workflow release triggering", () => { + it("creates tags via git push instead of Gitea tag API", () => { + const workflow = readFileSync(autoTagWorkflowPath, "utf-8"); + + expect(workflow).toContain("git push origin \"refs/tags/$NEXT\""); + expect(workflow).not.toContain("POST \"$API/tags\""); + }); +});