-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (123 loc) · 4.5 KB
/
Copy pathrelease-sdk-nodejs.yml
File metadata and controls
144 lines (123 loc) · 4.5 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Release Node.js SDK
# Triggered by version tags: v1.2.3
on:
push:
tags: ["v*.*.*"]
jobs:
# ---------------------------------------------------------------------------
# Build the native .node binary for each platform in parallel
# ---------------------------------------------------------------------------
build-native:
name: Build — ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux x64 (glibc)
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: checkgate.linux-x64-gnu.node
# Linux arm64 (glibc) — cross-compile via napi-rs cross toolchain
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact: checkgate.linux-arm64-gnu.node
cross: true
# Linux x64 (musl — Alpine) — cross-compile via napi-rs cross toolchain
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact: checkgate.linux-x64-musl.node
cross: true
# macOS x64 — cross-compile natively from arm64 runner
- os: macos-latest
target: x86_64-apple-darwin
artifact: checkgate.darwin-x64.node
# macOS arm64 (Apple Silicon)
- os: macos-latest
target: aarch64-apple-darwin
artifact: checkgate.darwin-arm64.node
# Windows x64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: checkgate.win32-x64-msvc.node
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
working-directory: sdks/nodejs
run: npm install
- name: Build
working-directory: sdks/nodejs
shell: bash
run: |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-musl" ]; then
# Satisfy host-side NAPI-RS linker check (will use real linker inside Docker)
sudo ln -s /usr/bin/true /usr/bin/aarch64-linux-musl-gcc
npx napi build --platform --release --target ${{ matrix.target }} --use-napi-cross
elif [ "${{ matrix.cross }}" = "true" ]; then
npx napi build --platform --release --target ${{ matrix.target }} --use-napi-cross
else
npx napi build --platform --release --target ${{ matrix.target }}
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: node-${{ matrix.target }}
path: sdks/nodejs/${{ matrix.artifact }}
if-no-files-found: error
# ---------------------------------------------------------------------------
# Publish Job — waits for all native builds above
# ---------------------------------------------------------------------------
publish:
name: Publish to npm
needs: build-native
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: Download all native artifacts
uses: actions/download-artifact@v4
with:
pattern: node-*
merge-multiple: true
path: sdks/nodejs/
- name: Validate native binaries count
working-directory: sdks/nodejs
run: |
COUNT=$(ls checkgate.*.node | wc -l)
echo "Found $COUNT labeled native binaries."
if [ "$COUNT" -ne 6 ]; then
echo "Error: Expected 6 labeled native binaries, found $COUNT."
ls -l *.node
exit 1
fi
- name: Install dependencies
working-directory: sdks/nodejs
run: npm install
- name: Set version from tag
working-directory: sdks/nodejs
run: |
TAG="${{ github.ref_name }}"
VERSION="${TAG#v}"
npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Publish @checkgate/node
working-directory: sdks/nodejs
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}