44 push :
55 tags :
66 - ' v*'
7+ workflow_dispatch :
8+ inputs :
9+ version :
10+ description : ' Version to release (e.g., v0.1.0)'
11+ required : true
12+ default : ' v0.1.0'
713
814env :
915 CARGO_TERM_COLOR : always
@@ -15,14 +21,39 @@ jobs:
1521 outputs :
1622 upload_url : ${{ steps.create_release.outputs.upload_url }}
1723 steps :
24+ - name : Checkout code
25+ uses : actions/checkout@v4
26+ with :
27+ fetch-depth : 0
28+
29+ - name : Set version from tag
30+ if : startsWith(github.ref, 'refs/tags/')
31+ run : echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
32+
33+ - name : Set version from input
34+ if : github.event_name == 'workflow_dispatch'
35+ run : echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
36+
37+ - name : Create tag for manual release
38+ if : github.event_name == 'workflow_dispatch'
39+ run : |
40+ git config user.name "github-actions[bot]"
41+ git config user.email "github-actions[bot]@users.noreply.github.com"
42+ if git tag -l "${{ github.event.inputs.version }}" | grep -q .; then
43+ echo "Tag ${{ github.event.inputs.version }} already exists!"
44+ exit 1
45+ fi
46+ git tag -a "${{ github.event.inputs.version }}" -m "Release ${{ github.event.inputs.version }}"
47+ git push origin "${{ github.event.inputs.version }}"
48+
1849 - name : Create Release
1950 id : create_release
2051 uses : actions/create-release@v1
2152 env :
2253 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2354 with :
24- tag_name : ${{ github.ref }}
25- release_name : Release ${{ github.ref }}
55+ tag_name : ${{ env.VERSION }}
56+ release_name : Release ${{ env.VERSION }}
2657 draft : false
2758 prerelease : false
2859
0 commit comments