From 445a335b900e3126205690bfe05472c8379ff5b9 Mon Sep 17 00:00:00 2001 From: priosshrsth Date: Tue, 18 Aug 2026 12:34:14 +0000 Subject: [PATCH 1/2] ci: manage releases with release-please Replaces the hand-rolled release workflow. The previous attempts all failed on the same conflict: the version had to be decided somewhere, and every option either required CI to write to a branch its rulesets protect, or left package.json as a placeholder that no longer described the published package. release-please resolves both. It opens a release PR that bumps package.json, src/version.ts and CHANGELOG.md from the conventional commits on main. Merging that PR goes through the normal review path, so the ruleset is satisfied and the merge commit is signed by GitHub. release-please then tags it and creates the GitHub Release, and the publish job builds from that tag. The version in the repository is accurate again, and no tag or bump is created by hand. --- .claude/CLAUDE.md | 20 ++++++++++- .github/workflows/release.yml | 66 ++++++++++++++++------------------- .release-please-manifest.json | 3 ++ release-please-config.json | 11 ++++++ src/version.ts | 2 +- 5 files changed, 64 insertions(+), 38 deletions(-) create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index 9536b55..d8e0ce9 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -13,13 +13,31 @@ pnpm run build # Build all entry points to dist/ via vp pack pnpm run dev # Build in watch mode pnpm test # Run tests via vp test pnpm run check # Lint + format + type check via vp check -pnpm run release # Bump version, commit, push, tag via bumpp ``` Pre-commit hook runs `vp check --fix` on staged files. After any significant code change, always run `vp check --fix` to ensure lint, formatting, and type checking pass before committing. +## Releasing + +Releases are driven by [release-please](https://github.com/googleapis/release-please) from +conventional commit messages on `main` (`feat:` `fix:` `chore:` `ci:`, with `!` or a +`BREAKING CHANGE:` footer for majors). + +1. Merge PRs to `main` as usual. +2. release-please keeps an open `chore(main): release x.y.z` PR that bumps + `package.json`, `src/version.ts` and `CHANGELOG.md`. +3. Merge that PR. release-please tags it and creates the GitHub Release, then the + `publish` job builds and publishes to npm via OIDC trusted publishing. + +Never bump the version or create a tag by hand — release-please owns both, and +`.release-please-manifest.json` is the source of truth for the current version. To force a +specific version, put `Release-As: 1.2.3` in a commit footer. + +`src/version.ts` carries an `x-release-please-version` marker so it is bumped alongside +`package.json`; `tests/version.test.ts` fails if the two ever drift. + ## Documentation Rules After any significant code change, update the following: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3edacb8..d9e0c22 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,34 +1,45 @@ name: Release on: - release: - types: [published] + push: + branches: [main] permissions: contents: write - id-token: write + pull-requests: write + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false jobs: - release: - name: Release Package + release-please: + name: Release PR + runs-on: ubuntu-latest + outputs: + released: ${{ steps.release.outputs.release_created }} + tag: ${{ steps.release.outputs.tag_name }} + steps: + - uses: googleapis/release-please-action@v4 + id: release + with: + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + + publish: + name: Publish to npm + needs: release-please + if: needs.release-please.outputs.released == 'true' runs-on: ubuntu-latest environment: release + permissions: + contents: read + id-token: write steps: - - name: Checkout main + - name: Checkout release tag uses: actions/checkout@v6 with: - ref: main - fetch-depth: 0 - - - name: Resolve version from release tag - env: - TAG: ${{ github.event.release.tag_name }} - run: | - if ! echo "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then - echo "::error::Release tag '$TAG' is not a vSEMVER tag (e.g. v0.0.6, v10.1.11)." - exit 1 - fi - echo "VERSION=${TAG#v}" >> "$GITHUB_ENV" + ref: ${{ needs.release-please.outputs.tag }} - name: Setup Bun uses: oven-sh/setup-bun@v2 @@ -54,30 +65,13 @@ jobs: - name: Run tests run: bun run test - - name: Bump to the released version - env: - TAG: ${{ github.event.release.tag_name }} - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - npm version "$VERSION" --no-git-tag-version --allow-same-version - printf '/** SDK version string sent with every API request. */\nexport const SDK_VERSION: string = "%s";\n' "$VERSION" > src/version.ts - if git diff --quiet; then - echo "Already at $VERSION" - else - git commit -am "chore: release v$VERSION" - git push origin HEAD:main - fi - git tag -f "$TAG" - git push -f origin "refs/tags/$TAG" - - name: Build run: bun run build # No NODE_AUTH_TOKEN: auth comes from OIDC trusted publishing. # Requires a trusted publisher configured on npmjs.com for this repo, # workflow (release.yml), and the "release" environment. - - name: Publish to npm + - name: Publish run: npm pack && npm publish ./*.tgz --access public --provenance env: NPM_CONFIG_PROVENANCE: true diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..45ca42f --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.5" +} diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..fa53bff --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "release-type": "node", + "changelog-path": "CHANGELOG.md", + "include-component-in-tag": false, + "extra-files": ["src/version.ts"] + } + } +} diff --git a/src/version.ts b/src/version.ts index 66ab1ee..0763a2d 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1,2 @@ /** SDK version string sent with every API request. */ -export const SDK_VERSION: string = "0.0.5"; +export const SDK_VERSION: string = "0.0.5"; // x-release-please-version From d170a960fef913b6a8a686b21330095e606bbaab Mon Sep 17 00:00:00 2001 From: priosshrsth Date: Wed, 19 Aug 2026 11:21:22 +0000 Subject: [PATCH 2/2] ci: keep pre-1.0 releases on the patch line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While the version is below 1.0.0, features bump the patch and breaking changes bump the minor, matching how 0.0.2 through 0.0.5 were released — 0.0.5 itself carried a feat. Without this the next release would be 0.1.0. --- release-please-config.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release-please-config.json b/release-please-config.json index fa53bff..03517cd 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,5 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": true, "packages": { ".": { "release-type": "node",