Skip to content

Commit 4697caa

Browse files
committed
fix: update napi config and workflows for OIDC trusted publishing
- Fix native/package.json to use binaryName and targets (napi v3 format) - Add id-token: write permission for npm OIDC authentication - Add --provenance flag for supply chain security - Remove NPM_TOKEN dependency, use trusted publishers instead - Add cross-compilation linker for ARM64 Linux builds - Update to Node.js 22
1 parent c41d4b6 commit 4697caa

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
name: Build
1+
name: Build and Publish
22

33
on:
44
release:
55
types: [published]
66
workflow_dispatch:
77

8+
permissions:
9+
contents: read
10+
id-token: write
11+
812
jobs:
913
build:
1014
strategy:
@@ -29,7 +33,7 @@ jobs:
2933
- name: Setup Node.js
3034
uses: actions/setup-node@v4
3135
with:
32-
node-version: '20'
36+
node-version: '22'
3337
cache: 'npm'
3438

3539
- name: Setup Rust
@@ -41,15 +45,16 @@ jobs:
4145
if: matrix.target == 'aarch64-unknown-linux-gnu'
4246
run: |
4347
sudo apt-get update
44-
sudo apt-get install -y gcc-aarch64-linux-gnu
48+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
4549
4650
- name: Install dependencies
4751
run: npm ci
4852

4953
- name: Build native module
50-
run: |
51-
cd native
52-
npx napi build --release --platform --target ${{ matrix.target }}
54+
working-directory: native
55+
run: npx napi build --release --platform --target ${{ matrix.target }}
56+
env:
57+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
5358

5459
- name: Upload artifact
5560
uses: actions/upload-artifact@v4
@@ -62,13 +67,16 @@ jobs:
6267
needs: build
6368
runs-on: ubuntu-latest
6469
if: github.event_name == 'release'
70+
permissions:
71+
contents: read
72+
id-token: write
6573
steps:
6674
- uses: actions/checkout@v4
6775

6876
- name: Setup Node.js
6977
uses: actions/setup-node@v4
7078
with:
71-
node-version: '20'
79+
node-version: '22'
7280
cache: 'npm'
7381
registry-url: 'https://registry.npmjs.org'
7482

@@ -88,6 +96,4 @@ jobs:
8896
run: ls -la native/*.node
8997

9098
- name: Publish to npm
91-
run: npm publish
92-
env:
93-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
99+
run: npm publish --provenance --access public

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Setup Node.js
1616
uses: actions/setup-node@v4
1717
with:
18-
node-version: '20'
18+
node-version: '22'
1919
cache: 'npm'
2020

2121
- name: Setup Rust
@@ -25,7 +25,10 @@ jobs:
2525
run: npm ci
2626

2727
- name: Build native module
28-
run: npm run build:native
28+
working-directory: native
29+
run: |
30+
cargo build --release
31+
npx napi build --release --platform
2932
3033
- name: Build TypeScript
3134
run: npm run build:ts
@@ -44,7 +47,7 @@ jobs:
4447
- name: Setup Node.js
4548
uses: actions/setup-node@v4
4649
with:
47-
node-version: '20'
50+
node-version: '22'
4851
cache: 'npm'
4952

5053
- name: Install dependencies

native/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"name": "codebase-index-native",
33
"version": "0.1.0",
44
"napi": {
5-
"name": "codebase-index-native",
6-
"triples": {
7-
"defaults": true,
8-
"additional": [
9-
"aarch64-apple-darwin"
10-
]
11-
}
5+
"binaryName": "codebase-index-native",
6+
"targets": [
7+
"x86_64-apple-darwin",
8+
"aarch64-apple-darwin",
9+
"x86_64-unknown-linux-gnu",
10+
"aarch64-unknown-linux-gnu",
11+
"x86_64-pc-windows-msvc"
12+
]
1213
}
1314
}

0 commit comments

Comments
 (0)