feat(cli): add npm publishing support for Bun CLI #1
Workflow file for this run
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
| name: Release CLI | |
| on: | |
| push: | |
| tags: | |
| - 'cli-v*' | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: 'Dry run (skip npm publish)' | |
| required: false | |
| default: 'false' | |
| type: boolean | |
| env: | |
| DEBUG: napi:* | |
| MACOSX_DEPLOYMENT_TARGET: '10.13' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: macos-latest | |
| target: x86_64-apple-darwin | |
| build: bun run build | |
| - host: macos-latest | |
| target: aarch64-apple-darwin | |
| build: bun run build --target aarch64-apple-darwin | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| build: bun run build --target x86_64-unknown-linux-gnu | |
| - host: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| build: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| bun run build --target aarch64-unknown-linux-gnu | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| build: bun run build --target x86_64-unknown-linux-musl | |
| - host: ubuntu-latest | |
| target: aarch64-unknown-linux-musl | |
| build: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| bun run build --target aarch64-unknown-linux-musl | |
| - host: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| build: bun run build | |
| - host: windows-latest | |
| target: aarch64-pc-windows-msvc | |
| build: bun run build --target aarch64-pc-windows-msvc | |
| name: Build - ${{ matrix.settings.target }} | |
| runs-on: ${{ matrix.settings.host }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.settings.target }} | |
| - name: Install dependencies | |
| run: bun install | |
| working-directory: packages/core | |
| - name: Build native module | |
| run: ${{ matrix.settings.build }} | |
| working-directory: packages/core | |
| shell: bash | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: packages/core/*.node | |
| if-no-files-found: error | |
| build-universal-macos: | |
| name: Build - universal-apple-darwin | |
| needs: build | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| working-directory: packages/core | |
| - name: Download x64 artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: bindings-x86_64-apple-darwin | |
| path: packages/core | |
| - name: Download arm64 artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: bindings-aarch64-apple-darwin | |
| path: packages/core | |
| - name: Create universal binary | |
| run: | | |
| bun x @napi-rs/cli universal | |
| working-directory: packages/core | |
| - name: Upload universal artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bindings-universal-apple-darwin | |
| path: packages/core/*.node | |
| if-no-files-found: error | |
| publish: | |
| name: Publish to npm | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build | |
| - build-universal-macos | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Setup Node.js (for npm publish) | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: packages/core/artifacts | |
| - name: Move artifacts | |
| run: bun x @napi-rs/cli artifacts | |
| working-directory: packages/core | |
| - name: List packages | |
| run: ls -la npm/ | |
| working-directory: packages/core | |
| - name: Publish @vibetracking/core | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| run: | | |
| bun x @napi-rs/cli prepublish -t npm | |
| npm publish --access public --provenance | |
| working-directory: packages/core | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish platform packages | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| run: | | |
| for dir in npm/*/; do | |
| if [ -d "$dir" ]; then | |
| echo "Publishing $dir" | |
| cd "$dir" | |
| npm publish --access public --provenance | |
| cd ../.. | |
| fi | |
| done | |
| working-directory: packages/core | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Build CLI | |
| run: bun run build | |
| working-directory: packages/cli | |
| - name: Publish vibetracking CLI | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| run: npm publish --access public --provenance | |
| working-directory: packages/cli | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Dry run summary | |
| if: ${{ github.event.inputs.dry_run == 'true' }} | |
| run: | | |
| echo "## Dry Run Complete" >> $GITHUB_STEP_SUMMARY | |
| echo "Would have published:" >> $GITHUB_STEP_SUMMARY | |
| echo "- @vibetracking/core@0.1.0" >> $GITHUB_STEP_SUMMARY | |
| echo "- vibetracking@0.1.0" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Platform packages:" >> $GITHUB_STEP_SUMMARY | |
| ls -la packages/core/npm/ >> $GITHUB_STEP_SUMMARY |