name: Build OpenCode CLI on: push: branches: - main - master paths: - opencode/** workflow_dispatch: permissions: contents: read actions: read jobs: build-cli: name: Build OpenCode CLI (x86_64) runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version-file: opencode/package.json - name: Install dependencies run: bun install working-directory: opencode - name: Build CLI run: bun run ./packages/opencode/script/build.ts --single working-directory: opencode - name: Upload CLI artifact uses: actions/upload-artifact@v4 with: name: opencode-cli-x86_64 path: opencode/packages/opencode/dist/opencode-linux-x64 retention-days: 1 - name: Cleanup old CLI artifacts uses: actions/github-script@v7 with: script: | const artifactName = 'opencode-cli-x86_64'; const { data: artifacts } = await github.rest.actions.listArtifactsForRepo({ owner: context.repo.owner, repo: context.repo.repo, name: artifactName, per_page: 10 }); if (artifacts.length > 1) { const artifactsToDelete = artifacts.slice(1); for (const artifact of artifactsToDelete) { await github.rest.actions.deleteArtifact({ owner: context.repo.owner, repo: context.repo.repo, artifact_id: artifact.id }); console.log(`Deleted old artifact: ${artifact.id}`); } }