fix(cli): ship a self-contained CJS bin so commander resolves #18
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: | |
| push: | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| outputs: | |
| version: ${{ steps.meta.outputs.version }} | |
| tag: ${{ steps.meta.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org/ | |
| - run: bun install --frozen-lockfile | |
| - run: bun run test | |
| - name: Get version metadata | |
| id: meta | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Verify pushed tag matches package.json version | |
| if: github.event_name == 'push' | |
| run: | | |
| if [ "${{ github.ref_name }}" != "${{ steps.meta.outputs.tag }}" ]; then | |
| echo "::error::Pushed tag ${{ github.ref_name }} does not match package.json version (${{ steps.meta.outputs.tag }}). Run 'changeset version' and retag." | |
| exit 1 | |
| fi | |
| # Use the package.json `release` script so Changesets consumes any | |
| # pending entries in .changeset/ and updates CHANGELOG.md. This keeps | |
| # the tag-push flow consistent with `bun run release` locally. | |
| - name: Publish to npm via Changesets | |
| run: bun run release | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # Build standalone binaries after npm publish | |
| binaries: | |
| needs: publish | |
| strategy: | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| target: darwin-arm64 | |
| binary_name: cmdk-engine-darwin-arm64 | |
| - os: macos-13 | |
| target: darwin-x64 | |
| binary_name: cmdk-engine-darwin-x64 | |
| - os: ubuntu-latest | |
| target: linux-x64 | |
| binary_name: cmdk-engine-linux-x64 | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - run: bun install --frozen-lockfile | |
| - run: bun run build | |
| - name: Compile standalone binary | |
| run: bun build dist/cli/index.js --compile --outfile dist/${{ matrix.binary_name }} | |
| - name: Generate checksum | |
| run: shasum -a 256 dist/${{ matrix.binary_name }} > dist/${{ matrix.binary_name }}.sha256 | |
| - name: Upload binary to release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="${{ needs.publish.outputs.tag }}" | |
| # Create release if it doesn't exist | |
| gh release create "${TAG}" --title "${TAG}" --generate-notes 2>/dev/null || true | |
| # Upload binary and checksum | |
| gh release upload "${TAG}" \ | |
| "dist/${{ matrix.binary_name }}" \ | |
| "dist/${{ matrix.binary_name }}.sha256" \ | |
| --clobber | |
| # Update Homebrew tap formula after binaries are uploaded | |
| update-homebrew: | |
| needs: [publish, binaries] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Get version and checksums | |
| id: meta | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="${{ needs.publish.outputs.tag }}" | |
| VERSION="${{ needs.publish.outputs.version }}" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | |
| # Download checksums | |
| gh release download "${TAG}" -p "*.sha256" -D /tmp/checksums | |
| DARWIN_ARM64=$(cat /tmp/checksums/cmdk-engine-darwin-arm64.sha256 | awk '{print $1}') | |
| DARWIN_X64=$(cat /tmp/checksums/cmdk-engine-darwin-x64.sha256 | awk '{print $1}') | |
| LINUX_X64=$(cat /tmp/checksums/cmdk-engine-linux-x64.sha256 | awk '{print $1}') | |
| echo "darwin_arm64_sha=${DARWIN_ARM64}" >> "$GITHUB_OUTPUT" | |
| echo "darwin_x64_sha=${DARWIN_X64}" >> "$GITHUB_OUTPUT" | |
| echo "linux_x64_sha=${LINUX_X64}" >> "$GITHUB_OUTPUT" | |
| - name: Update Homebrew tap | |
| env: | |
| GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| run: | | |
| # Clone the tap repo | |
| git clone "https://x-access-token:${GH_TOKEN}@github.com/Priyans-hu/homebrew-tap.git" /tmp/tap | |
| cd /tmp/tap | |
| mkdir -p Formula | |
| cat > Formula/cmdk-engine.rb << 'FORMULA_EOF' | |
| class CmdkEngine < Formula | |
| desc "Smart command palette engine — route scanner and config generator" | |
| homepage "https://github.com/Priyans-hu/cmdk-engine" | |
| version "${{ steps.meta.outputs.version }}" | |
| license "MIT" | |
| on_macos do | |
| if Hardware::CPU.arm? | |
| url "https://github.com/Priyans-hu/cmdk-engine/releases/download/${{ steps.meta.outputs.tag }}/cmdk-engine-darwin-arm64" | |
| sha256 "${{ steps.meta.outputs.darwin_arm64_sha }}" | |
| else | |
| url "https://github.com/Priyans-hu/cmdk-engine/releases/download/${{ steps.meta.outputs.tag }}/cmdk-engine-darwin-x64" | |
| sha256 "${{ steps.meta.outputs.darwin_x64_sha }}" | |
| end | |
| end | |
| on_linux do | |
| url "https://github.com/Priyans-hu/cmdk-engine/releases/download/${{ steps.meta.outputs.tag }}/cmdk-engine-linux-x64" | |
| sha256 "${{ steps.meta.outputs.linux_x64_sha }}" | |
| end | |
| def install | |
| binary = Dir["cmdk-engine-*"].first | |
| bin.install binary => "cmdk-engine" | |
| end | |
| test do | |
| assert_match "cmdk-engine", shell_output("#{bin}/cmdk-engine --help") | |
| end | |
| end | |
| FORMULA_EOF | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Formula/cmdk-engine.rb | |
| git commit -m "Update cmdk-engine to ${{ steps.meta.outputs.version }}" || true | |
| git push || true |