Skip to content

Commit 9cbeb0f

Browse files
committed
chore: updated release workflow
1 parent 4300dad commit 9cbeb0f

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

.github/workflows/release-publish.yml

+35-7
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,35 @@ on:
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

2029
jobs:
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
@@ -45,6 +58,7 @@ jobs:
4558
run: |
4659
git config --local user.email "[email protected]"
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 }}

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@
2525
"version:patch": "npm version patch",
2626
"version:minor": "npm version minor",
2727
"version:major": "npm version major",
28-
"release": "npm publish"
28+
"release": "npm publish",
29+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
30+
"changelog:latest": "conventional-changelog -p angular -r 1 > RELEASE_NOTES.md"
2931
},
3032
"devDependencies": {
3133
"@types/bun": "latest",
3234
"@types/cors": "^2.8.17",
33-
"@types/express": "^5.0.0"
35+
"@types/express": "^5.0.0",
36+
"conventional-changelog-cli": "^5.0.0"
3437
},
3538
"peerDependencies": {
3639
"typescript": "^5.8.2"
@@ -69,4 +72,4 @@
6972
"publishConfig": {
7073
"access": "public"
7174
}
72-
}
75+
}

0 commit comments

Comments
 (0)