Skip to content

Commit bb7a60b

Browse files
committed
feat: add prepare release workflow for version bump and changelog generation
1 parent 02964bd commit bb7a60b

File tree

2 files changed

+51
-11
lines changed

2 files changed

+51
-11
lines changed

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2-
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3-
4-
name: Node.js Package
1+
name: Publish to NPM
52

63
on:
74
push:
@@ -32,10 +29,3 @@ jobs:
3229
- run: npm publish --access=public
3330
env:
3431
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
35-
36-
- name: Create Pull Request
37-
uses: peter-evans/create-pull-request@v7
38-
with:
39-
token: ${{ secrets.GITHUB_TOKEN }}
40-
commit-message: "chore(release): update CHANGELOG.md and version"
41-
base: main
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to bump to (e.g. patch, minor, major, or specific version)'
8+
required: true
9+
default: 'patch'
10+
11+
jobs:
12+
prepare-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Update version
28+
run: |
29+
npm version ${{ github.event.inputs.version }} --no-git-tag-version
30+
NEW_VERSION=$(node -p "require('./package.json').version")
31+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
32+
33+
- name: Generate changelog
34+
id: changelog
35+
run: |
36+
npx conventional-changelog-cli -p angular -i CHANGELOG.md -s
37+
38+
- name: Create Pull Request
39+
uses: peter-evans/create-pull-request@v7
40+
with:
41+
token: ${{ secrets.GITHUB_TOKEN }}
42+
commit-message: "chore(release): v${{ env.NEW_VERSION }}"
43+
title: "chore(release): prepare release v${{ env.NEW_VERSION }}"
44+
body: |
45+
Prepare release v${{ env.NEW_VERSION }}
46+
47+
- Update version in package.json
48+
- Update CHANGELOG.md
49+
base: main
50+
branch: release/v${{ env.NEW_VERSION }}

0 commit comments

Comments
 (0)