Skip to content

Commit b8dae34

Browse files
committed
Add GitHub Actions workflow with NPM trusted publishing
1 parent c2c311c commit b8dae34

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
release:
9+
types: [ created ]
10+
11+
# See https://docs.npmjs.com/trusted-publishers#step-2-configure-your-cicd-workflow
12+
permissions:
13+
id-token: write
14+
contents: read
15+
16+
jobs:
17+
build:
18+
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
30+
- name: Install dependencies
31+
run: npm install
32+
33+
publish:
34+
needs: build
35+
runs-on: ubuntu-latest
36+
if: ${{ github.event_name == 'release' }}
37+
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Setup Node
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version: 20
46+
registry-url: https://registry.npmjs.org/
47+
48+
# Ensure npm 11.5.1 or later is installed
49+
- name: Update npm
50+
run: npm install -g npm@latest
51+
52+
- name: Install dependencies
53+
run: npm install
54+
55+
- name: Set new version
56+
run: npm version --allow-same-version --no-git-tag-version ${{ github.event.release.tag_name }}
57+
58+
- name: Publish release
59+
run: npm publish

0 commit comments

Comments
 (0)