66 - ' v*'
77 workflow_dispatch :
88 inputs :
9- tag :
10- description : ' Tag name (e.g. v0.1.0) '
9+ bump :
10+ description : ' Version bump type '
1111 required : false
12- default : ' '
12+ default : ' patch'
13+ type : choice
14+ options :
15+ - patch
16+ - minor
17+ - major
1318 prerelease :
1419 description : ' Mark as prerelease'
1520 type : boolean
@@ -24,10 +29,50 @@ jobs:
2429 steps :
2530 - name : Checkout
2631 uses : actions/checkout@v4
32+ with :
33+ fetch-depth : 0
2734
2835 - name : Install capnp compiler
2936 run : sudo apt-get update && sudo apt-get install -y capnproto
3037
38+ - name : Compute next tag (workflow dispatch only)
39+ id : bump
40+ if : github.event_name == 'workflow_dispatch'
41+ run : |
42+ git fetch --tags --force
43+ latest=$(git tag -l 'v*' --sort=-v:refname | head -n 1)
44+ if [ -z "$latest" ]; then
45+ latest="v0.0.0"
46+ fi
47+
48+ bump="${{ github.event.inputs.bump }}"
49+ IFS='.' read -r major minor patch <<<"${latest#v}"
50+
51+ case "$bump" in
52+ major) major=$((major + 1)); minor=0; patch=0 ;;
53+ minor) minor=$((minor + 1)); patch=0 ;;
54+ *) patch=$((patch + 1)) ;;
55+ esac
56+
57+ new_tag="v${major}.${minor}.${patch}"
58+ echo "tag=${new_tag}" >> "$GITHUB_OUTPUT"
59+ echo "Next tag: ${new_tag}"
60+
61+ - name : Create tag (workflow dispatch only)
62+ if : github.event_name == 'workflow_dispatch'
63+ env :
64+ TAG : ${{ steps.bump.outputs.tag }}
65+ run : |
66+ git config user.name "github-actions[bot]"
67+ git config user.email "github-actions[bot]@users.noreply.github.com"
68+ git tag "$TAG"
69+ git push origin "$TAG"
70+
71+ - name : Set release tag
72+ run : echo "TAG_NAME=${TAG}" >> "$GITHUB_ENV"
73+ env :
74+ TAG : ${{ github.event_name == 'workflow_dispatch' && steps.bump.outputs.tag || github.ref_name }}
75+
3176 - name : Setup PHP
3277 uses : shivammathur/setup-php@v2
3378 with :
57102 - name : Create GitHub release
58103 uses : softprops/action-gh-release@v2
59104 with :
60- tag_name : ${{ github.event.inputs.tag || github.ref_name }}
61- name : ${{ github.event.inputs.tag || github.ref_name }}
105+ tag_name : ${{ env.TAG_NAME }}
106+ name : ${{ env.TAG_NAME }}
62107 target_commitish : ${{ github.sha }}
63108 prerelease : ${{ github.event.inputs.prerelease == 'true' }}
64109 env :
0 commit comments