Skip to content

Commit 15d0d12

Browse files
chore: update publish workflow to include concurrency and improve clarity
1 parent 5001318 commit 15d0d12

1 file changed

Lines changed: 38 additions & 31 deletions

File tree

.github/workflows/publish.yml

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
name: Publish to npm
2-
3-
on:
4-
push:
5-
tags:
6-
- 'v*'
7-
release:
8-
types: [published]
9-
10-
permissions:
11-
contents: read
12-
packages: write
13-
id-token: write
14-
15-
jobs:
16-
publish:
17-
name: Publish package
18-
runs-on: ubuntu-latest
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
id-token: write
12+
13+
concurrency:
14+
group: publish-${{ github.ref }}
15+
cancel-in-progress: false
16+
17+
jobs:
18+
publish:
19+
name: Publish package
20+
runs-on: ubuntu-latest
1921

2022
steps:
2123
- name: Checkout
@@ -27,20 +29,25 @@ jobs:
2729
node-version: '18'
2830
registry-url: 'https://registry.npmjs.org'
2931

30-
- name: Install dependencies
31-
run: npm ci
32-
33-
- name: Publish to npm (using NPM_TOKEN)
34-
if: secrets.NPM_TOKEN != ''
35-
env:
36-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Run tests
36+
run: npm test
37+
38+
- name: Run linter
39+
run: npm run lint
40+
41+
- name: Publish to npm (using NPM_TOKEN)
42+
if: secrets.NPM_TOKEN != ''
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3745
run: |
3846
echo "Publishing with NPM_TOKEN..."
3947
npm publish --access public
4048
41-
- name: Publish to npm (OIDC / Trusted Publisher)
42-
if: secrets.NPM_TOKEN == ''
43-
run: |
44-
echo "No NPM_TOKEN found. To publish without a stored token, set up a Trusted Publisher in npm and enable OIDC."
45-
echo "See README or npm docs for steps to configure Trusted Publisher."
46-
exit 1
49+
- name: Publish to npm (OIDC / Trusted Publisher)
50+
if: secrets.NPM_TOKEN == ''
51+
run: |
52+
echo "No NPM_TOKEN found. Trying Trusted Publisher via OIDC..."
53+
npm publish --access public --provenance

0 commit comments

Comments
 (0)