Skip to content

Commit b151987

Browse files
committed
Add npm release workflows
1 parent 96047e8 commit b151987

6 files changed

Lines changed: 226 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Release CUA Agent
2+
3+
on:
4+
push:
5+
tags:
6+
- "cua-agent/v*"
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
concurrency:
13+
group: release-cua-agent-${{ github.ref_name }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
publish:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 20
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Verify tag is on main
26+
run: |
27+
git fetch origin main:refs/remotes/origin/main
28+
git merge-base --is-ancestor "$GITHUB_SHA" origin/main
29+
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version: 24
33+
registry-url: https://registry.npmjs.org
34+
35+
- name: Ensure npm supports trusted publishing
36+
run: npm install -g npm@^11.5.1
37+
38+
- run: npm ci
39+
40+
- name: Verify package version matches tag
41+
run: |
42+
node --input-type=module <<'EOF'
43+
import { readFileSync } from "node:fs";
44+
45+
const tag = process.env.GITHUB_REF_NAME;
46+
const prefix = "cua-agent/v";
47+
if (!tag?.startsWith(prefix)) {
48+
throw new Error(`Expected tag to start with ${prefix}, got ${tag}`);
49+
}
50+
51+
const tagVersion = tag.slice(prefix.length);
52+
const pkg = JSON.parse(readFileSync("packages/agent/package.json", "utf8"));
53+
if (pkg.version !== tagVersion) {
54+
throw new Error(`Tag version ${tagVersion} does not match ${pkg.name} package.json version ${pkg.version}`);
55+
}
56+
57+
console.log(`${pkg.name}@${pkg.version}`);
58+
EOF
59+
60+
- run: npm run build --workspace @onkernel/cua-ai
61+
- run: npm run build --workspace @onkernel/cua-agent
62+
63+
- name: Unit tests
64+
run: npm test --workspace @onkernel/cua-agent -- test/agent.test.ts test/tool-exhaustiveness.test.ts
65+
66+
- name: Verify dependency package is published
67+
run: npm view @onkernel/cua-ai@$(node -p 'require("./packages/agent/package.json").dependencies["@onkernel/cua-ai"]') version
68+
69+
- name: Pack dry run
70+
run: npm pack --workspace @onkernel/cua-agent --dry-run
71+
72+
- name: Publish to npm
73+
run: npm publish --workspace @onkernel/cua-agent --access public
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release CUA AI
2+
3+
on:
4+
push:
5+
tags:
6+
- "cua-ai/v*"
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
concurrency:
13+
group: release-cua-ai-${{ github.ref_name }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
publish:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 20
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Verify tag is on main
26+
run: |
27+
git fetch origin main:refs/remotes/origin/main
28+
git merge-base --is-ancestor "$GITHUB_SHA" origin/main
29+
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version: 24
33+
registry-url: https://registry.npmjs.org
34+
35+
- name: Ensure npm supports trusted publishing
36+
run: npm install -g npm@^11.5.1
37+
38+
- run: npm ci
39+
40+
- name: Verify package version matches tag
41+
run: |
42+
node --input-type=module <<'EOF'
43+
import { readFileSync } from "node:fs";
44+
45+
const tag = process.env.GITHUB_REF_NAME;
46+
const prefix = "cua-ai/v";
47+
if (!tag?.startsWith(prefix)) {
48+
throw new Error(`Expected tag to start with ${prefix}, got ${tag}`);
49+
}
50+
51+
const tagVersion = tag.slice(prefix.length);
52+
const pkg = JSON.parse(readFileSync("packages/ai/package.json", "utf8"));
53+
if (pkg.version !== tagVersion) {
54+
throw new Error(`Tag version ${tagVersion} does not match ${pkg.name} package.json version ${pkg.version}`);
55+
}
56+
57+
console.log(`${pkg.name}@${pkg.version}`);
58+
EOF
59+
60+
- run: npm run build --workspace @onkernel/cua-ai
61+
62+
- name: Unit tests
63+
run: >
64+
npm test --workspace @onkernel/cua-ai --
65+
test/api-keys.test.ts
66+
test/models.test.ts
67+
test/providers.test.ts
68+
test/runtime-spec.test.ts
69+
test/tools.test.ts
70+
test/yutori-payload.test.ts
71+
72+
- name: Pack dry run
73+
run: npm pack --workspace @onkernel/cua-ai --dry-run
74+
75+
- name: Publish to npm
76+
run: npm publish --workspace @onkernel/cua-ai --access public

‎docs/npm-releases.md‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# npm releases
2+
3+
`@onkernel/cua-ai` and `@onkernel/cua-agent` publish from package-specific tags:
4+
5+
- `cua-ai/v0.1.0` runs `.github/workflows/release-cua-ai.yml`
6+
- `cua-agent/v0.1.0` runs `.github/workflows/release-cua-agent.yml`
7+
8+
The tag version must match the target package's `package.json` version, and the
9+
tagged commit must be contained in `main`.
10+
11+
## Trusted publishing setup
12+
13+
Configure each package on npm with a GitHub Actions trusted publisher:
14+
15+
| package | organization | repository | workflow filename | environment |
16+
| --- | --- | --- | --- | --- |
17+
| `@onkernel/cua-ai` | `kernel` | `cua` | `release-cua-ai.yml` | leave blank |
18+
| `@onkernel/cua-agent` | `kernel` | `cua` | `release-cua-agent.yml` | leave blank |
19+
20+
The same configuration can be created from the npm CLI:
21+
22+
```sh
23+
npm install -g npm@^11.10.0
24+
npm trust github @onkernel/cua-ai --repo kernel/cua --file release-cua-ai.yml
25+
npm trust github @onkernel/cua-agent --repo kernel/cua --file release-cua-agent.yml
26+
```
27+
28+
npm requires packages to exist before a trusted publisher can be configured. If
29+
the package has not been published yet, either publish the first version manually
30+
and use trusted publishing for later versions, or publish a bootstrap version
31+
first, configure trusted publishing, then release `0.1.0` from tags.
32+
33+
## Releasing 0.1.0
34+
35+
Publish `@onkernel/cua-ai` first because `@onkernel/cua-agent` depends on it:
36+
37+
```sh
38+
git checkout main
39+
git pull --ff-only
40+
git tag cua-ai/v0.1.0
41+
git push origin cua-ai/v0.1.0
42+
```
43+
44+
After `@onkernel/cua-ai@0.1.0` is available on npm:
45+
46+
```sh
47+
git tag cua-agent/v0.1.0
48+
git push origin cua-agent/v0.1.0
49+
```

‎package-lock.json‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/agent/package.json‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22
"name": "@onkernel/cua-agent",
33
"version": "0.1.0",
44
"description": "Kernel browser computer-use Agent and AgentHarness classes built on pi-agent-core",
5+
"license": "MIT",
56
"type": "module",
67
"main": "./dist/index.js",
78
"types": "./dist/index.d.ts",
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/kernel/cua.git",
12+
"directory": "packages/agent"
13+
},
14+
"bugs": {
15+
"url": "https://github.com/kernel/cua/issues"
16+
},
17+
"homepage": "https://github.com/kernel/cua/tree/main/packages/agent#readme",
818
"exports": {
919
".": {
1020
"types": "./dist/index.d.ts",
@@ -18,6 +28,9 @@
1828
"README.md",
1929
"CHANGELOG.md"
2030
],
31+
"publishConfig": {
32+
"access": "public"
33+
},
2134
"scripts": {
2235
"build": "tsc -b",
2336
"clean": "tsc -b --clean",

‎packages/ai/package.json‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22
"name": "@onkernel/cua-ai",
33
"version": "0.1.0",
44
"description": "Kernel-curated computer-use model access built on pi-ai",
5+
"license": "MIT",
56
"type": "module",
67
"main": "./dist/index.js",
78
"types": "./dist/index.d.ts",
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/kernel/cua.git",
12+
"directory": "packages/ai"
13+
},
14+
"bugs": {
15+
"url": "https://github.com/kernel/cua/issues"
16+
},
17+
"homepage": "https://github.com/kernel/cua/tree/main/packages/ai#readme",
818
"exports": {
919
".": {
1020
"types": "./dist/index.d.ts",
@@ -18,6 +28,9 @@
1828
"README.md",
1929
"CHANGELOG.md"
2030
],
31+
"publishConfig": {
32+
"access": "public"
33+
},
2134
"scripts": {
2235
"build": "tsc -b",
2336
"clean": "tsc -b --clean",

0 commit comments

Comments
 (0)