Skip to content

Commit 0ce3344

Browse files
sfastsfast
authored andcommitted
ci: add npm publish workflow with OIDC
1 parent 1c5fe3a commit 0ce3344

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/publish.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [created]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version bump type'
10+
required: true
11+
default: 'patch'
12+
type: choice
13+
options:
14+
- patch
15+
- minor
16+
- major
17+
18+
permissions:
19+
contents: write
20+
id-token: write
21+
22+
jobs:
23+
publish:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: '22'
35+
registry-url: 'https://registry.npmjs.org'
36+
37+
- name: Install dependencies
38+
run: npm install
39+
40+
- name: Run tests
41+
run: npm test
42+
43+
- name: Run linter
44+
run: npm run lint
45+
46+
- name: Build
47+
run: npm run build
48+
49+
- name: Bump version
50+
if: github.event_name == 'workflow_dispatch'
51+
run: |
52+
git config user.name "GitHub Actions Bot"
53+
git config user.email "actions@github.com"
54+
npm version ${{ github.event.inputs.version }} -m "chore: release v%s"
55+
git push --follow-tags
56+
57+
- name: Publish to npm
58+
run: npm publish --provenance --access public
59+

0 commit comments

Comments
 (0)