Skip to content

Commit 0d5e88b

Browse files
Merge pull request #61 from codedbychavez/trusted-publishing
Configure GitHub workflow to use trusted publishing
2 parents cb2c644 + 39e84a0 commit 0d5e88b

File tree

1 file changed

+51
-34
lines changed

1 file changed

+51
-34
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
name: CI
2-
permissions:
3-
contents: read
42

53
on:
64
schedule:
75
- cron: "0 0 * * *"
86
push:
9-
branches:
10-
- "main"
11-
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
7+
branches: [main]
8+
tags: ['v[0-9]+.[0-9]+.[0-9]+']
129
pull_request:
13-
branches:
14-
- "main"
10+
branches: [main]
1511

1612
workflow_dispatch:
1713
inputs:
@@ -26,42 +22,63 @@ on:
2622
- debug
2723

2824
jobs:
29-
test:
25+
build_and_test:
3026
runs-on: ubuntu-latest
31-
name: Run unit and integration tests
32-
strategy:
33-
matrix:
34-
version: [20, 22]
27+
name: Build and test
3528
steps:
36-
- uses: actions/checkout@v4
37-
- name: Using Node.js ${{ matrix.version }}
38-
uses: actions/setup-node@v4
29+
- uses: actions/checkout@v5
30+
31+
- uses: actions/setup-node@v5
3932
with:
40-
node-version: ${{ matrix.version }}
33+
node-version: 22
34+
4135
- name: Install dependencies
42-
run: npm install
43-
- name: Run tests
36+
run: npm ci
37+
38+
- name: Build
39+
run: npm run build
40+
41+
- name: Test
4442
run: npm test
4543

46-
build_and_publish:
47-
needs: [test]
44+
- name: Upload dist artifact
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: dist
48+
path: dist/
49+
50+
publish:
51+
needs: [build_and_test]
52+
if: startsWith(github.ref, 'refs/tags/')
4853
runs-on: ubuntu-latest
49-
if: startsWith(github.ref, 'refs/tags')
54+
permissions:
55+
contents: read
56+
id-token: write
5057
steps:
51-
- uses: actions/checkout@v4
52-
53-
- uses: actions/setup-node@v4
58+
- uses: actions/checkout@v5
59+
- uses: actions/setup-node@v5
5460
with:
55-
node-version: 22
56-
registry-url: "https://registry.npmjs.org"
61+
node-version: "22"
5762

58-
- name: Install dependencies
59-
run: npm install
63+
# Ensure npm 11.5.1 or later is installed
64+
- name: Update npm
65+
run: npm install -g npm@latest
6066

61-
- name: Build
62-
run: npm run build
67+
- name: Download build artifacts
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: dist
71+
path: dist/
72+
73+
- name: Pack
74+
run: npm pack
75+
76+
- name: Upload package
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: package-tarball
80+
path: '*.tgz'
81+
retention-days: 7
6382

64-
- name: Publish
65-
run: npm publish
66-
env:
67-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
83+
- name: Publish (trusted publishing)
84+
run: npm publish --dry-run

0 commit comments

Comments
 (0)