44 workflow_dispatch :
55 inputs :
66 version_type :
7- description : ' Version type (patch, minor, major)'
7+ description : ' Version type (prerelease, prepatch, patch, preminor, minor, premajor , major)'
88 required : true
99 default : ' patch'
1010 type : choice
1111 options :
12+ - prerelease
13+ - prepatch
1214 - patch
15+ - preminor
1316 - minor
17+ - premajor
1418 - major
1519 custom_version :
1620 description : ' Custom version (leave empty to use version_type)'
1721 required : false
1822 type : string
23+ dist_tag :
24+ description : ' npm distribution tag (latest, next, beta, etc)'
25+ required : false
26+ default : ' latest'
27+ type : string
1928
2029jobs :
2130 release-and-publish :
2231 runs-on : ubuntu-latest
32+ permissions :
33+ contents : write
34+ packages : write
35+ id-token : write
2336 steps :
2437 - name : Checkout code
2538 uses : actions/checkout@v4
4558 run : |
4659 git config --local user.email "action@github.com"
4760 git config --local user.name "GitHub Action"
61+ git config pull.rebase false
4862
4963 - name : Bump version
5064 id : bump_version
@@ -60,30 +74,44 @@ jobs:
6074 fi
6175 echo "New version: ${{ env.VERSION }}"
6276
77+ - name : Generate Changelog
78+ run : |
79+ # Generate the full changelog
80+ npm run changelog
81+ # Generate release notes for just this version
82+ npm run changelog:latest
83+
6384 - name : Build project
6485 run : bun run build && bun run build:http
6586
6687 - name : Commit and push changes
6788 run : |
68- git add package.json
89+ git pull origin main --no-edit
90+ git add package.json CHANGELOG.md
6991 git commit -m "Bump version to v${{ env.VERSION }}"
70- git push
92+ git push --force-with-lease
7193
7294 - name : Create and push tag
7395 run : |
74- git tag -a v${{ env.VERSION }} -m "Release v${{ env.VERSION }}"
75- git push --tags
96+ # Delete the tag if it already exists locally
97+ git tag -d "v${{ env.VERSION }}" 2>/dev/null || true
98+ # Delete the tag if it exists on the remote
99+ git push origin --delete "v${{ env.VERSION }}" 2>/dev/null || true
100+ # Create and push the new tag
101+ git tag -a "v${{ env.VERSION }}" -m "Release v${{ env.VERSION }}"
102+ git push origin "v${{ env.VERSION }}"
76103
77104 - name : Create GitHub Release
78105 uses : softprops/action-gh-release@v1
79106 with :
80107 tag_name : v${{ env.VERSION }}
81108 name : Release v${{ env.VERSION }}
82- generate_release_notes : true
109+ body_path : RELEASE_NOTES.md
110+ generate_release_notes : false
83111 env :
84112 GITHUB_TOKEN : ${{ secrets.PAT_GITHUB }}
85113
86114 - name : Publish to npm
87- run : npm publish
115+ run : npm publish --access public --provenance --tag ${{ github.event.inputs.dist_tag || 'latest' }}
88116 env :
89117 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments