Skip to content

Commit 96f82c2

Browse files
ci: adopt GitHub flow with PR checks and semantic-release (#1)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 100d783 commit 96f82c2

15 files changed

Lines changed: 1258 additions & 252 deletions

.github/workflows/catalog-sync.yml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,28 @@ on:
1313
permissions:
1414
contents: write
1515
issues: write
16+
pull-requests: write
1617

1718
jobs:
1819
sync:
20+
name: catalog-pr
1921
runs-on: ubuntu-latest
2022
steps:
21-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v7
2224
with:
23-
token: ${{ secrets.CATALOG_PUSH_TOKEN || secrets.GITHUB_TOKEN }}
24-
25-
- uses: actions/setup-node@v4
26-
with:
27-
node-version: "22"
28-
registry-url: https://registry.npmjs.org
25+
token: ${{ secrets.RELEASE_SYNC_TOKEN || secrets.CATALOG_PUSH_TOKEN || secrets.GITHUB_TOKEN }}
2926

3027
- uses: oven-sh/setup-bun@v2
3128
with:
3229
bun-version: "1.3.14"
3330

3431
- name: Install dependencies
35-
run: bun install
36-
37-
- name: Unit tests
38-
run: bun test tests/unit/
32+
run: bun install --frozen-lockfile
3933

40-
- name: Sync catalog
34+
- name: Open catalog PR
4135
env:
4236
CI: "true"
4337
FORCE: ${{ inputs.force }}
44-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45-
# workit lesson: setup-node writes NODE_AUTH_TOKEN into .npmrc.
46-
# NPM_TOKEN alone is an empty placeholder there.
47-
NPM_TOKEN: ${{ secrets.NPMJS }}
48-
NODE_AUTH_TOKEN: ${{ secrets.NPMJS }}
38+
GH_TOKEN: ${{ secrets.RELEASE_SYNC_TOKEN || secrets.CATALOG_PUSH_TOKEN || secrets.GITHUB_TOKEN }}
39+
GITHUB_TOKEN: ${{ secrets.RELEASE_SYNC_TOKEN || secrets.CATALOG_PUSH_TOKEN || secrets.GITHUB_TOKEN }}
4940
run: bun run scripts/catalog-sync-ci.ts

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ci-${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
BUN_VERSION: "1.3.14"
18+
19+
jobs:
20+
test:
21+
name: check (test)
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v7
25+
- uses: oven-sh/setup-bun@v2
26+
with:
27+
bun-version: ${{ env.BUN_VERSION }}
28+
- name: Install dependencies
29+
run: bun install --frozen-lockfile
30+
- name: Unit tests
31+
run: bun test tests/unit/
32+
33+
typecheck:
34+
name: check (typecheck)
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v7
38+
- uses: oven-sh/setup-bun@v2
39+
with:
40+
bun-version: ${{ env.BUN_VERSION }}
41+
- name: Install dependencies
42+
run: bun install --frozen-lockfile
43+
- name: Typecheck
44+
run: bun run typecheck
45+
46+
pack:
47+
name: check (pack)
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v7
51+
- uses: actions/setup-node@v7
52+
with:
53+
node-version: "22"
54+
- uses: oven-sh/setup-bun@v2
55+
with:
56+
bun-version: ${{ env.BUN_VERSION }}
57+
- name: Install dependencies
58+
run: bun install --frozen-lockfile
59+
- name: Verify release candidate
60+
run: bun run verify:release-candidate

.github/workflows/release.yml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ on:
77
permissions:
88
contents: write
99
issues: write
10+
pull-requests: write
1011

1112
jobs:
1213
release:
14+
name: semantic-release
1315
runs-on: ubuntu-latest
1416
steps:
15-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v7
18+
with:
19+
fetch-depth: 0
20+
persist-credentials: false
1621

17-
- uses: actions/setup-node@v4
22+
- uses: actions/setup-node@v7
1823
with:
1924
node-version: "22"
2025
registry-url: https://registry.npmjs.org
@@ -24,16 +29,40 @@ jobs:
2429
bun-version: "1.3.14"
2530

2631
- name: Install dependencies
27-
run: bun install
32+
run: bun install --frozen-lockfile
2833

29-
- name: Unit tests
30-
run: bun test tests/unit/
34+
- name: Verify release candidate
35+
run: bun run verify:release-candidate
3136

32-
- name: Publish if unpublished
37+
- name: Release
38+
run: npx semantic-release
3339
env:
3440
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
# workit lesson: setup-node writes NODE_AUTH_TOKEN into .npmrc.
36-
# NPM_TOKEN alone is an empty placeholder there.
3741
NPM_TOKEN: ${{ secrets.NPMJS }}
3842
NODE_AUTH_TOKEN: ${{ secrets.NPMJS }}
39-
run: bun run scripts/publish-if-needed.ts
43+
44+
- name: Sync release manifests to main
45+
if: success()
46+
env:
47+
GH_TOKEN: ${{ secrets.RELEASE_SYNC_TOKEN || secrets.GITHUB_TOKEN }}
48+
run: |
49+
git checkout -- package.json manifest.json 2>/dev/null || true
50+
bun run scripts/sync-release-manifests.ts
51+
if [[ -z "$(git status --porcelain -- package.json manifest.json)" ]]; then
52+
echo "manifests already match the latest tag"
53+
exit 0
54+
fi
55+
VERSION=$(node -p "require('./package.json').version")
56+
BRANCH="chore/manifest-sync-v${VERSION}"
57+
git config user.name "github-actions[bot]"
58+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
59+
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
60+
git checkout -b "${BRANCH}"
61+
git add package.json manifest.json
62+
git commit -m "chore(release): sync manifests to v${VERSION}"
63+
git push -u origin "${BRANCH}"
64+
gh pr create \
65+
--title "chore(release): sync manifests to v${VERSION}" \
66+
--body "Automated post-release manifest alignment. Sets package.json and manifest.json to the released ${VERSION}." \
67+
--base main --head "${BRANCH}"
68+
gh pr merge --auto --squash --delete-branch || echo "auto-merge unavailable — merge the sync PR after CI is green"

.github/workflows/test.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- CI catalog watch every 6 hours, `catalog-break` GitHub issues, and automatic npm patch + GitHub Release after publish.
12+
- GitHub flow: PR-gated `main`, CI matrix (`check (test|typecheck|pack)`), semantic-release on merge, catalog updates as PRs.
1313
- `manifest.json` describing the bundled catalog (status, cost sources, command-code version).
1414
- First publish of `@brainervirus/commandcode-go-opencode-provider`.
1515
- Last-good catalog cache and silent `startup.json` diagnostics under the plugin state dir.

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
# @brainervirus/commandcode-go-opencode-provider
22

33
[![npm version](https://img.shields.io/npm/v/@brainervirus/commandcode-go-opencode-provider)](https://www.npmjs.com/package/@brainervirus/commandcode-go-opencode-provider)
4-
[![CI](https://img.shields.io/github/actions/workflow/status/BrainerVirus/opencode-commandcode-provider/test.yml?branch=main&label=CI)](https://github.com/BrainerVirus/opencode-commandcode-provider/actions)
4+
[![CI](https://img.shields.io/github/actions/workflow/status/BrainerVirus/opencode-commandcode-provider/ci.yml?branch=main&label=CI)](https://github.com/BrainerVirus/opencode-commandcode-provider/actions)
55
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
66

77
[Command Code](https://commandcode.ai) API provider for [opencode](https://opencode.ai). Use Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax, Step, and other models through a single API key.
88

9-
This fork keeps a **bundled** model catalog current via CI. You do **not** need a local `command-code` CLI. Catalog patches publish automatically when Command Code ships a new npm version.
9+
This package keeps a **bundled** model catalog current via CI. You do **not** need a local `command-code` CLI. Catalog patches publish automatically after a green PR merges to `main`.
1010

1111
## Credits
1212

13-
This plugin is based on **[opencode-commandcode-provider](https://github.com/brent-weatherall/opencode-commandcode-provider)** by **[Brent Weatherall](https://github.com/brent-weatherall)**. Thank you for the original OpenCode plugin, catalog extraction, and Command Code wiring.
13+
This plugin is based on **[opencode-commandcode-provider](https://github.com/brent-weatherall/opencode-commandcode-provider)** by **[Brent Weatherall](https://github.com/brent-weatherall)**. Thank you for the original OpenCode plugin, catalog extraction, and Command Code wiring. The license remains MIT; copyright stays with Brent Weatherall.
1414

15-
This public fork started from [FanFan4204/opencode-commandcode-provider](https://github.com/FanFan4204/opencode-commandcode-provider) and continues that work with a CI-kept catalog and npm releases. The license remains MIT; copyright stays with Brent Weatherall.
16-
17-
### Key improvements over upstream
15+
### What this package adds
1816

1917
- Bundled `models.json` is the default runtime catalog (no local CLI scrape).
2018
- CLI cost extraction can fail (as on `command-code@1.38.x`) without dropping models.
@@ -83,9 +81,9 @@ bun test tests/unit/
8381
bun run sync -- --remote # refresh models.json + manifest.json from command-code@latest
8482
```
8583

86-
CI (`.github/workflows/catalog-sync.yml`) runs that every 6 hours, commits catalog files to `main`, publishes an npm patch when `NPMJS` is set, and creates a GitHub Release **after** publish. Model extraction failures open a `catalog-break` issue and do not publish.
84+
CI (`.github/workflows/catalog-sync.yml`) opens a PR every 6 hours when Command Code ships a new catalog. Merge after **check (test)**, **check (typecheck)**, and **check (pack)** are green. `.github/workflows/release.yml` then runs **semantic-release** (npm publish + GitHub Release + tag). Do not push to `main`.
8785

88-
The GitHub Actions secret name is `NPMJS` (same as workit). It is mapped to both `NPM_TOKEN` and `NODE_AUTH_TOKEN`. Use an npm **Automation** token (bypasses 2FA). A login token from `~/.npmrc` fails CI with `EOTP`.
86+
The GitHub Actions secret name is `NPMJS` (same as workit). It is mapped to both `NPM_TOKEN` and `NODE_AUTH_TOKEN`. Use an npm **Automation** token (bypasses 2FA). A login token from `~/.npmrc` fails CI with `EOTP`. Catalog PRs get a real CI run when `RELEASE_SYNC_TOKEN` (or `CATALOG_PUSH_TOKEN`) is a PAT; `GITHUB_TOKEN` can open the PR but GitHub will not start workflows from that event.
8987

9088
## License
9189

0 commit comments

Comments
 (0)