2626 with :
2727 fetch-depth : 0
2828
29+ - name : Calculate next version
30+ id : next_version
31+ run : |
32+ # Use npm version to calculate the next version without modifying files
33+ CURRENT_VERSION=$(node -p "require('./package.json').version")
34+ NEW_VERSION=$(npm version ${{ github.event.inputs.version }} --no-git-tag-version)
35+
36+ # Restore package.json to avoid dirty state
37+ git checkout package.json package-lock.json 2>/dev/null || true
38+
39+ echo "current=v$CURRENT_VERSION" >> $GITHUB_OUTPUT
40+ echo "next=$NEW_VERSION" >> $GITHUB_OUTPUT
41+ echo "📦 Current version: v$CURRENT_VERSION"
42+ echo "📦 Next version: $NEW_VERSION (bump: ${{ github.event.inputs.version }})"
43+
44+ - name : Check if release already exists
45+ run : |
46+ echo "🔍 Checking if ${{ steps.next_version.outputs.next }} already exists..."
47+
48+ # Check if tag exists in remote
49+ if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.next_version.outputs.next }}$"; then
50+ echo "❌ Error: Git tag ${{ steps.next_version.outputs.next }} already exists on remote"
51+ echo "Please check existing releases or use a different version bump type."
52+ exit 1
53+ fi
54+
55+ # Check if GitHub release exists (via API)
56+ if gh release view "${{ steps.next_version.outputs.next }}" &>/dev/null; then
57+ echo "❌ Error: GitHub release ${{ steps.next_version.outputs.next }} already exists"
58+ echo "Please check existing releases or use a different version bump type."
59+ exit 1
60+ fi
61+
62+ echo "✅ Version ${{ steps.next_version.outputs.next }} is available"
63+ env :
64+ GH_TOKEN : ${{ github.token }}
65+
2966 - name : Setup Project
3067 uses : ./.github/actions/setup-node-yarn
3168
3471 run : |
3572 NOTES=$(awk '/## \[Unreleased\]/ {flag=1; next} /^## \[/ {flag=0} flag && NF {print}' CHANGELOG.md)
3673 if [ -z "$NOTES" ] || [ -z "$(echo "$NOTES" | tr -d '[:space:]')" ]; then
37- echo "Error: No release notes found in the [Unreleased] section of CHANGELOG.md"
74+ echo "❌ Error: No release notes found in the [Unreleased] section of CHANGELOG.md"
3875 echo "Please add release notes before creating a release."
3976 exit 1
4077 fi
4986 echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
5087 sed -i "s/## \[Unreleased\]/## [Unreleased]\n\n## [$NEW_VERSION] - $(date +%Y-%m-%d)/" CHANGELOG.md
5188
52- - name : Check if release already exists
53- run : |
54- if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.bump.outputs.version }}$"; then
55- echo "Error: Release tag ${{ steps.bump.outputs.version }} already exists"
56- echo "Please check existing releases or use a different version bump type."
57- exit 1
89+ # Verify we got the expected version
90+ if [ "$NEW_VERSION" != "${{ steps.next_version.outputs.next }}" ]; then
91+ echo "⚠️ Warning: Calculated version (${{ steps.next_version.outputs.next }}) doesn't match npm version ($NEW_VERSION)"
5892 fi
5993
6094 - name : Build and pack
@@ -72,6 +106,10 @@ jobs:
72106 name : ${{ steps.bump.outputs.version }}
73107 body : ${{ steps.changelog.outputs.notes }}
74108 files : ${{ steps.pack.outputs.tgz }}
109+ fail_on_unmatched_files : true
110+ draft : false
111+ prerelease : false
112+ make_latest : true
75113
76114 - name : Create Pull Request
77115 uses : peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412
80118 branch : release/${{ steps.bump.outputs.version }}
81119 title : " Release ${{ steps.bump.outputs.version }}"
82120 body : " This PR updates CHANGELOG.md and package.json for release ${{ steps.bump.outputs.version }}."
83- base : main
121+ base : ${{ github.ref_name }}
0 commit comments