|
| 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 |
0 commit comments