This document explains how to publish the brin package to npm.
- npm account: You need an npm account with publishing rights for the
brinpackage - npm authentication: Run
npm loginto authenticate - Release binaries: Ensure GitHub releases exist for the version you're publishing
Before publishing, check what will be included in the package:
npm pack --dry-runThis should show:
bin/brin.js- CLI wrapper scriptscripts/postinstall.js- Installation scriptindex.js- Main entry pointpackage.json- Package metadataREADME.md- DocumentationLICENSE- License file
You can test the package locally before publishing:
# Create a tarball
npm pack
# Install it globally from the tarball
npm install -g ./brin-0.1.8.tgz
# Test the installation
brin --version- Update the version in
package.jsonandCargo.toml(workspace.package.version) - Ensure GitHub releases are created with binaries for:
brin-linux-x86_64.tar.gzbrin-linux-aarch64.tar.gzbrin-darwin-x86_64.tar.gzbrin-darwin-aarch64.tar.gz
- Publish to npm:
npm publishAfter publishing, verify the package:
# Check on npm
npm view brin
# Test installation
npm install -g brin
brin --versionThe package version should match the Rust crate version defined in /workspace/Cargo.toml:
[workspace.package]
version = "0.1.8"When bumping versions:
- Update
Cargo.toml(workspace.package.version) - Update
package.json(version) - Create and push a git tag:
git tag v0.1.8 && git push origin v0.1.8 - Create GitHub release with binaries
- Publish to npm
The postinstall script downloads pre-built binaries from GitHub releases. The binary naming convention is:
brin-{os}-{arch}.tar.gz
Where:
os:linuxordarwinarch:x86_64oraarch64
The postinstall script will:
- Detect the user's platform and architecture
- Download the appropriate binary from GitHub releases
- Extract it to
node_modules/brin/bin/ - Make it executable
If users get a "binary not found" error, it means:
- The GitHub release doesn't exist for that version
- The binary for their platform wasn't included in the release
- The download failed during installation
Users can check the postinstall output for more details.
Currently supported platforms:
- Linux (x64, arm64)
- macOS (x64, arm64)
Windows is not currently supported. Windows users should use WSL or install from source.
Consider adding npm publishing to the GitHub Actions release workflow:
- name: Publish to npm
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}This will automatically publish to npm when a new version tag is pushed.