|
| 1 | +name: Release CLI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'cli-v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + dry_run: |
| 10 | + description: 'Dry run (skip npm publish)' |
| 11 | + required: false |
| 12 | + default: 'false' |
| 13 | + type: boolean |
| 14 | + |
| 15 | +env: |
| 16 | + DEBUG: napi:* |
| 17 | + MACOSX_DEPLOYMENT_TARGET: '10.13' |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + id-token: write |
| 22 | + |
| 23 | +jobs: |
| 24 | + build: |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + settings: |
| 29 | + - host: macos-latest |
| 30 | + target: x86_64-apple-darwin |
| 31 | + build: bun run build |
| 32 | + - host: macos-latest |
| 33 | + target: aarch64-apple-darwin |
| 34 | + build: bun run build --target aarch64-apple-darwin |
| 35 | + - host: ubuntu-latest |
| 36 | + target: x86_64-unknown-linux-gnu |
| 37 | + build: bun run build --target x86_64-unknown-linux-gnu |
| 38 | + - host: ubuntu-latest |
| 39 | + target: aarch64-unknown-linux-gnu |
| 40 | + build: | |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 43 | + bun run build --target aarch64-unknown-linux-gnu |
| 44 | + - host: ubuntu-latest |
| 45 | + target: x86_64-unknown-linux-musl |
| 46 | + build: bun run build --target x86_64-unknown-linux-musl |
| 47 | + - host: ubuntu-latest |
| 48 | + target: aarch64-unknown-linux-musl |
| 49 | + build: | |
| 50 | + sudo apt-get update |
| 51 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 52 | + bun run build --target aarch64-unknown-linux-musl |
| 53 | + - host: windows-latest |
| 54 | + target: x86_64-pc-windows-msvc |
| 55 | + build: bun run build |
| 56 | + - host: windows-latest |
| 57 | + target: aarch64-pc-windows-msvc |
| 58 | + build: bun run build --target aarch64-pc-windows-msvc |
| 59 | + |
| 60 | + name: Build - ${{ matrix.settings.target }} |
| 61 | + runs-on: ${{ matrix.settings.host }} |
| 62 | + |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Setup Bun |
| 67 | + uses: oven-sh/setup-bun@v2 |
| 68 | + with: |
| 69 | + bun-version: latest |
| 70 | + |
| 71 | + - name: Setup Rust |
| 72 | + uses: dtolnay/rust-toolchain@stable |
| 73 | + with: |
| 74 | + targets: ${{ matrix.settings.target }} |
| 75 | + |
| 76 | + - name: Install dependencies |
| 77 | + run: bun install |
| 78 | + working-directory: packages/core |
| 79 | + |
| 80 | + - name: Build native module |
| 81 | + run: ${{ matrix.settings.build }} |
| 82 | + working-directory: packages/core |
| 83 | + shell: bash |
| 84 | + |
| 85 | + - name: Upload artifact |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: bindings-${{ matrix.settings.target }} |
| 89 | + path: packages/core/*.node |
| 90 | + if-no-files-found: error |
| 91 | + |
| 92 | + build-universal-macos: |
| 93 | + name: Build - universal-apple-darwin |
| 94 | + needs: build |
| 95 | + runs-on: macos-latest |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v4 |
| 98 | + |
| 99 | + - name: Setup Bun |
| 100 | + uses: oven-sh/setup-bun@v2 |
| 101 | + with: |
| 102 | + bun-version: latest |
| 103 | + |
| 104 | + - name: Install dependencies |
| 105 | + run: bun install |
| 106 | + working-directory: packages/core |
| 107 | + |
| 108 | + - name: Download x64 artifact |
| 109 | + uses: actions/download-artifact@v4 |
| 110 | + with: |
| 111 | + name: bindings-x86_64-apple-darwin |
| 112 | + path: packages/core |
| 113 | + |
| 114 | + - name: Download arm64 artifact |
| 115 | + uses: actions/download-artifact@v4 |
| 116 | + with: |
| 117 | + name: bindings-aarch64-apple-darwin |
| 118 | + path: packages/core |
| 119 | + |
| 120 | + - name: Create universal binary |
| 121 | + run: | |
| 122 | + bun x @napi-rs/cli universal |
| 123 | + working-directory: packages/core |
| 124 | + |
| 125 | + - name: Upload universal artifact |
| 126 | + uses: actions/upload-artifact@v4 |
| 127 | + with: |
| 128 | + name: bindings-universal-apple-darwin |
| 129 | + path: packages/core/*.node |
| 130 | + if-no-files-found: error |
| 131 | + |
| 132 | + publish: |
| 133 | + name: Publish to npm |
| 134 | + runs-on: ubuntu-latest |
| 135 | + needs: |
| 136 | + - build |
| 137 | + - build-universal-macos |
| 138 | + |
| 139 | + steps: |
| 140 | + - uses: actions/checkout@v4 |
| 141 | + |
| 142 | + - name: Setup Bun |
| 143 | + uses: oven-sh/setup-bun@v2 |
| 144 | + with: |
| 145 | + bun-version: latest |
| 146 | + |
| 147 | + - name: Setup Node.js (for npm publish) |
| 148 | + uses: actions/setup-node@v4 |
| 149 | + with: |
| 150 | + node-version: '20' |
| 151 | + registry-url: 'https://registry.npmjs.org' |
| 152 | + |
| 153 | + - name: Install dependencies |
| 154 | + run: bun install |
| 155 | + |
| 156 | + - name: Download all artifacts |
| 157 | + uses: actions/download-artifact@v4 |
| 158 | + with: |
| 159 | + path: packages/core/artifacts |
| 160 | + |
| 161 | + - name: Move artifacts |
| 162 | + run: bun x @napi-rs/cli artifacts |
| 163 | + working-directory: packages/core |
| 164 | + |
| 165 | + - name: List packages |
| 166 | + run: ls -la npm/ |
| 167 | + working-directory: packages/core |
| 168 | + |
| 169 | + - name: Publish @vibetracking/core |
| 170 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
| 171 | + run: | |
| 172 | + bun x @napi-rs/cli prepublish -t npm |
| 173 | + npm publish --access public --provenance |
| 174 | + working-directory: packages/core |
| 175 | + env: |
| 176 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 177 | + |
| 178 | + - name: Publish platform packages |
| 179 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
| 180 | + run: | |
| 181 | + for dir in npm/*/; do |
| 182 | + if [ -d "$dir" ]; then |
| 183 | + echo "Publishing $dir" |
| 184 | + cd "$dir" |
| 185 | + npm publish --access public --provenance |
| 186 | + cd ../.. |
| 187 | + fi |
| 188 | + done |
| 189 | + working-directory: packages/core |
| 190 | + env: |
| 191 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 192 | + |
| 193 | + - name: Build CLI |
| 194 | + run: bun run build |
| 195 | + working-directory: packages/cli |
| 196 | + |
| 197 | + - name: Publish vibetracking CLI |
| 198 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
| 199 | + run: npm publish --access public --provenance |
| 200 | + working-directory: packages/cli |
| 201 | + env: |
| 202 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 203 | + |
| 204 | + - name: Dry run summary |
| 205 | + if: ${{ github.event.inputs.dry_run == 'true' }} |
| 206 | + run: | |
| 207 | + echo "## Dry Run Complete" >> $GITHUB_STEP_SUMMARY |
| 208 | + echo "Would have published:" >> $GITHUB_STEP_SUMMARY |
| 209 | + echo "- @vibetracking/core@0.1.0" >> $GITHUB_STEP_SUMMARY |
| 210 | + echo "- vibetracking@0.1.0" >> $GITHUB_STEP_SUMMARY |
| 211 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 212 | + echo "Platform packages:" >> $GITHUB_STEP_SUMMARY |
| 213 | + ls -la packages/core/npm/ >> $GITHUB_STEP_SUMMARY |
0 commit comments