Skip to content

ci: automate release — version-bump PR, draft release, and dist-tag sync#2256

Merged
ninadbstack merged 9 commits into
masterfrom
ci/automate-release-pr
Jun 2, 2026
Merged

ci: automate release — version-bump PR, draft release, and dist-tag sync#2256
ninadbstack merged 9 commits into
masterfrom
ci/automate-release-pr

Conversation

@pranavz28
Copy link
Copy Markdown
Contributor

@pranavz28 pranavz28 commented Jun 1, 2026

Summary

Automates the manual release chore behind a button, keeping humans on the two real gates (merge + publish). No npm publish happens automatically — the existing release.yml (unchanged) still runs only when you publish a GitHub Release.

version-bump.yml (new) — "Create Release PR" button

Manually triggered from the Actions tab. You pick how to bump from a dropdown (each option carries a fixed, illustrative example):

prerelease  (e.g. 1.2.3-beta.4 -> 1.2.3-beta.5)
patch       (e.g. 1.2.3-beta.4 -> 1.2.3, or 1.2.3 -> 1.2.4)
minor / major / preminor / premajor ...
  • The target version is computed dynamically at run time from the current version (semver) — nothing is hard-coded or self-edited. The actual resolved version shows in the run summary and the PR title.
  • Bumps all packages in lockstep (lerna fixed mode) and syncs each package's publishConfig.tag to match: beta for prereleases, latest for stable.
  • Opens a Release X.Y.Z PR that touches only lerna.json + packages/**/package.json — never workflow files (so the default GITHUB_TOKEN works; no PAT needed).

draft-release.yml (new) — auto draft on merge

When a Release … PR merges to master, creates a draft GitHub Release: v<version> tag, --prerelease flag for betas, --generate-notes. You just click Publish to ship. Skips if the tag's release already exists.

package.jsonbump-version also syncs the tag

yarn bump-version now runs lerna version … then sets publishConfig.tag to match the result, so local bumps stay correct too. lerna remains the direct command (tag-sync chained after it).

release.yml is intentionally unchanged — npm publish behavior is exactly as today, now fed the correct publishConfig.tag.

Flow

"Create Release PR" button → Release X.Y.Z PR (version + tag synced)
   → review & merge           → draft GitHub Release auto-created
   → click Publish            → existing release.yml publishes to npm + builds executables

Required repo settings

  1. Settings → Actions → General → Workflow permissions → "Allow GitHub Actions to create and approve pull requests."
  2. PRs opened by the default GITHUB_TOKEN don't trigger CI (test.yml/lint.yml). If CI on the Release PR is desired, add a RELEASE_PAT secret and switch the token: in version-bump.yml. (Release PRs are version-only, so this is optional.)

Testing

Verified end-to-end on a fork (pranavz28/cli):

  • ✅ All bump types create a Release X.Y.Z PR touching only version files (0 workflow files).
  • beta → latest (patch) and latest → beta (prerelease) flip both the version and publishConfig.tag across all 18 publishable packages.
  • ✅ Merging a Release PR auto-creates a draft release with the correct prerelease flag (false for stable, true for beta).

🤖 Generated with Claude Code

@pranavz28 pranavz28 requested a review from a team as a code owner June 1, 2026 12:55
@pranavz28 pranavz28 added the 🧹 maintenance General maintenance label Jun 1, 2026
pranavz28 and others added 4 commits June 1, 2026 19:34
- Add "Create Release PR" workflow_dispatch: bumps all package versions
  (lerna fixed mode) and opens a Release X.Y.Z PR. Inputs choose the bump
  type (pre* = beta channel, plain = latest) and preid.
- Add Draft Release workflow: on merge of a "Release ..." PR, auto-create a
  draft GitHub Release with the v-tag, pre-release flag for betas, and
  generated notes. Publishing stays a manual human gate.
- release.yml now derives the npm dist-tag (beta vs latest) from the version
  instead of defaulting everything to latest.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Keep release.yml as-is; this PR only adds the Create Release PR button and
the Draft Release automation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the bump-type dropdown + preid with a single 'version' text input.
You type the exact target (e.g. 1.32.0-beta.5); the run summary shows
current -> new. Validates semver format before touching files.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GitHub can't compute versions in a workflow_dispatch form, so bake them in:
add scripts/gen-release-options.mjs which rewrites the choice options as
"<bump>: <current> -> <target>". The workflow runs it after bumping and
commits the refreshed dropdown into the Release PR, so master's form always
reflects the latest version. The bump step parses the target from the choice.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pranavz28 pranavz28 force-pushed the ci/automate-release-pr branch from d59ff45 to 3f27d84 Compare June 1, 2026 14:05
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pranavz28 pranavz28 force-pushed the ci/automate-release-pr branch from 72d73d7 to c4c4b3b Compare June 1, 2026 14:22
pranavz28 and others added 4 commits June 2, 2026 16:33
Drop the self-editing dropdown generator (scripts/gen-release-options.mjs).
GitHub workflow_dispatch dropdowns are static and can't show computed values,
and editing the workflow file in the release PR was both blocked for
GITHUB_TOKEN and wrong for a release PR. Instead, the dropdown is a simple
bump-type picker and the bump step computes the target from the current
version at run time via semver. add-paths scopes the PR to version files only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…un time)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A release sets each package's publishConfig.tag (the npm dist-tag used by
`lerna publish from-package`) to `beta` for prereleases and `latest` for
stable. Fold it into `yarn bump-version` (chained after lerna) so it applies
locally, and mirror it in the Create Release PR workflow after its lerna call.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GitHub can't render computed values in workflow_dispatch dropdowns, so show a
fixed generic example per option (e.g. 1.2.3 -> 1.3.0). The bump step parses
the leading keyword; the actual resulting version still shows in the summary.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pranavz28 pranavz28 changed the title ci: automate release PR creation, draft release, and npm dist-tag ci: automate release — version-bump PR, draft release, and dist-tag sync Jun 2, 2026
@ninadbstack ninadbstack merged commit da36844 into master Jun 2, 2026
44 of 45 checks passed
@ninadbstack ninadbstack deleted the ci/automate-release-pr branch June 2, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧹 maintenance General maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants