spawn/.github/workflows/cli-release.yml
L 61bcedc0eb
feat: migrate to openrouter.ai/labs/spawn CDN + release artifact version checks (#2178)
* feat: migrate shell script URLs to openrouter.ai/labs/spawn CDN

Users on older CLI versions can't auto-update because the repo was restructured
(cli/ → packages/cli/), so old version-check URLs 404. This decouples the CLI
from the repo's internal directory structure:

- Shell script URLs (install, agent scripts, github-auth) now use
  openrouter.ai/labs/spawn/* as primary with GitHub raw as fallback
- Version checks now use GitHub release artifact (cli-latest/version)
  as primary — a static URL that never changes regardless of repo layout
- CI workflow updated to publish a `version` file alongside cli.js
- Remove GITHUB_RAW_URL_PATTERN validation (no longer needed since
  install URL is now a hardcoded CDN string, not interpolated)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: fix biome formatting in update-check test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: CLAUDE.md says biome lint but should say biome check

biome lint only checks lint rules, not formatting. biome check does both.
The hooks and CI already run biome check — the docs were out of sync.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(hooks): PostToolUse hook wasn't running biome on CLI source files

Two bugs in validate-file.ts:

1. Config search only checked 1-2 levels up from the edited file, but
   biome.json is at packages/cli/ — 3 levels above src/__tests__/*.ts.
   Fix: walk up directories until biome.json is found (or hit root).

2. Ran `biome format` (prints formatted output, always exits 0) instead
   of `biome format --check` (exits non-zero if file needs formatting).
   Fix: use `biome check` which does lint + format check in one pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-03 23:34:58 -08:00

93 lines
2.9 KiB
YAML

name: CLI Release
on:
push:
branches: [main]
paths:
- 'packages/cli/src/**'
- 'packages/cli/package.json'
- 'packages/cli/bun.lock'
workflow_dispatch:
concurrency:
group: cli-release
cancel-in-progress: true
jobs:
build:
name: Build and release CLI
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies and build
working-directory: packages/cli
run: |
bun install
bun run build
- name: Build cloud bundles
run: bun run packages/cli/build-clouds.ts
- name: Get version
id: version
working-directory: packages/cli
run: echo "version=$(jq -r .version package.json)" >> "$GITHUB_OUTPUT"
- name: Create version file
working-directory: packages/cli
run: jq -r .version package.json > version
- name: Update cli-latest release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Delete existing release if present
gh release delete cli-latest --yes 2>/dev/null || true
git tag -d cli-latest 2>/dev/null || true
git push origin :refs/tags/cli-latest 2>/dev/null || true
# Create new release with built cli.js and version file
gh release create cli-latest \
--title "CLI v${{ steps.version.outputs.version }}" \
--notes "Pre-built CLI binary (auto-updated on every push to main).
This release is used as a fallback by \`install.sh\` when the local build fails (e.g. Termux proot).
The \`version\` file is used by the CLI's auto-update check.
**Version:** ${{ steps.version.outputs.version }}
**Built:** $(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--prerelease \
packages/cli/cli.js \
packages/cli/version
- name: Upload cloud bundles
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Upload each cloud bundle as a separate release (aws-latest/aws.js, etc.)
for bundle in packages/cli/*.js; do
name=$(basename "$bundle" .js)
[[ "$name" == "cli" ]] && continue # skip cli.js, already uploaded above
gh release delete "${name}-latest" --yes 2>/dev/null || true
git tag -d "${name}-latest" 2>/dev/null || true
git push origin ":refs/tags/${name}-latest" 2>/dev/null || true
gh release create "${name}-latest" \
--title "${name} bundle v${{ steps.version.outputs.version }}" \
--notes "Pre-built ${name} cloud provider bundle.
Downloaded by \`sh/${name}/*.sh\` shims for \`bash <(curl ...)\` execution.
**Built:** $(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--prerelease \
"$bundle"
done