Skip to content

Commit ddd6da0

Browse files
committed
feat(sdk-ts): automate semantic-release for npm publishing
1 parent 10b34c8 commit ddd6da0

8 files changed

Lines changed: 2527 additions & 75 deletions

File tree

‎.github/workflows/pr-title.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
chore
3030
scopes: |
3131
sdk
32+
sdk-ts
3233
server
3334
models
3435
engine

‎.github/workflows/release-sdk-ts.yml‎

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: Release TypeScript SDK
22

33
on:
4+
push:
5+
branches: [ main ]
46
workflow_dispatch:
57
inputs:
68
dry_run:
7-
description: Run npm publish in dry-run mode
9+
description: Run semantic-release in dry-run mode
810
required: true
911
type: boolean
1012
default: true
@@ -13,14 +15,20 @@ jobs:
1315
release-sdk-ts:
1416
runs-on: ubuntu-latest
1517
permissions:
16-
contents: read
18+
contents: write
1719
id-token: write
20+
issues: write
21+
pull-requests: write
1822
env:
1923
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
24+
NPM_CONFIG_PROVENANCE: "true"
2025

2126
steps:
2227
- name: Checkout
2328
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
token: ${{ secrets.GALILEO_AUTOMATION_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
2432

2533
- name: Setup Python
2634
uses: actions/setup-python@v5
@@ -36,7 +44,7 @@ jobs:
3644
- name: Setup Node.js
3745
uses: actions/setup-node@v4
3846
with:
39-
node-version: "20"
47+
node-version: "22.14.0"
4048
registry-url: "https://registry.npmjs.org"
4149

4250
- name: Install pnpm
@@ -66,24 +74,23 @@ jobs:
6674
- name: Build TypeScript SDK
6775
run: make sdk-ts-build
6876

69-
- name: Publish TypeScript SDK (dry run)
70-
if: ${{ inputs.dry_run }}
77+
- name: Run semantic-release
7178
working-directory: ./sdks/typescript
72-
run: npm publish --dry-run
73-
74-
- name: Ensure npm token exists
75-
if: ${{ !inputs.dry_run }}
7679
env:
77-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
80+
GITHUB_TOKEN: ${{ secrets.GALILEO_AUTOMATION_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
81+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
7882
run: |
79-
if [[ -z "${NODE_AUTH_TOKEN}" ]]; then
83+
set -euo pipefail
84+
85+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.dry_run }}" == "true" ]]; then
86+
echo "Running semantic-release dry-run."
87+
pnpm run release:dry-run
88+
exit 0
89+
fi
90+
91+
if [[ -z "${NPM_TOKEN}" ]]; then
8092
echo "NPM_TOKEN secret is required for publish runs."
8193
exit 1
8294
fi
8395
84-
- name: Publish TypeScript SDK
85-
if: ${{ !inputs.dry_run }}
86-
working-directory: ./sdks/typescript
87-
env:
88-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
89-
run: npm publish --provenance
96+
pnpm run release

‎sdks/typescript/CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
All notable changes to the TypeScript SDK are documented in this file.

‎sdks/typescript/README.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,22 @@ Release:
143143

144144
- Package name: `agent-control`
145145
- Release runbook: `RELEASING.md`
146+
147+
## Semantic Versioning
148+
149+
TypeScript SDK versioning is independent from server/monorepo tags and is automated with `semantic-release`.
150+
151+
Release-triggering commit prefixes for scope `sdk-ts`:
152+
153+
- `feat(sdk-ts): ...` -> minor bump
154+
- `fix(sdk-ts): ...` -> patch bump
155+
- `perf(sdk-ts): ...` -> patch bump
156+
- `refactor(sdk-ts): ...` -> patch bump
157+
- `chore(sdk-ts): ...` -> patch bump
158+
- `BREAKING CHANGE` footer or `!` -> major bump
159+
160+
To preview the next computed release locally:
161+
162+
```bash
163+
pnpm run release:dry-run
164+
```

‎sdks/typescript/RELEASING.md‎

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22

33
This package publishes to npm as `agent-control`.
44

5+
## Release policy
6+
7+
- TypeScript SDK releases are independent from server/monorepo version tags.
8+
- Releases are commit-driven via `semantic-release`.
9+
- Expected release-triggering commit scopes use `sdk-ts`:
10+
- `feat(sdk-ts): ...` -> minor bump
11+
- `fix(sdk-ts): ...`, `perf(sdk-ts): ...`, `refactor(sdk-ts): ...`, `chore(sdk-ts): ...` -> patch bump
12+
- `BREAKING CHANGE` or `!` -> major bump
13+
514
## One-time setup
615

716
1. Ensure npm ownership for `agent-control` is configured.
817
2. Add repository secret `NPM_TOKEN` with publish permission.
9-
3. Ensure GitHub Actions has `id-token: write` permission for provenance.
18+
3. Ensure workflow `.github/workflows/release-sdk-ts.yml` has:
19+
- `contents: write` for release commit/tag
20+
- `id-token: write` for npm provenance
1021

11-
## Pre-release checklist
22+
## Pre-release checks
1223

1324
Run from repo root:
1425

@@ -21,36 +32,34 @@ This validates:
2132
- Generated client is current
2233
- Lint, typecheck, test, and build all pass
2334

24-
## Local package dry run
35+
## Local semantic-release preview
2536

26-
Run from repo root:
37+
Run from `sdks/typescript`:
2738

2839
```bash
29-
make sdk-ts-publish-dry-run
40+
pnpm run release:dry-run
3041
```
3142

32-
This runs the publish gate checks and then executes `npm publish --dry-run`.
43+
This previews the next semantic version and release notes without publishing.
3344

3445
## GitHub Actions release flow
3546

36-
Use workflow `.github/workflows/release-sdk-ts.yml`:
47+
Workflow: `.github/workflows/release-sdk-ts.yml`
3748

38-
1. Trigger manually with `dry_run=true` first.
39-
2. Confirm all checks and packaging output are correct.
40-
3. Trigger again with `dry_run=false` to publish.
49+
- Automatic publish: runs on `push` to `main`.
50+
- Manual preview: `workflow_dispatch` with `dry_run=true`.
51+
- Manual publish: `workflow_dispatch` with `dry_run=false`.
4152

42-
The publish run performs:
43-
- `make sdk-ts-generate-check` (this generates OpenAPI from server code, then checks SDK/overlay drift)
44-
- `make sdk-ts-lint`
45-
- `make sdk-ts-typecheck`
46-
- `make sdk-ts-test`
47-
- `make sdk-ts-build`
48-
- `npm publish --provenance`
53+
Release job performs:
54+
- `make sdk-ts-release-check`
55+
- `semantic-release` (updates `package.json` + `CHANGELOG.md`, creates Git tag/release, publishes to npm)
4956

5057
## Post-publish verification
5158

52-
1. Install from npm in a clean temp project:
59+
1. Confirm npm version/dist-tag:
60+
- `npm view agent-control version dist-tags --json`
61+
2. Install from npm in a clean temp project:
5362
- `npm i agent-control`
54-
2. Confirm import works:
63+
3. Confirm import works:
5564
- `import { AgentControlClient } from "agent-control";`
56-
3. Verify package metadata on npm and GitHub release notes.
65+
4. Verify GitHub release/tag and changelog update.

‎sdks/typescript/package.json‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
"test:watch": "vitest",
5050
"generate": "make generate",
5151
"generate:check": "make generate-check",
52-
"speakeasy:install": "make speakeasy-install"
52+
"speakeasy:install": "make speakeasy-install",
53+
"release": "semantic-release",
54+
"release:dry-run": "semantic-release --dry-run"
5355
},
5456
"dependencies": {
5557
"zod": "^4.1.11"
@@ -58,7 +60,14 @@
5860
"@types/node": "^22.14.1",
5961
"@typescript-eslint/eslint-plugin": "^8.30.1",
6062
"@typescript-eslint/parser": "^8.30.1",
63+
"@semantic-release/changelog": "^6.0.3",
64+
"@semantic-release/commit-analyzer": "^13.0.1",
65+
"@semantic-release/git": "^10.0.1",
66+
"@semantic-release/github": "^11.0.6",
67+
"@semantic-release/npm": "^12.0.2",
68+
"@semantic-release/release-notes-generator": "^14.1.0",
6169
"eslint": "^8.57.1",
70+
"semantic-release": "^25.0.2",
6271
"tsup": "^8.3.6",
6372
"typescript": "^5.8.2",
6473
"vitest": "^3.0.9"

0 commit comments

Comments
 (0)