Skip to content

Commit 717dac1

Browse files
mikolalysenkoclaude
andcommitted
Use per-platform optionalDependencies for npm package
Instead of bundling all 10 platform binaries into a single package (~40MB+), publish each binary as a separate @socketsecurity/socket-patch-<platform>-<arch> package with os/cpu fields so npm only installs the matching one. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a55a915 commit 717dac1

File tree

16 files changed

+305
-69
lines changed

16 files changed

+305
-69
lines changed

.github/workflows/release.yml

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -238,35 +238,46 @@ jobs:
238238
- name: Update npm for trusted publishing
239239
run: npm install -g npm@latest
240240

241-
- name: Stage binaries
241+
- name: Stage binaries into platform packages
242242
run: |
243-
mkdir -p npm/socket-patch/bin
244-
tar xzf artifacts/socket-patch-aarch64-apple-darwin.tar.gz -C npm/socket-patch/bin/
245-
mv npm/socket-patch/bin/socket-patch npm/socket-patch/bin/socket-patch-darwin-arm64
246-
tar xzf artifacts/socket-patch-x86_64-apple-darwin.tar.gz -C npm/socket-patch/bin/
247-
mv npm/socket-patch/bin/socket-patch npm/socket-patch/bin/socket-patch-darwin-x64
248-
tar xzf artifacts/socket-patch-x86_64-unknown-linux-musl.tar.gz -C npm/socket-patch/bin/
249-
mv npm/socket-patch/bin/socket-patch npm/socket-patch/bin/socket-patch-linux-x64
250-
tar xzf artifacts/socket-patch-aarch64-unknown-linux-gnu.tar.gz -C npm/socket-patch/bin/
251-
mv npm/socket-patch/bin/socket-patch npm/socket-patch/bin/socket-patch-linux-arm64
252-
tar xzf artifacts/socket-patch-arm-unknown-linux-gnueabihf.tar.gz -C npm/socket-patch/bin/
253-
mv npm/socket-patch/bin/socket-patch npm/socket-patch/bin/socket-patch-linux-arm
254-
tar xzf artifacts/socket-patch-i686-unknown-linux-gnu.tar.gz -C npm/socket-patch/bin/
255-
mv npm/socket-patch/bin/socket-patch npm/socket-patch/bin/socket-patch-linux-ia32
256-
tar xzf artifacts/socket-patch-aarch64-linux-android.tar.gz -C npm/socket-patch/bin/
257-
mv npm/socket-patch/bin/socket-patch npm/socket-patch/bin/socket-patch-android-arm64
258-
cd npm/socket-patch/bin
259-
unzip ../../../artifacts/socket-patch-x86_64-pc-windows-msvc.zip
260-
mv socket-patch.exe socket-patch-win32-x64.exe
261-
unzip ../../../artifacts/socket-patch-i686-pc-windows-msvc.zip
262-
mv socket-patch.exe socket-patch-win32-ia32.exe
263-
unzip ../../../artifacts/socket-patch-aarch64-pc-windows-msvc.zip
264-
mv socket-patch.exe socket-patch-win32-arm64.exe
243+
# Unix platforms: extract binary into each platform package directory
244+
stage_unix() {
245+
local artifact="$1" pkg_dir="$2"
246+
tar xzf "artifacts/${artifact}.tar.gz" -C "${pkg_dir}/"
247+
}
248+
249+
# Windows platforms: extract .exe into each platform package directory
250+
stage_win() {
251+
local artifact="$1" pkg_dir="$2"
252+
unzip -o "artifacts/${artifact}.zip" -d "${pkg_dir}/"
253+
}
254+
255+
stage_unix socket-patch-aarch64-apple-darwin npm/socket-patch-darwin-arm64
256+
stage_unix socket-patch-x86_64-apple-darwin npm/socket-patch-darwin-x64
257+
stage_unix socket-patch-x86_64-unknown-linux-musl npm/socket-patch-linux-x64
258+
stage_unix socket-patch-aarch64-unknown-linux-gnu npm/socket-patch-linux-arm64
259+
stage_unix socket-patch-arm-unknown-linux-gnueabihf npm/socket-patch-linux-arm
260+
stage_unix socket-patch-i686-unknown-linux-gnu npm/socket-patch-linux-ia32
261+
stage_unix socket-patch-aarch64-linux-android npm/socket-patch-android-arm64
262+
263+
stage_win socket-patch-x86_64-pc-windows-msvc npm/socket-patch-win32-x64
264+
stage_win socket-patch-i686-pc-windows-msvc npm/socket-patch-win32-ia32
265+
stage_win socket-patch-aarch64-pc-windows-msvc npm/socket-patch-win32-arm64
266+
267+
- name: Publish platform packages
268+
run: |
269+
for pkg_dir in npm/socket-patch-*/; do
270+
echo "Publishing ${pkg_dir}..."
271+
npm publish "./${pkg_dir}" --provenance --access public
272+
done
273+
274+
- name: Wait for npm registry propagation
275+
run: sleep 30
265276

266277
- name: Copy README for npm package
267278
run: cp README.md npm/socket-patch/README.md
268279

269-
- name: Publish package
280+
- name: Publish main package
270281
run: npm publish ./npm/socket-patch --provenance --access public
271282

272283
pypi-publish:
@@ -292,6 +303,9 @@ jobs:
292303
with:
293304
python-version: '3.12'
294305

306+
- name: Copy README for PyPI package
307+
run: cp README.md pypi/socket-patch/README.md
308+
295309
- name: Build platform wheels
296310
run: |
297311
VERSION="${{ needs.sync-and-tag.outputs.version }}"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@socketsecurity/socket-patch-android-arm64",
3+
"version": "1.6.0",
4+
"description": "socket-patch binary for Android ARM64",
5+
"os": [
6+
"android"
7+
],
8+
"cpu": [
9+
"arm64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
},
14+
"license": "MIT",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/SocketDev/socket-patch"
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@socketsecurity/socket-patch-darwin-arm64",
3+
"version": "1.6.0",
4+
"description": "socket-patch binary for macOS ARM64",
5+
"os": [
6+
"darwin"
7+
],
8+
"cpu": [
9+
"arm64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
},
14+
"license": "MIT",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/SocketDev/socket-patch"
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@socketsecurity/socket-patch-darwin-x64",
3+
"version": "1.6.0",
4+
"description": "socket-patch binary for macOS x64",
5+
"os": [
6+
"darwin"
7+
],
8+
"cpu": [
9+
"x64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
},
14+
"license": "MIT",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/SocketDev/socket-patch"
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@socketsecurity/socket-patch-linux-arm",
3+
"version": "1.6.0",
4+
"description": "socket-patch binary for Linux ARM",
5+
"os": [
6+
"linux"
7+
],
8+
"cpu": [
9+
"arm"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
},
14+
"license": "MIT",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/SocketDev/socket-patch"
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@socketsecurity/socket-patch-linux-arm64",
3+
"version": "1.6.0",
4+
"description": "socket-patch binary for Linux ARM64",
5+
"os": [
6+
"linux"
7+
],
8+
"cpu": [
9+
"arm64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
},
14+
"license": "MIT",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/SocketDev/socket-patch"
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@socketsecurity/socket-patch-linux-ia32",
3+
"version": "1.6.0",
4+
"description": "socket-patch binary for Linux ia32",
5+
"os": [
6+
"linux"
7+
],
8+
"cpu": [
9+
"ia32"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
},
14+
"license": "MIT",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/SocketDev/socket-patch"
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@socketsecurity/socket-patch-linux-x64",
3+
"version": "1.6.0",
4+
"description": "socket-patch binary for Linux x64",
5+
"os": [
6+
"linux"
7+
],
8+
"cpu": [
9+
"x64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
},
14+
"license": "MIT",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/SocketDev/socket-patch"
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@socketsecurity/socket-patch-win32-arm64",
3+
"version": "1.6.0",
4+
"description": "socket-patch binary for Windows ARM64",
5+
"os": [
6+
"win32"
7+
],
8+
"cpu": [
9+
"arm64"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
},
14+
"license": "MIT",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/SocketDev/socket-patch"
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@socketsecurity/socket-patch-win32-ia32",
3+
"version": "1.6.0",
4+
"description": "socket-patch binary for Windows ia32",
5+
"os": [
6+
"win32"
7+
],
8+
"cpu": [
9+
"ia32"
10+
],
11+
"publishConfig": {
12+
"access": "public"
13+
},
14+
"license": "MIT",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/SocketDev/socket-patch"
18+
}
19+
}

0 commit comments

Comments
 (0)