Skip to content

Commit b630bb2

Browse files
authored
Automate release creation on package version bumps
1 parent f61e5f4 commit b630bb2

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,45 @@
1-
name: Publish Package to npmjs
1+
name: Release and Publish
22

33
on:
4-
release:
5-
types: [created]
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
610

711
jobs:
8-
publish:
12+
release-and-publish:
913
runs-on: ubuntu-latest
1014
defaults:
1115
run:
1216
working-directory: precise
1317

1418
steps:
15-
- name: Checkout repo
16-
uses: actions/checkout@v4
17-
18-
- name: Setup node
19-
uses: actions/setup-node@v4
19+
- uses: actions/checkout@v6
2020
with:
21-
node-version: '22'
22-
registry-url: 'https://registry.npmjs.org'
21+
fetch-depth: 0
2322

24-
- name: Install dependencies
25-
run: npm ci
23+
- id: version
24+
uses: EndBug/version-check@v2
2625

27-
- name: Build package
28-
run: npm run build
26+
- if: steps.version.outputs.changed == 'true'
27+
uses: softprops/action-gh-release@v2
28+
with:
29+
tag_name: ${{ steps.version.outputs.version }}
30+
name: ${{ steps.version.outputs.version }}
31+
generate_release_notes: true
32+
33+
- if: steps.version.outputs.changed == 'true'
34+
uses: actions/setup-node@v6
35+
with:
36+
node-version: '24'
37+
registry-url: https://registry.npmjs.org
2938

30-
- name: Publish to npm
31-
run: npm publish
39+
- if: steps.version.outputs.changed == 'true'
40+
run: |
41+
npm ci
42+
npm run build
43+
npm publish
3244
env:
3345
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)