Skip to content

Commit 3e32920

Browse files
committed
fix: update Code release workflows for arm64-only macOS
- remove macOS Intel build targets - publish Node platform packages without napi prepublish
1 parent e49244a commit 3e32920

2 files changed

Lines changed: 61 additions & 5 deletions

File tree

.github/workflows/publish-node.yml

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ jobs:
1212
settings:
1313
- host: macos-latest
1414
target: aarch64-apple-darwin
15-
- host: macos-latest
16-
target: x86_64-apple-darwin
1715
- host: ubuntu-latest
1816
target: x86_64-unknown-linux-gnu
1917
- host: ubuntu-latest
@@ -118,7 +116,67 @@ jobs:
118116
119117
- name: Prepublish (generate optionalDependencies)
120118
working-directory: sdk/node
121-
run: npx napi prepublish -t npm
119+
shell: bash
120+
env:
121+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
122+
run: |
123+
set -euo pipefail
124+
test -n "${NPM_TOKEN:-}" || { echo "Missing NPM_TOKEN secret" >&2; exit 1; }
125+
ls -1 *.node
126+
rm -rf npm
127+
mkdir -p npm
128+
VERSION="$(node -p "require('./package.json').version")"
129+
130+
create_pkg() {
131+
local dir="$1"
132+
local pkg_name="$2"
133+
local os="$3"
134+
local cpu="$4"
135+
local node_file="$5"
136+
local libc="${6:-}"
137+
138+
mkdir -p "npm/$dir"
139+
cp "$node_file" "npm/$dir/$node_file"
140+
141+
cat > "npm/$dir/package.json" <<JSON
142+
{
143+
"name": "@a3s-lab/${pkg_name}",
144+
"version": "$VERSION",
145+
"os": ["$os"],
146+
"cpu": ["$cpu"],
147+
"main": "$node_file",
148+
"files": ["$node_file"],
149+
"description": "Native binding for @a3s-lab/code ($dir)",
150+
"license": "MIT",
151+
"repository": {
152+
"type": "git",
153+
"url": "https://github.com/A3S-Lab/Code",
154+
"directory": "sdk/node"
155+
}$(if [[ -n "$libc" ]]; then printf ',\n "libc": ["%s"]' "$libc"; fi)
156+
}
157+
JSON
158+
}
159+
160+
create_pkg "darwin-arm64" "code-darwin-arm64" "darwin" "arm64" "index.darwin-arm64.node"
161+
create_pkg "linux-x64-gnu" "code-linux-x64-gnu" "linux" "x64" "index.linux-x64-gnu.node" "glibc"
162+
create_pkg "linux-x64-musl" "code-linux-x64-musl" "linux" "x64" "index.linux-x64-musl.node" "musl"
163+
create_pkg "linux-arm64-gnu" "code-linux-arm64-gnu" "linux" "arm64" "index.linux-arm64-gnu.node" "glibc"
164+
create_pkg "linux-arm64-musl" "code-linux-arm64-musl" "linux" "arm64" "index.linux-arm64-musl.node" "musl"
165+
create_pkg "win32-x64-msvc" "code-win32-x64-msvc" "win32" "x64" "index.win32-x64-msvc.node"
166+
167+
find npm -mindepth 1 -maxdepth 2 -type f | sort
168+
find . -maxdepth 1 -name '*.node' -delete
169+
170+
- name: Publish platform packages
171+
working-directory: sdk/node
172+
shell: bash
173+
env:
174+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
175+
run: |
176+
set -euo pipefail
177+
for pkg in npm/*; do
178+
(cd "$pkg" && npm publish --access public --ignore-scripts)
179+
done
122180
123181
- name: Publish to npm
124182
working-directory: sdk/node

.github/workflows/publish-python.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222
settings:
2323
- host: macos-latest
2424
target: aarch64-apple-darwin
25-
- host: macos-latest
26-
target: x86_64-apple-darwin
2725
- host: ubuntu-latest
2826
target: x86_64-unknown-linux-gnu
2927
manylinux: 2_28

0 commit comments

Comments
 (0)