55 tags : ['v*']
66
77jobs :
8- release :
8+ check-tag :
99 runs-on : ubuntu-latest
10- permissions :
11- contents : write
12-
10+ outputs :
11+ should-release : ${{ steps.check.outputs.should-release }}
1312 steps :
1413 - name : Checkout code
1514 uses : actions/checkout@v4
1615 with :
1716 fetch-depth : 0 # Fetch all history and tags
1817 fetch-tags : true # Ensure all tags are fetched for version resolution
1918
20- - name : Verify tag is on main/master branch
19+ - name : Check if tag is on main/master branch
20+ id : check
2121 run : |
2222 # Get the commit that the tag points to
2323 TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }})
@@ -26,14 +26,30 @@ jobs:
2626 # Check if this commit is reachable from main or master
2727 if git branch -r --contains $TAG_COMMIT | grep -E "(origin/main|origin/master)" > /dev/null; then
2828 echo "✅ Tag ${{ github.ref_name }} is on main/master branch"
29+ echo "should-release=true" >> $GITHUB_OUTPUT
2930 else
30- echo "❌ Tag ${{ github.ref_name }} is NOT on main/master branch"
31+ echo "⚠️ Tag ${{ github.ref_name }} is NOT on main/master branch"
3132 echo "Available branches containing this commit:"
3233 git branch -r --contains $TAG_COMMIT
3334 echo "This release will be skipped for security reasons."
34- exit 1
35+ echo "To release, merge your changes to main/master first, then tag from there."
36+ echo "should-release=false" >> $GITHUB_OUTPUT
3537 fi
3638
39+ release :
40+ needs : check-tag
41+ if : needs.check-tag.outputs.should-release == 'true'
42+ runs-on : ubuntu-latest
43+ permissions :
44+ contents : write
45+
46+ steps :
47+ - name : Checkout code
48+ uses : actions/checkout@v4
49+ with :
50+ fetch-depth : 0 # Fetch all history and tags
51+ fetch-tags : true # Ensure all tags are fetched for version resolution
52+
3753 - name : Set up Python
3854 uses : actions/setup-python@v5
3955 with :
0 commit comments