Skip to content

Commit 4bf038b

Browse files
lacerbiclaude
andauthored
ci: fix release workflow trigger + add manual dispatch (#70)
- Change trigger from tag push to workflow_run (fixes GITHUB_TOKEN limitation) - Add workflow_dispatch for manual releases with tag input - Add check-tag job to detect latest tag and skip existing releases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: lacerbi <luigi.acerbi@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent af6195c commit 4bf038b

File tree

1 file changed

+56
-5
lines changed

1 file changed

+56
-5
lines changed

.github/workflows/release.yml

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,61 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
4+
workflow_run:
5+
workflows: ["Auto Tag"]
6+
types:
7+
- completed
8+
workflow_dispatch:
9+
inputs:
10+
tag:
11+
description: 'Tag to release (e.g., v0.7.14)'
12+
required: true
13+
type: string
714

815
jobs:
16+
check-tag:
17+
runs-on: ubuntu-latest
18+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
19+
outputs:
20+
tag: ${{ steps.get-tag.outputs.tag }}
21+
should_release: ${{ steps.get-tag.outputs.should_release }}
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Get tag
30+
id: get-tag
31+
run: |
32+
# Use input tag for manual dispatch, otherwise detect latest
33+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
34+
TAG="${{ inputs.tag }}"
35+
else
36+
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
37+
fi
38+
39+
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
40+
# Check if release already exists
41+
if gh release view "$TAG" &>/dev/null; then
42+
echo "Release $TAG already exists, skipping"
43+
echo "should_release=false" >> $GITHUB_OUTPUT
44+
else
45+
echo "tag=$TAG" >> $GITHUB_OUTPUT
46+
echo "should_release=true" >> $GITHUB_OUTPUT
47+
echo "Will create release for $TAG"
48+
fi
49+
else
50+
echo "No valid semver tag found: $TAG"
51+
echo "should_release=false" >> $GITHUB_OUTPUT
52+
fi
53+
env:
54+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
956
build:
57+
needs: check-tag
58+
if: ${{ needs.check-tag.outputs.should_release == 'true' }}
1059
strategy:
1160
matrix:
1261
include:
@@ -22,6 +71,8 @@ jobs:
2271
steps:
2372
- name: Checkout repository
2473
uses: actions/checkout@v4
74+
with:
75+
ref: ${{ needs.check-tag.outputs.tag }}
2576

2677
- name: Setup Node.js
2778
uses: actions/setup-node@v4
@@ -51,7 +102,7 @@ jobs:
51102
if-no-files-found: error
52103

53104
release:
54-
needs: build
105+
needs: [check-tag, build]
55106
runs-on: ubuntu-latest
56107
permissions:
57108
contents: write
@@ -73,6 +124,6 @@ jobs:
73124
env:
74125
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75126
run: |
76-
gh release create ${{ github.ref_name }} \
127+
gh release create ${{ needs.check-tag.outputs.tag }} \
77128
--generate-notes \
78129
artifacts/**/*

0 commit comments

Comments
 (0)