Skip to content

Commit da2456a

Browse files
committed
feat(ci): reuse cached binaries from build-socketbin.yml
Update publish-socketbin.yml to restore and reuse cached smol binaries from build-socketbin.yml workflow. This eliminates redundant binary compilation when publishing to npm. Cache integration: - Restores smol binary using same cache key as build-socketbin.yml - Matches hash algorithm: build/patches + node-smol-builder + scripts - Key format: node-smol-{platform}-{arch}-{hash} Workflow coordination: - build-socketbin.yml creates cache - publish-socketbin.yml restores from same cache - Cache shared across workflows in monorepo Benefits: - Eliminates redundant 2-hour binary builds on publish - Reuses pre-built binaries from build-socketbin.yml - Faster publish workflow (~10 minutes vs ~2 hours) - Consistent binaries between testing and publishing Fallback behavior: - If cache miss, builds from source as before - No behavior change for existing publish process - Only adds optimization when cache available
1 parent e40e2e6 commit da2456a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

.github/workflows/publish-socketbin.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,23 @@ jobs:
101101
id: build-cache-key
102102
shell: bash
103103
run: |
104-
# Generate hash from build-affecting files
104+
# Generate hash from build-affecting files (matches build-binaries.yml).
105105
if [ "${{ matrix.os }}" = "windows" ]; then
106-
HASH=$(find build/patches scripts -type f -name "*.patch" -o -name "*.mjs" | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
106+
HASH=$(find build/patches packages/node-smol-builder scripts -type f -name "*.patch" -o -name "*.mjs" | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
107107
else
108-
HASH=$(find build/patches scripts -type f \( -name "*.patch" -o -name "*.mjs" \) | sort | xargs shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
108+
HASH=$(find build/patches packages/node-smol-builder scripts -type f \( -name "*.patch" -o -name "*.mjs" \) | sort | xargs shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
109109
fi
110110
echo "hash=$HASH" >> $GITHUB_OUTPUT
111111
echo "Build hash: $HASH"
112112
113+
- name: Restore smol binary from build-socketbin.yml cache
114+
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
115+
id: smol-cache
116+
with:
117+
path: packages/node-smol-builder/dist/socket-smol-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.os == 'windows' && '.exe' || '' }}
118+
key: node-smol-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.build-cache-key.outputs.hash }}
119+
restore-keys: node-smol-${{ matrix.platform }}-${{ matrix.arch }}-
120+
113121
- name: Cache compiled Node.js binary
114122
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.2.0
115123
id: binary-cache

0 commit comments

Comments
 (0)