fix(ci): trigger release workflow from auto-tag pushes
Switch auto-tag to create and push tags via git instead of the tag API so Gitea emits a real tag push event that reliably starts release builds. Document the trigger behavior and add a workflow regression test. Made-with: Cursor
This commit is contained in:
parent
42120cb140
commit
48041acc8c
@ -18,7 +18,8 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
run: |
|
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"
|
API="http://172.0.0.29:3000/api/v1/repos/$GITHUB_REPOSITORY"
|
||||||
|
|
||||||
@ -39,10 +40,20 @@ jobs:
|
|||||||
|
|
||||||
echo "Latest tag: ${LATEST:-none} → Next: $NEXT"
|
echo "Latest tag: ${LATEST:-none} → Next: $NEXT"
|
||||||
|
|
||||||
# Create the new tag pointing at the commit that triggered this push
|
# Create and push the tag via git so the tag push event triggers release.yml.
|
||||||
curl -sf -X POST "$API/tags" \
|
git init
|
||||||
-H "Authorization: token $RELEASE_TOKEN" \
|
git remote add origin "http://oauth2:${RELEASE_TOKEN}@172.0.0.29:3000/${GITHUB_REPOSITORY}.git"
|
||||||
-H "Content-Type: application/json" \
|
git fetch --depth=1 origin "$GITHUB_SHA"
|
||||||
-d "{\"tag_name\":\"$NEXT\",\"message\":\"Release $NEXT\",\"target\":\"$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"
|
||||||
|
|||||||
@ -69,6 +69,9 @@ steps:
|
|||||||
|
|
||||||
**Triggers:** Git tags matching `v*`
|
**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):
|
Jobs (run in parallel):
|
||||||
build-linux-amd64 → cargo tauri build (x86_64-unknown-linux-gnu)
|
build-linux-amd64 → cargo tauri build (x86_64-unknown-linux-gnu)
|
||||||
|
|||||||
17
tests/unit/autoTagWorkflowTrigger.test.ts
Normal file
17
tests/unit/autoTagWorkflowTrigger.test.ts
Normal file
@ -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\"");
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user