|
12 | 12 | settings: |
13 | 13 | - host: macos-latest |
14 | 14 | target: aarch64-apple-darwin |
15 | | - - host: macos-latest |
16 | | - target: x86_64-apple-darwin |
17 | 15 | - host: ubuntu-latest |
18 | 16 | target: x86_64-unknown-linux-gnu |
19 | 17 | - host: ubuntu-latest |
@@ -118,7 +116,67 @@ jobs: |
118 | 116 |
|
119 | 117 | - name: Prepublish (generate optionalDependencies) |
120 | 118 | 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 |
122 | 180 |
|
123 | 181 | - name: Publish to npm |
124 | 182 | working-directory: sdk/node |
|
0 commit comments