4
4
workflow_dispatch :
5
5
inputs :
6
6
version_type :
7
- description : ' Version type (patch, minor, major)'
7
+ description : ' Version type (prerelease, prepatch, patch, preminor, minor, premajor , major)'
8
8
required : true
9
9
default : ' patch'
10
10
type : choice
11
11
options :
12
+ - prerelease
13
+ - prepatch
12
14
- patch
15
+ - preminor
13
16
- minor
17
+ - premajor
14
18
- major
15
19
custom_version :
16
20
description : ' Custom version (leave empty to use version_type)'
17
21
required : false
18
22
type : string
23
+ dist_tag :
24
+ description : ' npm distribution tag (latest, next, beta, etc)'
25
+ required : false
26
+ default : ' latest'
27
+ type : string
19
28
20
29
jobs :
21
30
release-and-publish :
22
31
runs-on : ubuntu-latest
32
+ permissions :
33
+ contents : write
34
+ packages : write
35
+ id-token : write
23
36
steps :
24
37
- name : Checkout code
25
38
uses : actions/checkout@v4
45
58
run : |
46
59
git config --local user.email "[email protected] "
47
60
git config --local user.name "GitHub Action"
61
+ git config pull.rebase false
48
62
49
63
- name : Bump version
50
64
id : bump_version
@@ -60,30 +74,44 @@ jobs:
60
74
fi
61
75
echo "New version: ${{ env.VERSION }}"
62
76
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
+
63
84
- name : Build project
64
85
run : bun run build && bun run build:http
65
86
66
87
- name : Commit and push changes
67
88
run : |
68
- git add package.json
89
+ git pull origin main --no-edit
90
+ git add package.json CHANGELOG.md
69
91
git commit -m "Bump version to v${{ env.VERSION }}"
70
- git push
92
+ git push --force-with-lease
71
93
72
94
- name : Create and push tag
73
95
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 }}"
76
103
77
104
- name : Create GitHub Release
78
105
uses : softprops/action-gh-release@v1
79
106
with :
80
107
tag_name : v${{ env.VERSION }}
81
108
name : Release v${{ env.VERSION }}
82
- generate_release_notes : true
109
+ body_path : RELEASE_NOTES.md
110
+ generate_release_notes : false
83
111
env :
84
112
GITHUB_TOKEN : ${{ secrets.PAT_GITHUB }}
85
113
86
114
- name : Publish to npm
87
- run : npm publish
115
+ run : npm publish --access public --provenance --tag ${{ github.event.inputs.dist_tag || 'latest' }}
88
116
env :
89
117
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments