Build CLI Binaries #7
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 | |
| skip_build: | |
| description: 'Skip build (reuse artifacts from previous run)' | |
| required: false | |
| default: false | |
| type: boolean | |
| run_id: | |
| description: 'Run ID to download artifacts from (required if skip_build is true)' | |
| required: false | |
| type: string | |
| env: | |
| DEBUG: napi:* | |
| MACOSX_DEPLOYMENT_TARGET: '10.13' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| actions: read | |
| jobs: | |
| build: | |
| if: ${{ github.event.inputs.skip_build != 'true' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: macos-latest | |
| target: x86_64-apple-darwin | |
| build: bun run build --target x86_64-apple-darwin | |
| - 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 g++-aarch64-linux-gnu | |
| export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc | |
| export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ | |
| export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc | |
| bun run build --target aarch64-unknown-linux-gnu | |
| - host: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| build: bun run build --target x86_64-pc-windows-msvc | |
| - 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: | |
| if: ${{ github.event.inputs.skip_build != 'true' }} | |
| 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 universalize | |
| 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 | |
| if: ${{ always() && (github.event.inputs.skip_build == 'true' || (needs.build.result == 'success' && needs.build-universal-macos.result == 'success')) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Download artifacts from current run | |
| if: ${{ github.event.inputs.skip_build != 'true' }} | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: packages/core/artifacts | |
| - name: Download artifacts from previous run | |
| if: ${{ github.event.inputs.skip_build == 'true' }} | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: packages/core/artifacts | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ github.event.inputs.run_id }} | |
| - name: Move artifacts | |
| run: bun x @napi-rs/cli artifacts | |
| working-directory: packages/core | |
| - name: List packages | |
| run: ls -la npm/ || echo "No npm directory" | |
| working-directory: packages/core | |
| - 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) | |
| fi | |
| done | |
| working-directory: packages/core | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish @vibetracking/core | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| run: npm publish --access public --provenance | |
| 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: Summary | |
| run: | | |
| echo "## Published Packages" >> $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 "### Install" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY | |
| echo "bunx vibetracking" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |