-
Notifications
You must be signed in to change notification settings - Fork 5
127 lines (108 loc) · 3.43 KB
/
Copy pathpublish-node.yml
File metadata and controls
127 lines (108 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Publish Node SDK
on:
workflow_call:
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: aarch64-apple-darwin
- host: macos-latest
target: x86_64-apple-darwin
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
zig: true
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
zig: true
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
zig: true
- host: windows-latest
target: x86_64-pc-windows-msvc
name: Build ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Setup workspace context
shell: bash
run: bash .github/setup-workspace.sh
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
- name: Install protobuf compiler
shell: bash
run: |
if [ "${{ matrix.settings.host }}" = "ubuntu-latest" ]; then
sudo apt-get update && sudo apt-get install -y protobuf-compiler
elif [ "${{ matrix.settings.host }}" = "windows-latest" ]; then
choco install protoc -y
else
brew install protobuf
fi
- name: Install Zig
if: matrix.settings.zig
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.13.0
- name: Install dependencies
working-directory: sdk/node
run: npm install
- name: Build native module
working-directory: sdk/node
shell: bash
run: |
if [ "${{ matrix.settings.zig }}" = "true" ]; then
npx napi build --platform --release --target ${{ matrix.settings.target }} --zig
else
npx napi build --platform --release --target ${{ matrix.settings.target }}
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: node-bindings-${{ matrix.settings.target }}
path: sdk/node/*.node
if-no-files-found: error
publish:
name: Publish to npm
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
- name: Install dependencies
working-directory: sdk/node
run: npm install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: node-bindings-*
path: sdk/node/artifacts
merge-multiple: true
- name: Move artifacts
working-directory: sdk/node
run: |
mv artifacts/*.node . 2>/dev/null || true
ls -la *.node
- name: Prepublish (generate optionalDependencies)
working-directory: sdk/node
run: npx napi prepublish -t npm
- name: Publish to npm
working-directory: sdk/node
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --ignore-scripts || true