diff --git a/.gitea/workflows/auto-tag.yml b/.gitea/workflows/auto-tag.yml index 48e1210a..2ac6e90c 100644 --- a/.gitea/workflows/auto-tag.yml +++ b/.gitea/workflows/auto-tag.yml @@ -13,9 +13,6 @@ jobs: runs-on: linux-amd64 container: image: alpine:latest - outputs: - release_tag: ${{ steps.bump.outputs.release_tag }} - tag_created: ${{ steps.bump.outputs.tag_created }} steps: - name: Bump patch version and create tag id: bump @@ -43,7 +40,6 @@ jobs: fi echo "Latest tag: ${LATEST:-none} → Next: $NEXT" - echo "release_tag=$NEXT" >> "$GITHUB_OUTPUT" # Create and push the tag via git so the tag push event triggers release.yml. git init @@ -55,19 +51,16 @@ jobs: if git ls-remote --exit-code --tags origin "refs/tags/$NEXT" >/dev/null 2>&1; then echo "Tag $NEXT already exists; skipping." - echo "tag_created=false" >> "$GITHUB_OUTPUT" exit 0 fi git tag -a "$NEXT" -m "Release $NEXT" git push origin "refs/tags/$NEXT" - echo "tag_created=true" >> "$GITHUB_OUTPUT" echo "Tag $NEXT pushed successfully" build-linux-amd64: needs: autotag - if: needs.autotag.outputs.tag_created == 'true' runs-on: linux-amd64 container: image: rust:1.88-slim @@ -99,7 +92,14 @@ jobs: run: | set -eu API="http://172.0.0.29:3000/api/v1/repos/$GITHUB_REPOSITORY" - TAG="${{ needs.autotag.outputs.release_tag }}" + TAG=$(curl -s "$API/tags?limit=50" \ + -H "Authorization: token $RELEASE_TOKEN" | \ + jq -r '.[].name' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | \ + sort -V | tail -1 || true) + if [ -z "$TAG" ]; then + echo "ERROR: Could not resolve release tag from repository tags." + exit 1 + fi echo "Creating release for $TAG..." curl -sf -X POST "$API/releases" \ -H "Authorization: token $RELEASE_TOKEN" \ @@ -150,7 +150,6 @@ PY build-windows-amd64: needs: autotag - if: needs.autotag.outputs.tag_created == 'true' runs-on: linux-amd64 container: image: rust:1.88-slim @@ -186,7 +185,14 @@ PY run: | set -eu API="http://172.0.0.29:3000/api/v1/repos/$GITHUB_REPOSITORY" - TAG="${{ needs.autotag.outputs.release_tag }}" + TAG=$(curl -s "$API/tags?limit=50" \ + -H "Authorization: token $RELEASE_TOKEN" | \ + jq -r '.[].name' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | \ + sort -V | tail -1 || true) + if [ -z "$TAG" ]; then + echo "ERROR: Could not resolve release tag from repository tags." + exit 1 + fi echo "Creating release for $TAG..." curl -sf -X POST "$API/releases" \ -H "Authorization: token $RELEASE_TOKEN" \ @@ -237,7 +243,6 @@ PY build-macos-arm64: needs: autotag - if: needs.autotag.outputs.tag_created == 'true' runs-on: macos-arm64 steps: - name: Checkout @@ -270,7 +275,14 @@ PY run: | set -eu API="http://172.0.0.29:3000/api/v1/repos/$GITHUB_REPOSITORY" - TAG="${{ needs.autotag.outputs.release_tag }}" + TAG=$(curl -s "$API/tags?limit=50" \ + -H "Authorization: token $RELEASE_TOKEN" | \ + jq -r '.[].name' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | \ + sort -V | tail -1 || true) + if [ -z "$TAG" ]; then + echo "ERROR: Could not resolve release tag from repository tags." + exit 1 + fi echo "Creating release for $TAG..." curl -sf -X POST "$API/releases" \ -H "Authorization: token $RELEASE_TOKEN" \ @@ -320,7 +332,6 @@ PY build-linux-arm64: needs: autotag - if: needs.autotag.outputs.tag_created == 'true' runs-on: linux-arm64 container: image: rust:1.88-slim @@ -351,7 +362,14 @@ PY run: | set -eu API="http://172.0.0.29:3000/api/v1/repos/$GITHUB_REPOSITORY" - TAG="${{ needs.autotag.outputs.release_tag }}" + TAG=$(curl -s "$API/tags?limit=50" \ + -H "Authorization: token $RELEASE_TOKEN" | \ + jq -r '.[].name' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | \ + sort -V | tail -1 || true) + if [ -z "$TAG" ]; then + echo "ERROR: Could not resolve release tag from repository tags." + exit 1 + fi echo "Creating release for $TAG..." curl -sf -X POST "$API/releases" \ -H "Authorization: token $RELEASE_TOKEN" \ diff --git a/tests/unit/autoTagWorkflowTrigger.test.ts b/tests/unit/autoTagWorkflowTrigger.test.ts index 813c1c03..1984c6f8 100644 --- a/tests/unit/autoTagWorkflowTrigger.test.ts +++ b/tests/unit/autoTagWorkflowTrigger.test.ts @@ -23,7 +23,7 @@ describe("auto-tag workflow release triggering", () => { expect(workflow).toContain("build-macos-arm64:"); expect(workflow).toContain("build-linux-arm64:"); expect(workflow).toContain("needs: autotag"); - expect(workflow).toContain("needs.autotag.outputs.tag_created == 'true'"); - expect(workflow).toContain("TAG=\"${{ needs.autotag.outputs.release_tag }}\""); + expect(workflow).toContain("TAG=$(curl -s \"$API/tags?limit=50\""); + expect(workflow).toContain("ERROR: Could not resolve release tag from repository tags."); }); });