1- name : Create Release
1+ name : Release on Merge
22
33on :
4- push :
5- tags :
6- - ' [0-9]+.[0-9]+.[0-9]+'
7-
8- permissions :
9- contents : write
10- # discussions: write
4+ pull_request :
5+ types : [closed]
6+ branches : [main]
117
128jobs :
13- create_release :
9+ check-release-branch :
10+ runs-on : ubuntu-latest
11+ # This if clause ensures the job only runs when the PR is merged
12+ # and the branch starts with release/
13+ if : |
14+ github.event.pull_request.merged == true &&
15+ startsWith(github.event.pull_request.head.ref, 'release/')
16+
17+ outputs :
18+ valid_release : ${{ steps.validate.outputs.valid_release }}
19+ version : ${{ steps.validate.outputs.version }}
20+
21+ steps :
22+ - name : Validate release branch and extract version
23+ id : validate
24+ run : |
25+ BRANCH="${{ github.event.pull_request.head.ref }}"
26+ if [[ "$BRANCH" =~ ^release/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
27+ VERSION="${BASH_REMATCH[1]}"
28+ echo "valid_release=true" >> "$GITHUB_OUTPUT"
29+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
30+ echo "Branch name valid for release: $BRANCH"
31+ else
32+ echo "valid_release=false" >> "$GITHUB_OUTPUT"
33+ echo "version=" >> "$GITHUB_OUTPUT"
34+ echo "Branch '$BRANCH' does not match release/X.Y.Z (semver) pattern. Skipping release."
35+ fi
36+
37+ do-release :
38+ needs : check-release-branch
39+ if : needs.check-release-branch.outputs.valid_release == 'true'
1440 runs-on : ubuntu-latest
41+ env :
42+ VERSION : ${{ needs.check-release-branch.outputs.version }}
43+
1544 steps :
16- - name : Generate GitHub Release
45+ - name : Checkout code
46+ uses : actions/checkout@v4
47+
48+ - name : Setup uv
49+ id : setup-uv
50+ uses : astral-sh/setup-uv@v1
51+
52+ - name : Print the installed version
53+ run : |
54+ echo "uv version is ${{ steps.setup-uv.outputs.uv-version }}"
55+
56+ - name : Tag new release
57+ run : |
58+ git config user.name 'github-actions[bot]'
59+ git config user.email 'github-actions[bot]@users.noreply.github.com'
60+ git tag "${{ env.VERSION }}"
61+ git push origin "${{ env.VERSION }}"
62+
63+ - name : Build wheel
64+ run : uv build --wheel
65+
66+ - name : Generate GitHub Release & Upload wheel
1767 uses : softprops/action-gh-release@v2
1868 with :
69+ tag_name : ${{ env.VERSION }}
1970 generate_release_notes : true
71+ files : dist/*.whl
2072 env :
21- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
73+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments