@@ -150,14 +150,72 @@ jobs:
150150 --arch=${{ matrix.arch }} \
151151 --clean
152152
153- - name : Build CLI (required for SEA)
153+ - name : Generate build-deps cache key
154154 if : inputs.method == 'sea' || inputs.method == 'smol-sea'
155+ id : deps-cache-key
156+ shell : bash
157+ run : |
158+ # Include pnpm-lock.yaml to detect dependency changes (matches build-sea.yml).
159+ if [ "${{ matrix.os }}" = "windows" ]; then
160+ HASH=$(find packages/bootstrap packages/socket -type f \( -name "*.mts" -o -name "*.ts" -o -name "*.mjs" -o -name "*.js" -o -name "*.json" \) ! -path "*/node_modules/*" ! -path "*/dist/*" ! -path "*/build/*" | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
161+ LOCK_HASH=$(sha256sum pnpm-lock.yaml | cut -d' ' -f1)
162+ else
163+ HASH=$(find packages/bootstrap packages/socket -type f \( -name "*.mts" -o -name "*.ts" -o -name "*.mjs" -o -name "*.js" -o -name "*.json" \) ! -path "*/node_modules/*" ! -path "*/dist/*" ! -path "*/build/*" | sort | xargs shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
164+ LOCK_HASH=$(shasum -a 256 pnpm-lock.yaml | cut -d' ' -f1)
165+ fi
166+ COMBINED_HASH=$(echo "$HASH-$LOCK_HASH" | sha256sum | cut -d' ' -f1 || echo "$HASH-$LOCK_HASH" | shasum -a 256 | cut -d' ' -f1)
167+ echo "deps-hash=$COMBINED_HASH" >> $GITHUB_OUTPUT
168+
169+ - name : Restore build-deps cache
170+ if : inputs.method == 'sea' || inputs.method == 'smol-sea'
171+ id : deps-cache
172+ uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
173+ with :
174+ path : |
175+ packages/bootstrap/dist/
176+ packages/socket/dist/
177+ key : build-deps-sea-${{ steps.deps-cache-key.outputs.deps-hash }}
178+ restore-keys : build-deps-sea-
179+
180+ - name : Build bootstrap package
181+ if : (inputs.method == 'sea' || inputs.method == 'smol-sea') && steps.deps-cache.outputs.cache-hit != 'true'
182+ run : pnpm --filter @socketsecurity/bootstrap run build
183+
184+ - name : Build socket package bootstrap
185+ if : (inputs.method == 'sea' || inputs.method == 'smol-sea') && steps.deps-cache.outputs.cache-hit != 'true'
186+ run : pnpm --filter socket run build
187+
188+ - name : Generate SEA build cache key
189+ if : inputs.method == 'sea' || inputs.method == 'smol-sea'
190+ id : sea-cache-key
191+ shell : bash
192+ run : |
193+ if [ "${{ matrix.os }}" = "windows" ]; then
194+ SEA_HASH=$(find packages/node-sea-builder packages/cli/src -type f \( -name "*.mts" -o -name "*.ts" -o -name "*.mjs" -o -name "*.js" \) | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
195+ else
196+ SEA_HASH=$(find packages/node-sea-builder packages/cli/src -type f \( -name "*.mts" -o -name "*.ts" -o -name "*.mjs" -o -name "*.js" \) | sort | xargs shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
197+ fi
198+ # Include bootstrap/socket/cli dependencies in cache key (matches build-sea.yml).
199+ COMBINED_HASH=$(echo "$SEA_HASH-${{ steps.deps-cache-key.outputs.deps-hash }}" | sha256sum | cut -d' ' -f1 || echo "$SEA_HASH-${{ steps.deps-cache-key.outputs.deps-hash }}" | shasum -a 256 | cut -d' ' -f1)
200+ echo "hash=$COMBINED_HASH" >> $GITHUB_OUTPUT
201+
202+ - name : Restore SEA binary cache
203+ if : inputs.method == 'sea' || inputs.method == 'smol-sea'
204+ id : sea-cache
205+ uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
206+ with :
207+ path : packages/node-sea-builder/dist/sea/
208+ key : node-sea-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.sea-cache-key.outputs.hash }}
209+ restore-keys : node-sea-${{ matrix.platform }}-${{ matrix.arch }}-
210+
211+ - name : Build CLI (required for SEA)
212+ if : (inputs.method == 'sea' || inputs.method == 'smol-sea') && steps.sea-cache.outputs.cache-hit != 'true'
155213 shell : bash
156214 run : pnpm --filter @socketsecurity/cli run build
157215
158216 - name : Build SEA binary
159217 id : build-sea
160- if : inputs.method == 'sea' || inputs.method == 'smol-sea'
218+ if : ( inputs.method == 'sea' || inputs.method == 'smol-sea') && steps.sea-cache.outputs.cache-hit != 'true '
161219 shell : bash
162220 run : |
163221 echo "Building SEA binary..."
0 commit comments