Skip to content

🤏 Smol Binaries

🤏 Smol Binaries #6

Workflow file for this run

name: 🤏 Build Smol Node Binaries
on:
workflow_call:
inputs:
force:
description: 'Force rebuild (ignore cache)'
required: false
type: boolean
default: false
workflow_dispatch:
inputs:
force:
description: 'Force rebuild (ignore cache)'
required: false
type: boolean
default: false
# Removed push/pull_request triggers to prevent automatic builds.
# Run manually via workflow_dispatch or via workflow_call from build-socketbin.yml.
permissions:
contents: read
concurrency:
group: build-smol-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-smol:
name: 🤏 Build smol binary - ${{ matrix.platform }}-${{ matrix.arch }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 120
strategy:
fail-fast: false
max-parallel: 6
matrix:
include:
# Linux builds (8-core runners for faster compilation).
- runner: ubuntu-latest-8-cores
os: linux
platform: linux
arch: x64
- runner: ubuntu-latest-8-cores
os: linux
platform: linux
arch: arm64
# macOS builds (8-core runners for faster compilation).
- runner: macos-latest-xlarge
os: darwin
platform: darwin
arch: x64
- runner: macos-latest-xlarge
os: darwin
platform: darwin
arch: arm64
# Windows builds (8-core runners for faster compilation).
- runner: windows-latest-8-cores
os: windows
platform: win32
arch: x64
- runner: windows-latest-8-cores
os: windows
platform: win32
arch: arm64
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 22
- name: Setup pnpm
uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
with:
version: ^10.16.0
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build socket package bootstrap
run: pnpm --filter socket run build
- name: Generate smol build cache key
id: smol-cache-key
shell: bash
run: |
HASH=$(find patches packages/node-smol-builder/patches packages/node-smol-builder/additions scripts -type f \( -name "*.patch" -o -name "*.mjs" -o -name "*.h" -o -name "*.c" -o -name "*.cc" \) | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Setup ccache (Linux/macOS)
if: matrix.os != 'windows'
uses: hendrikmuhs/ccache-action@ed74d11c0b343532753ecead8a951bb09bb34bc9 # v1.2.14
with:
key: build-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.smol-cache-key.outputs.hash }}
max-size: 2G
- name: Restore smol build cache
if: inputs.force != true
id: smol-build-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: packages/node-smol-builder/build
key: node-smol-build-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.smol-cache-key.outputs.hash }}
restore-keys: |
node-smol-build-${{ matrix.platform }}-${{ matrix.arch }}-
- name: Restore smol stripped binary cache
if: inputs.force != true
id: smol-stripped-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: packages/node-smol-builder/build/out/Stripped
key: node-smol-stripped-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.smol-cache-key.outputs.hash }}
restore-keys: node-smol-stripped-${{ matrix.platform }}-${{ matrix.arch }}-
- name: Restore smol binary cache
if: inputs.force != true
id: smol-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: packages/node-smol-builder/dist/socket-smol-${{ matrix.platform }}-${{ matrix.arch }}
key: node-smol-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.smol-cache-key.outputs.hash }}
restore-keys: node-smol-${{ matrix.platform }}-${{ matrix.arch }}-
- name: Verify smol binary cache
id: smol-cache-valid
shell: bash
run: |
BINARY_PATH="packages/node-smol-builder/dist/socket-smol-${{ matrix.platform }}-${{ matrix.arch }}"
if [ "${{ matrix.os }}" = "windows" ]; then
BINARY_PATH="${BINARY_PATH}.exe"
fi
if [ -f "$BINARY_PATH" ]; then
echo "valid=true" >> $GITHUB_OUTPUT
echo "✓ Smol binary cache valid: $BINARY_PATH"
else
echo "valid=false" >> $GITHUB_OUTPUT
echo "✗ Smol binary cache invalid or missing: $BINARY_PATH"
fi
- name: Setup Python
if: steps.smol-cache-valid.outputs.valid != 'true' || inputs.force
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.11'
- name: Verify Python installation
if: steps.smol-cache-valid.outputs.valid != 'true' || inputs.force
shell: bash
run: |
echo "Python version:"
python3 --version
which python3
echo "PATH=$PATH"
- name: Install build dependencies (Ubuntu)
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Cache Ninja (Ubuntu)
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'linux'
id: ninja-cache-ubuntu
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: /usr/bin/ninja
key: ninja-ubuntu-${{ runner.os }}-${{ runner.arch }}
- name: Install Ninja (Ubuntu)
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'linux' && steps.ninja-cache-ubuntu.outputs.cache-hit != 'true'
run: sudo apt-get install -y ninja-build
- name: Cache Ninja (macOS)
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'darwin'
id: ninja-cache-macos
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
/usr/local/bin/ninja
/opt/homebrew/bin/ninja
key: ninja-macos-${{ runner.os }}-${{ runner.arch }}
- name: Install Ninja (macOS)
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'darwin' && steps.ninja-cache-macos.outputs.cache-hit != 'true'
run: brew install ninja
- name: Cache Ninja (Windows)
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'win32'
id: ninja-cache-windows
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: C:\ProgramData\chocolatey\bin\ninja.exe
key: ninja-windows-${{ runner.os }}-${{ runner.arch }}
- name: Install Ninja (Windows)
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'win32' && steps.ninja-cache-windows.outputs.cache-hit != 'true'
run: choco install ninja
- name: Build smol binary
if: steps.smol-cache-valid.outputs.valid != 'true' || inputs.force
run: pnpm --filter @socketbin/node-smol-builder run build
- name: Verify smol binary
shell: bash
run: |
echo "=== smol Binary Build Artifacts ==="
mkdir -p packages/node-smol-builder/dist
ls -lh packages/node-smol-builder/dist/
echo ""
BINARY_PATH="packages/node-smol-builder/dist/socket-smol-${{ matrix.platform }}-${{ matrix.arch }}"
if [ -f "$BINARY_PATH" ] || [ -f "${BINARY_PATH}.exe" ]; then
if [ "${{ matrix.os }}" = "windows" ]; then
echo "socket-smol-${{ matrix.platform }}-${{ matrix.arch }}.exe size: $(du -h ${BINARY_PATH}.exe | cut -f1)"
else
echo "socket-smol-${{ matrix.platform }}-${{ matrix.arch }} size: $(du -h $BINARY_PATH | cut -f1)"
fi
else
echo "⚠️ Binary not found at expected path"
fi
- name: Upload smol binary
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: socket-smol-${{ matrix.platform }}-${{ matrix.arch }}
path: |
packages/node-smol-builder/dist/socket-smol-${{ matrix.platform }}-${{ matrix.arch }}
packages/node-smol-builder/dist/socket-smol-${{ matrix.platform }}-${{ matrix.arch }}.exe
retention-days: 7
if-no-files-found: warn
summary:
name: 📊 Smol Node Build Summary
needs: [build-smol]
if: always()
runs-on: ubuntu-latest
steps:
- name: Generate summary
run: |
echo "# 🤏 Smol Node Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## ✅ Build Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Smol (compressed Node.js + CLI) binaries built successfully and cached." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📦 Build Method" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Method | Description | Size |" >> $GITHUB_STEP_SUMMARY
echo "|--------|-------------|------|" >> $GITHUB_STEP_SUMMARY
echo "| 🤏 smol | Compressed Node.js + CLI | ~18 MB |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🎯 Platforms Built" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- 🐧 Linux (x64, arm64)" >> $GITHUB_STEP_SUMMARY
echo "- 🍎 macOS (x64, arm64)" >> $GITHUB_STEP_SUMMARY
echo "- 🪟 Windows (x64, arm64)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🎯 Next Steps" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- These binaries are now cached for E2E tests" >> $GITHUB_STEP_SUMMARY
echo "- Use \`publish-socketbin.yml\` to publish to npm" >> $GITHUB_STEP_SUMMARY
echo "- Cache is invalidated when patches or build scripts change" >> $GITHUB_STEP_SUMMARY