Skip to content

Commit df91e9a

Browse files
ci: enhance GitHub Actions workflow with modern Node.js versions and security
- Update to Node.js 22 (LTS) for primary jobs and Node.js 20/22/24 for testing - Add cross-platform testing on Ubuntu, Windows, and macOS - Add security audit job with vulnerability scanning - Add package verification and npm provenance publishing - Update Node.js engine requirement to >=20.0.0 - Improve caching and performance optimizations
1 parent aa68a94 commit df91e9a

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup Node.js
2121
uses: actions/setup-node@v4
2222
with:
23-
node-version: 20
23+
node-version: 22
2424
cache: 'npm'
2525

2626
- name: Install dependencies
@@ -32,12 +32,35 @@ jobs:
3232
- name: TypeScript type checking
3333
run: npm run typecheck
3434

35+
security:
36+
name: Security Audit
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version: 22
46+
cache: 'npm'
47+
48+
- name: Install dependencies
49+
run: npm ci
50+
51+
- name: Run security audit
52+
run: npm audit --audit-level moderate
53+
54+
- name: Check for known vulnerabilities
55+
run: npm audit --audit-level high --production
56+
3557
test:
3658
name: Test
37-
runs-on: ubuntu-latest
59+
runs-on: ${{ matrix.os }}
3860
strategy:
3961
matrix:
40-
node-version: [22.x]
62+
os: [ubuntu-latest, windows-latest, macos-latest]
63+
node-version: [20.x, 22.x, 24.x]
4164

4265
steps:
4366
- name: Checkout repository
@@ -57,23 +80,23 @@ jobs:
5780

5881
- name: Upload coverage reports
5982
uses: codecov/codecov-action@v4
60-
if: matrix.node-version == '20.x' && github.event_name != 'pull_request'
83+
if: matrix.node-version == '22.x' && matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request'
6184
with:
6285
token: ${{ secrets.CODECOV_TOKEN }}
6386
fail_ci_if_error: false
6487

6588
build:
6689
name: Build
6790
runs-on: ubuntu-latest
68-
needs: [lint-and-typecheck, test]
91+
needs: [lint-and-typecheck, test, security]
6992
steps:
7093
- name: Checkout repository
7194
uses: actions/checkout@v4
7295

7396
- name: Setup Node.js
7497
uses: actions/setup-node@v4
7598
with:
76-
node-version: 20
99+
node-version: 22
77100
cache: 'npm'
78101

79102
- name: Install dependencies
@@ -93,8 +116,11 @@ jobs:
93116
name: Publish to npm
94117
runs-on: ubuntu-latest
95118
needs: build
96-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
119+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
97120
environment: npm-publish
121+
permissions:
122+
contents: read
123+
id-token: write
98124
steps:
99125
- name: Checkout repository
100126
uses: actions/checkout@v4
@@ -104,8 +130,9 @@ jobs:
104130
- name: Setup Node.js
105131
uses: actions/setup-node@v4
106132
with:
107-
node-version: 20
133+
node-version: 22
108134
registry-url: 'https://registry.npmjs.org'
135+
cache: 'npm'
109136

110137
- name: Download build artifact
111138
uses: actions/download-artifact@v4
@@ -114,10 +141,12 @@ jobs:
114141
path: dist/
115142

116143
- name: Install dependencies
117-
run: npm ci
144+
run: npm ci --only=production
145+
146+
- name: Verify package contents
147+
run: npm pack --dry-run
118148

119149
- name: Publish to NPM
120-
if: startsWith(github.ref, 'refs/tags/v')
121-
run: npm publish --access public
150+
run: npm publish --access public --provenance
122151
env:
123152
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
},
100100
101101
"engines": {
102-
"node": ">=18.0.0"
102+
"node": ">=20.0.0"
103103
},
104104
"exports": {
105105
".": {

0 commit comments

Comments
 (0)