btch-cli@3.0.10 #21
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 | |
| on: | |
| # Create a release in the GitHub UI (New release → choose/publish a tag) and | |
| # this workflow builds the binaries and attaches them to that release. | |
| # Draft the release first, fill in the notes, then hit “Publish release”. | |
| release: | |
| types: [published] | |
| # Manual fallback: run the workflow from the Actions tab with a version. | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Release tag to publish (for example btch-cli@3.0.8)" | |
| required: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Modern CPUs (AVX2). install.sh picks this when the CPU supports it. | |
| - runner: ubuntu-latest | |
| build_output: btch | |
| asset_name: btch-linux-x64 | |
| compile_target: bun-linux-x64 | |
| # Baseline target for older CPUs (pre-AVX2) such as Sandy Bridge VMs | |
| # that would otherwise crash with SIGILL. install.sh picks this when | |
| # the CPU lacks AVX2. | |
| - runner: ubuntu-latest | |
| build_output: btch-baseline | |
| asset_name: btch-linux-x64-baseline | |
| compile_target: bun-linux-x64-baseline | |
| - runner: macos-latest | |
| build_output: btch | |
| asset_name: btch-darwin-arm64 | |
| compile_target: bun-darwin-arm64 | |
| # ARM64 Linux (Raspberry Pi, ARM servers, Android/Termux with Bun). | |
| # Cross-compiled from the x64 ubuntu runner via Bun's --target. | |
| - runner: ubuntu-latest | |
| build_output: btch-arm64 | |
| asset_name: btch-linux-arm64 | |
| compile_target: bun-linux-arm64 | |
| # Native Android (Termux) — Bun 1.3.14+ compiles a bionic-linked | |
| # binary (interpreter /system/bin/linker64) that actually runs on | |
| # Termux, unlike the glibc linux-arm64 build. libopentui.so is | |
| # statically linked so the TUI works too. | |
| - runner: ubuntu-latest | |
| build_output: btch-android | |
| asset_name: btch-android-arm64 | |
| compile_target: bun-android-arm64 | |
| - runner: windows-latest | |
| build_output: btch.exe | |
| asset_name: btch-windows-x64.exe | |
| compile_target: bun-windows-x64 | |
| runs-on: ${{ matrix.runner }} | |
| permissions: | |
| contents: read | |
| id-token: write | |
| attestations: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set package version from release tag | |
| shell: bash | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| tag="${{ github.event.inputs.version }}" | |
| else | |
| tag="${{ github.event.release.tag_name }}" | |
| fi | |
| version="${tag#btch-cli@}" | |
| node -e "const fs=require('fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));p.version=process.argv[1];fs.writeFileSync('package.json',JSON.stringify(p,null,2)+'\n')" "$version" | |
| echo "package.json version set to ${version}" | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.14 | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| # bun install only installs the OpenTUI platform package matching the | |
| # *build host* (x64), so cross-compiling the arm64/android binaries needs | |
| # the arm64 native package present too (Bun bundles it at build time). | |
| # The shared script downloads the tarball directly, bypassing npm's | |
| # os/cpu check without touching package.json/lockfiles. | |
| - name: Install ARM64 OpenTUI native package (cross-compile) | |
| if: contains(matrix.asset_name, 'arm64') | |
| run: node scripts/install-opentui-platform.mjs @opentui/core-linux-arm64 | |
| # OpenTUI has no android package; for the android target Bun resolves | |
| # @opentui/core-android-arm64 at build time. libopentui.so is statically | |
| # linked, so the linux-arm64 package works verbatim as the android shim. | |
| - name: Shim Android OpenTUI package | |
| if: matrix.asset_name == 'btch-android-arm64' | |
| run: | | |
| mkdir -p node_modules/@opentui/core-android-arm64 | |
| cp -r node_modules/@opentui/core-linux-arm64/. node_modules/@opentui/core-android-arm64/ | |
| - name: Compile standalone binary | |
| run: bun build --compile --target="${{ matrix.compile_target }}" --outfile "release/${{ matrix.build_output }}" ./src/index.ts | |
| - name: Compute checksum (unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| working-directory: release | |
| run: | | |
| cp "${{ matrix.build_output }}" "${{ matrix.asset_name }}" | |
| shasum -a 256 "${{ matrix.asset_name }}" > "${{ matrix.asset_name }}.sha256" | |
| - name: Compute checksum (windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| working-directory: release | |
| run: | | |
| Copy-Item "${{ matrix.build_output }}" "${{ matrix.asset_name }}" | |
| $hash = (Get-FileHash "${{ matrix.asset_name }}" -Algorithm SHA256).Hash.ToLower() | |
| "$hash ${{ matrix.asset_name }}" | Out-File -Encoding ascii "${{ matrix.asset_name }}.sha256" | |
| - name: Attest build provenance | |
| uses: actions/attest-build-provenance@v2 | |
| with: | |
| subject-path: | | |
| release/${{ matrix.asset_name }} | |
| - name: Upload release artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.asset_name }} | |
| path: | | |
| release/${{ matrix.asset_name }} | |
| release/${{ matrix.asset_name }}.sha256 | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Resolve release tag | |
| shell: bash | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| tag="${{ github.event.inputs.version }}" | |
| else | |
| tag="${{ github.event.release.tag_name }}" | |
| fi | |
| echo "RELEASE_TAG=${tag}" >> "$GITHUB_ENV" | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: release-assets | |
| - name: Merge checksums | |
| shell: bash | |
| run: | | |
| cat release-assets/**/*.sha256 | sort > release-assets/checksums.txt | |
| - name: Publish GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| # When triggered by the `release` event the release already exists, so | |
| # just attach the binaries. Manual dispatch creates it with notes. | |
| tag_name: ${{ env.RELEASE_TAG }} | |
| generate_release_notes: ${{ github.event_name != 'release' }} | |
| prerelease: ${{ contains(env.RELEASE_TAG, '-rc') || contains(env.RELEASE_TAG, '-alpha') || contains(env.RELEASE_TAG, '-beta') || contains(env.RELEASE_TAG, '-pre') }} | |
| files: | | |
| release-assets/**/btch-linux-x64 | |
| release-assets/**/btch-linux-x64-baseline | |
| release-assets/**/btch-linux-arm64 | |
| release-assets/**/btch-android-arm64 | |
| release-assets/**/btch-darwin-arm64 | |
| release-assets/**/btch-windows-x64.exe | |
| release-assets/checksums.txt | |
| # Publish the package to npm on every GitHub release. Requires the | |
| # NPM_TOKEN secret (Settings → Secrets and variables → Actions) with | |
| # publish permissions. The version is taken from the release tag, so | |
| # just create a release like btch-cli@3.0.8 and the package is | |
| # published as 1.0.4 automatically. | |
| npm-publish: | |
| if: github.event_name == 'release' | |
| runs-on: ubuntu-latest | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set package version from release tag | |
| shell: bash | |
| run: | | |
| tag="${{ github.event.release.tag_name }}" | |
| version="${tag#btch-cli@}" | |
| node -e "const fs=require('fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));p.version=process.argv[1];fs.writeFileSync('package.json',JSON.stringify(p,null,2)+'\n')" "$version" | |
| echo "package.json version set to ${version}" | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.14 | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build | |
| run: bun run build | |
| - name: Publish to npm | |
| if: env.NPM_TOKEN != '' | |
| run: npm publish --ignore-scripts --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |