mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 11:59:29 +00:00
The cli-release workflow was deleting releases before recreating them, leaving a window where users downloading cloud bundles (gcp.js, aws.js, etc.) would get a 404. This affected all clouds on every push to main. Switch to gh release upload --clobber which atomically replaces assets without removing the release, and only create releases if they don't already exist. Co-authored-by: lab <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
90 lines
2.8 KiB
YAML
90 lines
2.8 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: |
|
|
# Create release if it doesn't exist, then upload assets with --clobber
|
|
# to atomically replace files without a delete→create race window
|
|
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 2>/dev/null || true
|
|
|
|
gh release upload cli-latest \
|
|
packages/cli/cli.js \
|
|
packages/cli/version \
|
|
--clobber
|
|
|
|
- name: Upload cloud bundles
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
# Upload each cloud bundle, creating the release if needed.
|
|
# Uses --clobber to atomically replace assets (no delete→create race).
|
|
for bundle in packages/cli/*.js; do
|
|
name=$(basename "$bundle" .js)
|
|
[[ "$name" == "cli" ]] && continue # skip cli.js, already uploaded above
|
|
|
|
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 2>/dev/null || true
|
|
|
|
gh release upload "${name}-latest" "$bundle" --clobber
|
|
done
|