Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions .github/workflows/napi-build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: NAPI Build

# Builds @vibecook/spaghetti-sdk-native for all 5 targets, require()-loads
# every resulting .node binary on a matching host, and publishes the single
# fat main package (bundling all 5 binaries) to npm with provenance.
# Builds @vibecook/spaghetti-sdk-native for all 6 targets, require()-loads
# every resulting .node binary on a matching host, and (when dispatched with
# `publish=true`) publishes the single fat main package to npm with provenance.
#
# Triggered by release.yml on release_created, or manually via
# workflow_dispatch (useful for debugging).
# release.yml passes that input; a bare manual dispatch builds and tests only.

env:
DEBUG: napi:*
Expand All @@ -17,6 +16,11 @@ permissions:

on:
workflow_dispatch:
inputs:
publish:
description: 'Publish @vibecook/spaghetti-sdk-native to npm after the binaries pass their load checks'
type: boolean
default: false

jobs:
build:
Expand Down Expand Up @@ -134,7 +138,7 @@ jobs:
runs-on: ${{ matrix.settings.host }}
strategy:
fail-fast: false
# Every published binary must be require()-loaded before publish. All 5
# Every published binary must be require()-loaded before publish. All 6
# build targets have a matching test host. darwin-x64 runs on the Apple
# Silicon runner under Rosetta 2 (setup-node architecture: x64 makes the
# whole job x64) — GitHub's Intel macos-13 runners are retired/starved
Expand Down Expand Up @@ -188,9 +192,14 @@ jobs:
cd crates/spaghetti-napi
node -e "const m = require('./index.js'); if (!m.nativeVersion) { throw new Error('nativeVersion export missing'); } console.log('Loaded OK, nativeVersion =', m.nativeVersion());"

# Gated on an explicit input. The header calls workflow_dispatch "useful for
# debugging", but until this gate existed every dispatch ran the matrix and
# then attempted an npm publish — so there was no way to exercise a build
# without reaching for the registry. release.yml passes `-f publish=true`.
publish:
name: Publish to npm
needs: [test]
if: ${{ inputs.publish }}
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -223,7 +232,7 @@ jobs:
cd crates/spaghetti-napi
npx napi artifacts

# We publish ONLY the main package, which fat-bundles all 5 .node binaries
# We publish ONLY the main package, which fat-bundles all 6 .node binaries
# (see its `files: ["*.node"]`). The per-platform packages under
# crates/spaghetti-napi/npm/* are deliberately NOT published: nothing
# references them. The proper slim layout would have the main package
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
gh workflow run napi-build.yml --repo "${{ github.repository }}" --ref "${{ steps.release.outputs.tag_name }}"
# `-f publish=true` is REQUIRED. napi-build.yml's publish job is
# gated on that input (default false) so the workflow can be
# dispatched by hand to exercise a build without touching the
# registry. Drop the flag and the native package never reaches npm;
# the release then fails at the "Require ... on npm" gate below
# rather than shipping an SDK whose native dependency is missing.
gh workflow run napi-build.yml --repo "${{ github.repository }}" --ref "${{ steps.release.outputs.tag_name }}" -f publish=true
RUN_ID=""
for i in $(seq 1 12); do
# `|| true` so a transient gh failure just retries the loop (and, if
Expand Down
Loading