@@ -3,12 +3,14 @@ name: Release
33on :
44 workflow_dispatch :
55 inputs :
6- version :
7- description : ' Release version (e.g., v1.2.0)'
8- required : true
9- base-ref :
10- description : ' Previous release tag (e.g., v1.1.0)'
6+ bump :
7+ description : ' Version bump type'
118 required : true
9+ type : choice
10+ options :
11+ - patch
12+ - minor
13+ - major
1214
1315jobs :
1416 release :
@@ -21,25 +23,45 @@ jobs:
2123 with :
2224 fetch-depth : 0
2325
26+ - name : Determine versions
27+ id : version
28+ run : |
29+ LATEST=$(git tag --list 'v*.*.*' --sort=-v:refname | head -n 1)
30+ if [ -z "$LATEST" ]; then
31+ LATEST="v0.0.0"
32+ fi
33+ echo "previous=$LATEST" >> "$GITHUB_OUTPUT"
34+
35+ # Strip 'v' prefix, split, bump, reassemble
36+ IFS='.' read -r MAJOR MINOR PATCH <<< "${LATEST#v}"
37+ case "${{ inputs.bump }}" in
38+ major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
39+ minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
40+ patch) PATCH=$((PATCH + 1)) ;;
41+ esac
42+ NEXT="v${MAJOR}.${MINOR}.${PATCH}"
43+ echo "next=$NEXT" >> "$GITHUB_OUTPUT"
44+ echo "major=v${MAJOR}" >> "$GITHUB_OUTPUT"
45+ echo "Releasing $NEXT (previous: $LATEST)"
46+
2447 - name : Generate release notes
2548 id : notes
2649 uses : github/copilot-release-notes@v1
2750 with :
28- base-ref : ${{ inputs.base-ref }}
51+ base-ref : ${{ steps.version.outputs.previous }}
2952 head-ref : ${{ github.sha }}
3053 env :
3154 COPILOT_GITHUB_TOKEN : ${{ secrets.COPILOT_GITHUB_TOKEN }}
3255
3356 - name : Create GitHub Release
3457 uses : softprops/action-gh-release@v2
3558 with :
36- tag_name : ${{ inputs .version }}
37- name : ${{ inputs .version }}
59+ tag_name : ${{ steps .version.outputs.next }}
60+ name : ${{ steps .version.outputs.next }}
3861 body : ${{ steps.notes.outputs.release-notes }}
3962 draft : true
4063
4164 - name : Update major version tag
4265 run : |
43- MAJOR=$(echo "${{ inputs.version }}" | grep -oE '^v[0-9]+')
44- git tag -f "$MAJOR" "${{ inputs.version }}"
45- git push origin "$MAJOR" --force
66+ git tag -f "${{ steps.version.outputs.major }}" "${{ steps.version.outputs.next }}"
67+ git push origin "${{ steps.version.outputs.major }}" --force
0 commit comments