-
Notifications
You must be signed in to change notification settings - Fork 25
Distribute native binaries via npm using prebuildify (drop node-pre-gyp/S3) #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
761a4f4
Distribute native binaries via npm using prebuildify (drop node-pre-g…
mohamed-rdr 516f071
release: publish to npm via OIDC trusted publishing instead of a token
mohamed-rdr aa289bd
release: use npm staged publishing (maintainer 2FA approval before pu…
mohamed-rdr 88d2ba9
release: drop darwin-x64 (Intel macOS) prebuild
mohamed-rdr 8e741e0
release: pin runner images (ubuntu-22.04) for stable, low-glibc prebu…
mohamed-rdr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: release | ||
|
|
||
| # Publishes @radarlabs/s2 to npm with the native prebuilds bundled in the | ||
| # tarball. Trigger by publishing a GitHub Release whose tag matches the | ||
| # version already set in package.json (e.g. v0.0.7). | ||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| jobs: | ||
| # Build one N-API prebuild per platform/arch. N-API is ABI-stable across | ||
| # Node versions, so a single build per platform serves Node 20/22/24. | ||
| prebuild: | ||
| name: prebuild (${{ matrix.name }}) | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| include: | ||
| # Pin the runner images: stable, and building on the oldest supported | ||
| # Ubuntu keeps the prebuilt binaries' glibc floor low so they run on | ||
| # more consumer systems. | ||
| - { os: ubuntu-22.04, name: linux-x64 } | ||
| - { os: ubuntu-22.04-arm, name: linux-arm64 } | ||
| - { os: macos-14, name: darwin-arm64 } | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| - run: npm ci | ||
| - run: JOBS=max npm run build | ||
| - name: Smoke test the prebuild | ||
| run: npm test | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: prebuild-${{ matrix.name }} | ||
| path: prebuilds/ | ||
| if-no-files-found: error | ||
|
|
||
| stage-publish: | ||
| name: stage publish to npm | ||
| needs: prebuild | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write # mint the OIDC token for npm trusted publishing + provenance | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 # trusted publishing requires Node >= 22.14 | ||
| registry-url: "https://registry.npmjs.org" | ||
| - name: Upgrade npm (trusted publishing needs >= 11.5.1) | ||
| run: npm install -g npm@latest | ||
| - name: Download all prebuilds | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: prebuild-* | ||
| path: artifacts | ||
| - name: Assemble prebuilds/ | ||
| run: | | ||
| mkdir -p prebuilds | ||
| cp -R artifacts/*/. prebuilds/ | ||
| ls -R prebuilds | ||
| # Stages the release via OIDC (no token). The package does NOT go public | ||
| # here. One-time setup on npmjs.com: configure a Trusted Publisher for | ||
| # this package pointing at radarlabs/s2 + .github/workflows/release.yml | ||
| # with STAGE-ONLY permissions. Provenance is attached automatically. | ||
| - name: Stage publish | ||
| run: npm stage publish --access public | ||
| - name: How to approve | ||
| run: | | ||
| echo "Release staged — NOT yet public. A maintainer must approve with 2FA:" | ||
| echo " npm stage list" | ||
| echo " npm stage view @radarlabs/s2" | ||
| echo " npm stage approve @radarlabs/s2 # (or approve/reject on npmjs.com)" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ radarlabs-s2-0.0.1.tgz | |
| *.txt | ||
| lib | ||
| *.swp | ||
| prebuilds/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,3 @@ | ||
| // magic incantation from step 3 @ https://github.com/mapbox/node-pre-gyp#readme | ||
| const binary = require('@mapbox/node-pre-gyp'); | ||
| const path = require('path'); | ||
| var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); | ||
| const s2 = require(binding_path); | ||
| module.exports = s2; | ||
| // Loads the prebuilt N-API addon shipped in ./prebuilds (built by prebuildify), | ||
| // falling back to a local ./build compile for unsupported platforms. | ||
| module.exports = require('node-gyp-build')(__dirname); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might not need this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping this one: it's the Apple Silicon prebuild, and the tarball has no source fallback, so without it
npm installhard-fails on Macs. Production is linux-only, so it only affects local dev — leaving the thread open in case you'd rather drop macOS support entirely.🤖 Addressed by Claude Code