Skip to content

Commit 6865878

Browse files
committed
update npm publish workflow
migrate to 'Trusted Publishers'
1 parent 6c7d318 commit 6865878

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: Build and Test
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
id-token: write
412

513
jobs:
614
build:
@@ -10,7 +18,11 @@ jobs:
1018

1119
strategy:
1220
matrix:
13-
node-version: [18.x, 20.x, 22.x, 24.x]
21+
node-version:
22+
- { v: 18 }
23+
- { v: 20 }
24+
- { v: 22 }
25+
- { v: 24, isLatest: yes }
1426

1527
steps:
1628
- name: ⏬ Checkout code
@@ -19,7 +31,7 @@ jobs:
1931
- name: 🔢 Use Node.js ${{ matrix.node-version }}
2032
uses: actions/setup-node@v2
2133
with:
22-
node-version: ${{ matrix.node-version }}
34+
node-version: ${{ matrix.node-version.v }}
2335

2436
- name: ⏬ Install
2537
run: |
@@ -45,10 +57,5 @@ jobs:
4557
# github-token: ${{ secrets.github_token }}
4658

4759
- name: 📦 Publish
48-
if: ${{ github.ref == 'refs/heads/main' && matrix['node-version'] == '20.x' }}
49-
run: |
50-
npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN
51-
npm run trypublish
52-
env:
53-
CI: true
54-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
60+
uses: k-yle/npm-publish@v1
61+
if: ${{ matrix.node-version.isLatest }}

0 commit comments

Comments
 (0)