From 4c16a3346b2e34c3c7a914c7419f9adfc458a6a3 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 10:58:32 -0700 Subject: [PATCH 01/14] Add BUMPY_GH_TOKEN support and ci setup command Replace the non-working API commit reroute with a token-aware push that temporarily swaps the remote URL to use a custom PAT/App token. Add interactive `bumpy ci setup` command that walks users through creating a fine-grained PAT or GitHub App and storing the secret. Co-Authored-By: Claude Opus 4.6 (1M context) --- .bumpy/fix-version-pr-ci-triggers.md | 8 +- packages/bumpy/src/cli.ts | 6 +- packages/bumpy/src/commands/ci-setup.ts | 260 ++++++++++++++++++++++++ packages/bumpy/src/commands/ci.ts | 86 ++++---- 4 files changed, 314 insertions(+), 46 deletions(-) create mode 100644 packages/bumpy/src/commands/ci-setup.ts diff --git a/.bumpy/fix-version-pr-ci-triggers.md b/.bumpy/fix-version-pr-ci-triggers.md index 24e99e4..8c2b571 100644 --- a/.bumpy/fix-version-pr-ci-triggers.md +++ b/.bumpy/fix-version-pr-ci-triggers.md @@ -1,7 +1,9 @@ --- -'@varlock/bumpy': patch +'@varlock/bumpy': minor --- -Fix version PR not triggering CI workflow runs +Support custom token for triggering CI on version PRs -After pushing the version branch, recreate the tip commit via the GitHub REST API so that pull_request workflows fire automatically. Commits pushed with GITHUB_TOKEN don't trigger workflows due to GitHub's anti-recursion guard, but API-created commits bypass this — no PATs, GitHub Apps, or user CI config changes needed. +- Add `BUMPY_GH_TOKEN` env var support — when set, bumpy pushes the version branch using the custom token, bypassing GitHub's anti-recursion guard so PR workflows fire automatically +- Add `bumpy ci setup` interactive command to help create a fine-grained PAT or GitHub App and store it as a repo secret +- When no custom token is set, log a warning with setup instructions diff --git a/packages/bumpy/src/cli.ts b/packages/bumpy/src/cli.ts index fe19daa..421de66 100644 --- a/packages/bumpy/src/cli.ts +++ b/packages/bumpy/src/cli.ts @@ -114,8 +114,11 @@ async function main() { tag: ciFlags.tag as string | undefined, branch: ciFlags.branch as string | undefined, }); + } else if (subcommand === 'setup') { + const { ciSetupCommand } = await import('./commands/ci-setup.ts'); + await ciSetupCommand(rootDir); } else { - log.error(`Unknown ci subcommand: ${subcommand}. Use "ci check" or "ci release".`); + log.error(`Unknown ci subcommand: ${subcommand}. Use "ci check", "ci release", or "ci setup".`); process.exit(1); } break; @@ -189,6 +192,7 @@ function printHelp() { publish Publish versioned packages ci check PR check — report pending releases, comment on PR ci release Release — create version PR or auto-publish + ci setup Set up a token for triggering CI on version PRs migrate Migrate from .changeset/ to .bumpy/ ai setup Install AI skill for creating changesets diff --git a/packages/bumpy/src/commands/ci-setup.ts b/packages/bumpy/src/commands/ci-setup.ts new file mode 100644 index 0000000..dba4cd3 --- /dev/null +++ b/packages/bumpy/src/commands/ci-setup.ts @@ -0,0 +1,260 @@ +import pc from 'picocolors'; +import { log } from '../utils/logger.ts'; +import { p, unwrap } from '../utils/clack.ts'; +import { tryRunArgs } from '../utils/shell.ts'; + +const PAT_PERMISSIONS = [ + 'contents: read & write', + 'pull requests: read & write', + 'metadata: read (selected automatically)', +]; + +export async function ciSetupCommand(rootDir: string): Promise { + p.intro(pc.bgCyan(pc.black(' bumpy ci setup '))); + + // Detect repo context + const repo = detectRepo(rootDir); + if (!repo) { + log.error('Could not detect GitHub repository. Run this from a repo with a GitHub remote.'); + process.exit(1); + } + + p.log.info(`Detected repository: ${pc.cyan(repo)}`); + p.log.info(''); + p.log.info( + 'To trigger CI checks on the version PR, bumpy needs a token\n' + + "that bypasses GitHub's default anti-recursion guard.\n" + + 'You can use a fine-grained PAT or a GitHub App installation token.', + ); + + const method = unwrap( + await p.select({ + message: 'How would you like to authenticate?', + options: [ + { + label: 'Fine-grained Personal Access Token (PAT)', + value: 'pat' as const, + hint: 'simplest setup', + }, + { + label: 'GitHub App installation token', + value: 'app' as const, + hint: 'recommended for orgs / shared repos', + }, + ], + }), + ); + + if (method === 'pat') { + await setupPat(rootDir, repo); + } else { + await setupApp(rootDir, repo); + } +} + +// ---- PAT flow ---- + +async function setupPat(rootDir: string, repo: string): Promise { + const patUrl = 'https://github.com/settings/personal-access-tokens/new'; + + p.log.info(''); + p.note( + [ + `1. Open: ${pc.cyan(patUrl)}`, + '', + `2. Set a name, e.g. ${pc.dim('"bumpy-ci"')}`, + '', + `3. Under ${pc.bold('Repository access')}, select ${pc.bold('"Only select repositories"')}`, + ` and choose ${pc.cyan(repo)}`, + '', + `4. Under ${pc.bold('Permissions → Repository permissions')}, grant:`, + ...PAT_PERMISSIONS.map((perm) => ` • ${pc.bold(perm)}`), + '', + '5. Click "Generate token" and copy the value', + ].join('\n'), + 'Create a fine-grained PAT', + ); + + // Try to open browser + const shouldOpen = unwrap(await p.confirm({ message: 'Open the token creation page in your browser?' })); + if (shouldOpen) { + openBrowser(patUrl); + } + + // Prompt for the token + const token = unwrap( + await p.text({ + message: 'Paste your token:', + placeholder: 'github_pat_...', + validate: (value) => { + if (!value?.trim()) return 'Token is required'; + if (!value?.startsWith('github_pat_')) return 'Expected a fine-grained PAT (starts with github_pat_)'; + }, + }), + ); + + await storeSecret(rootDir, repo, token); +} + +// ---- GitHub App flow ---- + +async function setupApp(rootDir: string, repo: string): Promise { + const owner = repo.split('/')[0]!; + const appUrl = `https://github.com/organizations/${owner}/settings/apps/new`; + const personalAppUrl = `https://github.com/settings/apps/new`; + + const isOrg = unwrap(await p.confirm({ message: `Is ${pc.cyan(owner)} a GitHub organization?`, initialValue: true })); + + const createUrl = isOrg ? appUrl : personalAppUrl; + + p.log.info(''); + p.note( + [ + 'If you already have a GitHub App, skip to step 2.', + '', + pc.bold('Step 1: Create a GitHub App'), + '', + `1. Open: ${pc.cyan(createUrl)}`, + `2. Set the name, e.g. ${pc.dim(`"${owner}-bumpy-ci"`)}`, + '3. Uncheck "Active" under Webhooks (not needed)', + '4. Under Permissions → Repository permissions, grant:', + ...PAT_PERMISSIONS.map((perm) => ` • ${pc.bold(perm)}`), + '5. Under "Where can this app be installed?" select "Only on this account"', + '6. Click "Create GitHub App"', + '7. Note the App ID shown on the settings page', + '8. Generate a private key and download the .pem file', + '', + pc.bold('Step 2: Install the App'), + '', + `Install the app on ${pc.cyan(repo)} from the app's "Install App" tab.`, + '', + pc.bold('Step 3: Add secrets'), + '', + "You'll need to add two repository secrets:", + ` • ${pc.bold('BUMPY_APP_ID')} — the App ID`, + ` • ${pc.bold('BUMPY_APP_PRIVATE_KEY')} — contents of the .pem file`, + ].join('\n'), + 'GitHub App setup', + ); + + const shouldOpen = unwrap(await p.confirm({ message: 'Open the app creation page in your browser?' })); + if (shouldOpen) { + openBrowser(createUrl); + } + + const hasSecrets = unwrap( + await p.confirm({ message: 'Have you added the BUMPY_APP_ID and BUMPY_APP_PRIVATE_KEY secrets?' }), + ); + + if (hasSecrets) { + printAppWorkflowSnippet(); + } else { + p.log.info('You can add them later. Once ready, update your release workflow:'); + printAppWorkflowSnippet(); + } + + p.outro(pc.green('GitHub App setup complete!')); +} + +// ---- Shared helpers ---- + +async function storeSecret(rootDir: string, repo: string, token: string): Promise { + const hasGh = tryRunArgs(['gh', '--version']); + if (!hasGh) { + p.log.warn("`gh` CLI not found — you'll need to add the secret manually."); + p.note( + `Go to: https://github.com/${repo}/settings/secrets/actions/new\n` + + `Name: ${pc.bold('BUMPY_GH_TOKEN')}\nValue: (the token you just created)`, + 'Add repository secret manually', + ); + printPatWorkflowSnippet(); + p.outro(pc.green('Setup complete!')); + return; + } + + const spin = p.spinner(); + spin.start('Storing BUMPY_GH_TOKEN as a repository secret...'); + try { + // gh secret set reads from stdin + tryRunArgs(['gh', 'secret', 'set', 'BUMPY_GH_TOKEN', '--repo', repo], { + cwd: rootDir, + input: token, + } as any); + spin.stop('Secret stored!'); + } catch { + spin.stop('Failed to store secret'); + p.log.warn('Could not store the secret automatically.'); + p.note( + `Go to: https://github.com/${repo}/settings/secrets/actions/new\n` + + `Name: ${pc.bold('BUMPY_GH_TOKEN')}\nValue: (the token you just created)`, + 'Add repository secret manually', + ); + } + + printPatWorkflowSnippet(); + p.outro(pc.green('Setup complete!')); +} + +function printPatWorkflowSnippet(): void { + p.note( + [ + 'In your release workflow, pass the token to bumpy:', + '', + pc.dim('# .github/workflows/release.yaml'), + '- run: bunx @varlock/bumpy ci release', + ' env:', + ' GH_TOKEN: ${{ github.token }}', + ` ${pc.bold('BUMPY_GH_TOKEN: ${{ secrets.BUMPY_GH_TOKEN }}')}`, + ].join('\n'), + 'Update your workflow', + ); +} + +function printAppWorkflowSnippet(): void { + p.note( + [ + 'In your release workflow, generate a token and pass it to bumpy:', + '', + pc.dim('# .github/workflows/release.yaml'), + '- uses: actions/create-github-app-token@v2', + ' id: app-token', + ' with:', + ' app-id: ${{ secrets.BUMPY_APP_ID }}', + ' private-key: ${{ secrets.BUMPY_APP_PRIVATE_KEY }}', + '', + '- run: bunx @varlock/bumpy ci release', + ' env:', + ' GH_TOKEN: ${{ github.token }}', + ` ${pc.bold('BUMPY_GH_TOKEN: ${{ steps.app-token.outputs.token }}')}`, + ].join('\n'), + 'Update your workflow', + ); +} + +function detectRepo(rootDir: string): string | null { + // Check GitHub Actions env first + if (process.env.GITHUB_REPOSITORY) return process.env.GITHUB_REPOSITORY; + + // Try to extract from git remote + const remote = tryRunArgs(['git', 'remote', 'get-url', 'origin'], { cwd: rootDir }); + if (!remote) return null; + + // SSH: git@github.com:owner/repo.git + const sshMatch = remote.match(/github\.com[:/](.+?)(?:\.git)?$/); + if (sshMatch) return sshMatch[1]!; + + // HTTPS: https://github.com/owner/repo.git + const httpsMatch = remote.match(/github\.com\/(.+?)(?:\.git)?$/); + if (httpsMatch) return httpsMatch[1]!; + + return null; +} + +function openBrowser(url: string): void { + try { + const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open'; + tryRunArgs([cmd, url]); + } catch { + // Silent fail — user can open manually + } +} diff --git a/packages/bumpy/src/commands/ci.ts b/packages/bumpy/src/commands/ci.ts index d3cf629..95ae13b 100644 --- a/packages/bumpy/src/commands/ci.ts +++ b/packages/bumpy/src/commands/ci.ts @@ -115,6 +115,12 @@ interface ReleaseOptions { * Designed for merge-to-main workflows. */ export async function ciReleaseCommand(rootDir: string, opts: ReleaseOptions): Promise { + // If a custom token is provided, also expose it as GH_TOKEN so that + // `gh` CLI calls (PR creation, comments, etc.) use the same credential. + if (process.env.BUMPY_GH_TOKEN) { + process.env.GH_TOKEN = process.env.BUMPY_GH_TOKEN; + } + const config = await loadConfig(rootDir); ensureGitIdentity(rootDir, config); const { packages } = await discoverWorkspace(rootDir, config); @@ -164,47 +170,47 @@ async function autoPublish(rootDir: string, config: BumpyConfig, tag?: string): await publishCommand(rootDir, { tag }); } -// ---- GitHub API push helper ---- +// ---- Token-aware push ---- /** - * After a normal `git push`, recreate the tip commit via the GitHub REST API - * and force-update the branch ref to point at the API-created commit. + * Push a branch to origin, optionally using a custom GitHub token. + * + * When `BUMPY_GH_TOKEN` is set, the remote URL is temporarily rewritten to + * include the token. Pushes made with a PAT or GitHub App token bypass + * GitHub's anti-recursion guard, allowing `pull_request` workflows to fire + * on the version PR — no extra CI configuration required. * - * Why: commits pushed with GITHUB_TOKEN don't trigger workflow runs (GitHub's - * anti-recursion guard), but commits created through the REST API *do*. - * The API commit has the same tree and parent so the PR diff is identical. + * When only the default `GITHUB_TOKEN` is available the push still succeeds, + * but PR workflows won't be triggered automatically. */ -async function rerouteCommitViaApi( - rootDir: string, - branch: string, - commitMsg: string, - config: BumpyConfig, -): Promise { - const treeSha = runArgs(['git', 'rev-parse', 'HEAD^{tree}'], { cwd: rootDir }); - const parentSha = runArgs(['git', 'rev-parse', 'HEAD~1'], { cwd: rootDir }); - - const commitBody = JSON.stringify({ - message: commitMsg, - tree: treeSha, - parents: [parentSha], - author: { - name: config.gitUser.name, - email: config.gitUser.email, - }, - }); - - const apiCommitSha = await runArgsAsync( - ['gh', 'api', 'repos/{owner}/{repo}/git/commits', '--input', '-', '--jq', '.sha'], - { cwd: rootDir, input: commitBody }, - ); - - const refBody = JSON.stringify({ sha: apiCommitSha, force: true }); - await runArgsAsync(['gh', 'api', `repos/{owner}/{repo}/git/refs/heads/${branch}`, '-X', 'PATCH', '--input', '-'], { - cwd: rootDir, - input: refBody, - }); - - log.dim(' Re-pushed commit via GitHub API to trigger workflow runs'); +function pushWithToken(rootDir: string, branch: string): void { + const token = process.env.BUMPY_GH_TOKEN; + const repo = process.env.GITHUB_REPOSITORY; // e.g. "owner/repo" + const server = process.env.GITHUB_SERVER_URL || 'https://github.com'; + + if (token && repo) { + const authedUrl = `${server.replace('://', `://x-access-token:${token}@`)}/${repo}.git`; + // Temporarily swap the remote URL so the push uses the custom token + const originalUrl = tryRunArgs(['git', 'remote', 'get-url', 'origin'], { cwd: rootDir }); + try { + runArgs(['git', 'remote', 'set-url', 'origin', authedUrl], { cwd: rootDir }); + runArgs(['git', 'push', '-u', 'origin', branch, '--force'], { cwd: rootDir }); + } finally { + // Restore original URL (avoid leaking the token in git config) + if (originalUrl) { + runArgs(['git', 'remote', 'set-url', 'origin', originalUrl], { cwd: rootDir }); + } + } + log.dim(' Pushed with custom token — PR workflows will be triggered'); + } else { + runArgs(['git', 'push', '-u', 'origin', branch, '--force'], { cwd: rootDir }); + if (!token) { + log.warn( + 'BUMPY_GH_TOKEN is not set — PR checks will not trigger automatically.\n' + + ' Run `bumpy ci setup` for help, or see https://bumpy.dev/docs/ci#pr-checks', + ); + } + } } // ---- version-pr mode ---- @@ -253,11 +259,7 @@ async function createVersionPr( const commitMsg = ['Version packages', '', ...plan.releases.map((r) => `${r.name}@${r.newVersion}`)].join('\n'); runArgs(['git', 'commit', '-F', '-'], { cwd: rootDir, input: commitMsg }); - // Push via git first to upload objects, then recreate the commit via the - // GitHub API and force-update the ref. Commits created through the REST API - // *do* trigger workflow runs, whereas commits pushed with GITHUB_TOKEN do not. - runArgs(['git', 'push', '-u', 'origin', branch, '--force'], { cwd: rootDir }); - await rerouteCommitViaApi(rootDir, branch, commitMsg, config); + pushWithToken(rootDir, branch); // Create or update PR const prBody = formatVersionPrBody(plan, config.versionPr.preamble); From 82453b714c8762155433f969dd578e2dd8d6b837 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 11:03:25 -0700 Subject: [PATCH 02/14] Only use BUMPY_GH_TOKEN for git push, not gh CLI calls Keep PR comments and other gh CLI operations using the default GH_TOKEN (GitHub Actions bot) so they aren't attributed to the PAT owner. Users can opt in by setting GH_TOKEN directly. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/bumpy/src/commands/ci.ts b/packages/bumpy/src/commands/ci.ts index 95ae13b..2691d07 100644 --- a/packages/bumpy/src/commands/ci.ts +++ b/packages/bumpy/src/commands/ci.ts @@ -115,12 +115,6 @@ interface ReleaseOptions { * Designed for merge-to-main workflows. */ export async function ciReleaseCommand(rootDir: string, opts: ReleaseOptions): Promise { - // If a custom token is provided, also expose it as GH_TOKEN so that - // `gh` CLI calls (PR creation, comments, etc.) use the same credential. - if (process.env.BUMPY_GH_TOKEN) { - process.env.GH_TOKEN = process.env.BUMPY_GH_TOKEN; - } - const config = await loadConfig(rootDir); ensureGitIdentity(rootDir, config); const { packages } = await discoverWorkspace(rootDir, config); From 4d632335f519587157b2b568e1249613684b86f2 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 11:04:21 -0700 Subject: [PATCH 03/14] Clear checkout extraheader before pushing with custom token actions/checkout sets http.extraheader with the default GITHUB_TOKEN, which takes precedence over URL-embedded credentials. Temporarily unset it during the push so BUMPY_GH_TOKEN is actually used, then restore it afterward. This avoids requiring persist-credentials: false. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/bumpy/src/commands/ci.ts b/packages/bumpy/src/commands/ci.ts index 2691d07..9fb5e3a 100644 --- a/packages/bumpy/src/commands/ci.ts +++ b/packages/bumpy/src/commands/ci.ts @@ -184,16 +184,27 @@ function pushWithToken(rootDir: string, branch: string): void { if (token && repo) { const authedUrl = `${server.replace('://', `://x-access-token:${token}@`)}/${repo}.git`; - // Temporarily swap the remote URL so the push uses the custom token const originalUrl = tryRunArgs(['git', 'remote', 'get-url', 'origin'], { cwd: rootDir }); + + // `actions/checkout` sets an http.extraheader with the default GITHUB_TOKEN. + // That header takes precedence over URL-embedded credentials, so we need to + // clear it temporarily for our custom token to be used. + const extraHeaderKey = `http.${server}/.extraheader`; + const savedHeader = tryRunArgs(['git', 'config', '--local', extraHeaderKey], { cwd: rootDir }); try { + if (savedHeader) { + runArgs(['git', 'config', '--local', '--unset-all', extraHeaderKey], { cwd: rootDir }); + } runArgs(['git', 'remote', 'set-url', 'origin', authedUrl], { cwd: rootDir }); runArgs(['git', 'push', '-u', 'origin', branch, '--force'], { cwd: rootDir }); } finally { - // Restore original URL (avoid leaking the token in git config) + // Restore original URL and extraheader (avoid leaking the token in git config) if (originalUrl) { runArgs(['git', 'remote', 'set-url', 'origin', originalUrl], { cwd: rootDir }); } + if (savedHeader) { + runArgs(['git', 'config', '--local', extraHeaderKey, savedHeader], { cwd: rootDir }); + } } log.dim(' Pushed with custom token — PR workflows will be triggered'); } else { From 252773609238cf1db5a4f32d6bf706d12f389182 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 11:17:33 -0700 Subject: [PATCH 04/14] Make PAT the recommended option in ci setup Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci-setup.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bumpy/src/commands/ci-setup.ts b/packages/bumpy/src/commands/ci-setup.ts index dba4cd3..515aa30 100644 --- a/packages/bumpy/src/commands/ci-setup.ts +++ b/packages/bumpy/src/commands/ci-setup.ts @@ -34,12 +34,12 @@ export async function ciSetupCommand(rootDir: string): Promise { { label: 'Fine-grained Personal Access Token (PAT)', value: 'pat' as const, - hint: 'simplest setup', + hint: 'recommended — quick and simple', }, { label: 'GitHub App installation token', value: 'app' as const, - hint: 'recommended for orgs / shared repos', + hint: 'advanced — better for orgs with many repos', }, ], }), From be05db24bfbb351d3424c8b6ade5a15bb8f4a88e Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 13:16:42 -0700 Subject: [PATCH 05/14] Tweak GitHub App hint text in ci setup Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci-setup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bumpy/src/commands/ci-setup.ts b/packages/bumpy/src/commands/ci-setup.ts index 515aa30..13283bb 100644 --- a/packages/bumpy/src/commands/ci-setup.ts +++ b/packages/bumpy/src/commands/ci-setup.ts @@ -39,7 +39,7 @@ export async function ciSetupCommand(rootDir: string): Promise { { label: 'GitHub App installation token', value: 'app' as const, - hint: 'advanced — better for orgs with many repos', + hint: 'advanced — not tied to a personal account', }, ], }), From b545866e2c4c7ab207bd0b31b0c4133157fa48c7 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 13:27:15 -0700 Subject: [PATCH 06/14] Add resource owner and expiration steps to PAT setup instructions Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci-setup.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/bumpy/src/commands/ci-setup.ts b/packages/bumpy/src/commands/ci-setup.ts index 13283bb..e0af652 100644 --- a/packages/bumpy/src/commands/ci-setup.ts +++ b/packages/bumpy/src/commands/ci-setup.ts @@ -64,13 +64,18 @@ async function setupPat(rootDir: string, repo: string): Promise { '', `2. Set a name, e.g. ${pc.dim('"bumpy-ci"')}`, '', - `3. Under ${pc.bold('Repository access')}, select ${pc.bold('"Only select repositories"')}`, + `3. Under ${pc.bold('Resource owner')}, select the org or account that owns ${pc.cyan(repo)}`, + '', + `4. Set ${pc.bold('Expiration')} — choose a longer duration to avoid frequent rotation`, + ` (you'll need to regenerate and update the secret when it expires)`, + '', + `5. Under ${pc.bold('Repository access')}, select ${pc.bold('"Only select repositories"')}`, ` and choose ${pc.cyan(repo)}`, '', - `4. Under ${pc.bold('Permissions → Repository permissions')}, grant:`, + `6. Under ${pc.bold('Permissions → Repository permissions')}, grant:`, ...PAT_PERMISSIONS.map((perm) => ` • ${pc.bold(perm)}`), '', - '5. Click "Generate token" and copy the value', + '7. Click "Generate token" and copy the value', ].join('\n'), 'Create a fine-grained PAT', ); From 0326c724c5ae12b39476d1aa51274049f5e184d6 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 13:29:32 -0700 Subject: [PATCH 07/14] Remove redundant GH_TOKEN from workflow snippets and release config gh CLI auto-detects GITHUB_TOKEN in GitHub Actions, so explicitly setting GH_TOKEN is unnecessary. Users only need BUMPY_GH_TOKEN. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/release.yaml | 2 +- packages/bumpy/src/commands/ci-setup.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b639e84..897ec0a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,4 +25,4 @@ jobs: - run: bun install - run: bunx @varlock/bumpy ci release env: - GH_TOKEN: ${{ github.token }} + BUMPY_GH_TOKEN: ${{ secrets.BUMPY_GH_TOKEN }} diff --git a/packages/bumpy/src/commands/ci-setup.ts b/packages/bumpy/src/commands/ci-setup.ts index e0af652..014faf5 100644 --- a/packages/bumpy/src/commands/ci-setup.ts +++ b/packages/bumpy/src/commands/ci-setup.ts @@ -208,7 +208,6 @@ function printPatWorkflowSnippet(): void { pc.dim('# .github/workflows/release.yaml'), '- run: bunx @varlock/bumpy ci release', ' env:', - ' GH_TOKEN: ${{ github.token }}', ` ${pc.bold('BUMPY_GH_TOKEN: ${{ secrets.BUMPY_GH_TOKEN }}')}`, ].join('\n'), 'Update your workflow', @@ -229,7 +228,6 @@ function printAppWorkflowSnippet(): void { '', '- run: bunx @varlock/bumpy ci release', ' env:', - ' GH_TOKEN: ${{ github.token }}', ` ${pc.bold('BUMPY_GH_TOKEN: ${{ steps.app-token.outputs.token }}')}`, ].join('\n'), 'Update your workflow', From 9b9c5c7e4fca7ec8d2917312943dd9408b6f21ec Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 13:31:10 -0700 Subject: [PATCH 08/14] Highlight new lines in green, dim existing lines in workflow snippets Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci-setup.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/bumpy/src/commands/ci-setup.ts b/packages/bumpy/src/commands/ci-setup.ts index 014faf5..3926ce6 100644 --- a/packages/bumpy/src/commands/ci-setup.ts +++ b/packages/bumpy/src/commands/ci-setup.ts @@ -206,9 +206,9 @@ function printPatWorkflowSnippet(): void { 'In your release workflow, pass the token to bumpy:', '', pc.dim('# .github/workflows/release.yaml'), - '- run: bunx @varlock/bumpy ci release', - ' env:', - ` ${pc.bold('BUMPY_GH_TOKEN: ${{ secrets.BUMPY_GH_TOKEN }}')}`, + pc.dim('- run: bunx @varlock/bumpy ci release'), + pc.dim(' env:'), + pc.green(' BUMPY_GH_TOKEN: ${{ secrets.BUMPY_GH_TOKEN }}'), ].join('\n'), 'Update your workflow', ); @@ -220,15 +220,15 @@ function printAppWorkflowSnippet(): void { 'In your release workflow, generate a token and pass it to bumpy:', '', pc.dim('# .github/workflows/release.yaml'), - '- uses: actions/create-github-app-token@v2', - ' id: app-token', - ' with:', - ' app-id: ${{ secrets.BUMPY_APP_ID }}', - ' private-key: ${{ secrets.BUMPY_APP_PRIVATE_KEY }}', + pc.green('- uses: actions/create-github-app-token@v2'), + pc.green(' id: app-token'), + pc.green(' with:'), + pc.green(' app-id: ${{ secrets.BUMPY_APP_ID }}'), + pc.green(' private-key: ${{ secrets.BUMPY_APP_PRIVATE_KEY }}'), '', - '- run: bunx @varlock/bumpy ci release', - ' env:', - ` ${pc.bold('BUMPY_GH_TOKEN: ${{ steps.app-token.outputs.token }}')}`, + pc.dim('- run: bunx @varlock/bumpy ci release'), + pc.dim(' env:'), + pc.green(' BUMPY_GH_TOKEN: ${{ steps.app-token.outputs.token }}'), ].join('\n'), 'Update your workflow', ); From 38227b46e4a2772a44f3bf53a1c4ad9cc2fb7aee Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 13:33:47 -0700 Subject: [PATCH 09/14] Use detected package manager in ci setup workflow snippets Detect bun/pnpm/yarn/npm and show the appropriate run command in workflow examples instead of hardcoding bunx. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci-setup.ts | 43 ++++++++++++++++--------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/packages/bumpy/src/commands/ci-setup.ts b/packages/bumpy/src/commands/ci-setup.ts index 3926ce6..757a381 100644 --- a/packages/bumpy/src/commands/ci-setup.ts +++ b/packages/bumpy/src/commands/ci-setup.ts @@ -2,6 +2,8 @@ import pc from 'picocolors'; import { log } from '../utils/logger.ts'; import { p, unwrap } from '../utils/clack.ts'; import { tryRunArgs } from '../utils/shell.ts'; +import { detectPackageManager } from '../utils/package-manager.ts'; +import type { PackageManager } from '../types.ts'; const PAT_PERMISSIONS = [ 'contents: read & write', @@ -12,12 +14,13 @@ const PAT_PERMISSIONS = [ export async function ciSetupCommand(rootDir: string): Promise { p.intro(pc.bgCyan(pc.black(' bumpy ci setup '))); - // Detect repo context + // Detect repo and package manager context const repo = detectRepo(rootDir); if (!repo) { log.error('Could not detect GitHub repository. Run this from a repo with a GitHub remote.'); process.exit(1); } + const pm = await detectPackageManager(rootDir); p.log.info(`Detected repository: ${pc.cyan(repo)}`); p.log.info(''); @@ -46,15 +49,15 @@ export async function ciSetupCommand(rootDir: string): Promise { ); if (method === 'pat') { - await setupPat(rootDir, repo); + await setupPat(rootDir, repo, pm); } else { - await setupApp(rootDir, repo); + await setupApp(rootDir, repo, pm); } } // ---- PAT flow ---- -async function setupPat(rootDir: string, repo: string): Promise { +async function setupPat(rootDir: string, repo: string, pm: PackageManager): Promise { const patUrl = 'https://github.com/settings/personal-access-tokens/new'; p.log.info(''); @@ -98,12 +101,12 @@ async function setupPat(rootDir: string, repo: string): Promise { }), ); - await storeSecret(rootDir, repo, token); + await storeSecret(rootDir, repo, token, pm); } // ---- GitHub App flow ---- -async function setupApp(rootDir: string, repo: string): Promise { +async function setupApp(rootDir: string, repo: string, pm: PackageManager): Promise { const owner = repo.split('/')[0]!; const appUrl = `https://github.com/organizations/${owner}/settings/apps/new`; const personalAppUrl = `https://github.com/settings/apps/new`; @@ -152,10 +155,10 @@ async function setupApp(rootDir: string, repo: string): Promise { ); if (hasSecrets) { - printAppWorkflowSnippet(); + printAppWorkflowSnippet(pm); } else { p.log.info('You can add them later. Once ready, update your release workflow:'); - printAppWorkflowSnippet(); + printAppWorkflowSnippet(pm); } p.outro(pc.green('GitHub App setup complete!')); @@ -163,7 +166,7 @@ async function setupApp(rootDir: string, repo: string): Promise { // ---- Shared helpers ---- -async function storeSecret(rootDir: string, repo: string, token: string): Promise { +async function storeSecret(rootDir: string, repo: string, token: string, pm: PackageManager): Promise { const hasGh = tryRunArgs(['gh', '--version']); if (!hasGh) { p.log.warn("`gh` CLI not found — you'll need to add the secret manually."); @@ -172,7 +175,7 @@ async function storeSecret(rootDir: string, repo: string, token: string): Promis `Name: ${pc.bold('BUMPY_GH_TOKEN')}\nValue: (the token you just created)`, 'Add repository secret manually', ); - printPatWorkflowSnippet(); + printPatWorkflowSnippet(pm); p.outro(pc.green('Setup complete!')); return; } @@ -196,17 +199,18 @@ async function storeSecret(rootDir: string, repo: string, token: string): Promis ); } - printPatWorkflowSnippet(); + printPatWorkflowSnippet(pm); p.outro(pc.green('Setup complete!')); } -function printPatWorkflowSnippet(): void { +function printPatWorkflowSnippet(pm: PackageManager): void { + const runCmd = pmxCommand(pm); p.note( [ 'In your release workflow, pass the token to bumpy:', '', pc.dim('# .github/workflows/release.yaml'), - pc.dim('- run: bunx @varlock/bumpy ci release'), + pc.dim(`- run: ${runCmd} ci release`), pc.dim(' env:'), pc.green(' BUMPY_GH_TOKEN: ${{ secrets.BUMPY_GH_TOKEN }}'), ].join('\n'), @@ -214,7 +218,8 @@ function printPatWorkflowSnippet(): void { ); } -function printAppWorkflowSnippet(): void { +function printAppWorkflowSnippet(pm: PackageManager): void { + const runCmd = pmxCommand(pm); p.note( [ 'In your release workflow, generate a token and pass it to bumpy:', @@ -226,7 +231,7 @@ function printAppWorkflowSnippet(): void { pc.green(' app-id: ${{ secrets.BUMPY_APP_ID }}'), pc.green(' private-key: ${{ secrets.BUMPY_APP_PRIVATE_KEY }}'), '', - pc.dim('- run: bunx @varlock/bumpy ci release'), + pc.dim(`- run: ${runCmd} ci release`), pc.dim(' env:'), pc.green(' BUMPY_GH_TOKEN: ${{ steps.app-token.outputs.token }}'), ].join('\n'), @@ -234,6 +239,14 @@ function printAppWorkflowSnippet(): void { ); } +/** Package-manager-appropriate command for running bumpy in CI workflows */ +function pmxCommand(pm: PackageManager): string { + if (pm === 'bun') return 'bunx @varlock/bumpy'; + if (pm === 'pnpm') return 'pnpm exec bumpy'; + if (pm === 'yarn') return 'yarn bumpy'; + return 'npx @varlock/bumpy'; +} + function detectRepo(rootDir: string): string | null { // Check GitHub Actions env first if (process.env.GITHUB_REPOSITORY) return process.env.GITHUB_REPOSITORY; From 08916b61d60060e1c2267903b7818de8731df684 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 13:42:30 -0700 Subject: [PATCH 10/14] Add branch protection tip to PAT setup instructions Remind users to enable branch protection on main so the PAT can only be used to push the version branch, not write directly. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci-setup.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/bumpy/src/commands/ci-setup.ts b/packages/bumpy/src/commands/ci-setup.ts index 757a381..b424e8b 100644 --- a/packages/bumpy/src/commands/ci-setup.ts +++ b/packages/bumpy/src/commands/ci-setup.ts @@ -79,6 +79,9 @@ async function setupPat(rootDir: string, repo: string, pm: PackageManager): Prom ...PAT_PERMISSIONS.map((perm) => ` • ${pc.bold(perm)}`), '', '7. Click "Generate token" and copy the value', + '', + pc.dim('Tip: enable branch protection rules on your main branch to prevent'), + pc.dim('direct pushes — the PAT will only be used to push the version branch.'), ].join('\n'), 'Create a fine-grained PAT', ); From 88a9dc5301fa4d7118a0a1a6983606b2e115bfa6 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 13:48:28 -0700 Subject: [PATCH 11/14] Detect existing secret and adjust messaging when replacing Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci-setup.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/bumpy/src/commands/ci-setup.ts b/packages/bumpy/src/commands/ci-setup.ts index b424e8b..061259f 100644 --- a/packages/bumpy/src/commands/ci-setup.ts +++ b/packages/bumpy/src/commands/ci-setup.ts @@ -183,15 +183,21 @@ async function storeSecret(rootDir: string, repo: string, token: string, pm: Pac return; } + // Check if the secret already exists + const existingSecrets = tryRunArgs(['gh', 'secret', 'list', '--repo', repo], { cwd: rootDir }); + const isReplacing = existingSecrets?.includes('BUMPY_GH_TOKEN') ?? false; + const spin = p.spinner(); - spin.start('Storing BUMPY_GH_TOKEN as a repository secret...'); + spin.start( + isReplacing ? 'Replacing BUMPY_GH_TOKEN repository secret...' : 'Storing BUMPY_GH_TOKEN as a repository secret...', + ); try { - // gh secret set reads from stdin + // gh secret set reads from stdin and overwrites if the secret already exists tryRunArgs(['gh', 'secret', 'set', 'BUMPY_GH_TOKEN', '--repo', repo], { cwd: rootDir, input: token, } as any); - spin.stop('Secret stored!'); + spin.stop(isReplacing ? 'Secret replaced!' : 'Secret stored!'); } catch { spin.stop('Failed to store secret'); p.log.warn('Could not store the secret automatically.'); From cf85d524668d59ccf9fe2388faf15d6bfce630f2 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 13:49:21 -0700 Subject: [PATCH 12/14] Improve non-GitHub handling in ci setup and push Clarify that ci setup only supports GitHub-hosted repos. Only show the BUMPY_GH_TOKEN warning when running on GitHub Actions, since other CI providers don't have the same anti-recursion limitation. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci-setup.ts | 6 +++++- packages/bumpy/src/commands/ci.ts | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/bumpy/src/commands/ci-setup.ts b/packages/bumpy/src/commands/ci-setup.ts index 061259f..bee77d2 100644 --- a/packages/bumpy/src/commands/ci-setup.ts +++ b/packages/bumpy/src/commands/ci-setup.ts @@ -17,7 +17,11 @@ export async function ciSetupCommand(rootDir: string): Promise { // Detect repo and package manager context const repo = detectRepo(rootDir); if (!repo) { - log.error('Could not detect GitHub repository. Run this from a repo with a GitHub remote.'); + log.error( + 'Could not detect a GitHub repository.\n' + + ' This command currently only supports GitHub-hosted repos.\n' + + ' Make sure you have a GitHub remote (git remote -v).', + ); process.exit(1); } const pm = await detectPackageManager(rootDir); diff --git a/packages/bumpy/src/commands/ci.ts b/packages/bumpy/src/commands/ci.ts index 9fb5e3a..8c4fad8 100644 --- a/packages/bumpy/src/commands/ci.ts +++ b/packages/bumpy/src/commands/ci.ts @@ -209,7 +209,8 @@ function pushWithToken(rootDir: string, branch: string): void { log.dim(' Pushed with custom token — PR workflows will be triggered'); } else { runArgs(['git', 'push', '-u', 'origin', branch, '--force'], { cwd: rootDir }); - if (!token) { + if (!token && repo) { + // Only warn on GitHub Actions — other CI providers don't have this limitation log.warn( 'BUMPY_GH_TOKEN is not set — PR checks will not trigger automatically.\n' + ' Run `bumpy ci setup` for help, or see https://bumpy.dev/docs/ci#pr-checks', From 570627eca6e00b3c6b8e23d6a10182372de1b951 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 13:56:43 -0700 Subject: [PATCH 13/14] Change bump type to patch Co-Authored-By: Claude Opus 4.6 (1M context) --- .bumpy/fix-version-pr-ci-triggers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bumpy/fix-version-pr-ci-triggers.md b/.bumpy/fix-version-pr-ci-triggers.md index 8c2b571..40ac948 100644 --- a/.bumpy/fix-version-pr-ci-triggers.md +++ b/.bumpy/fix-version-pr-ci-triggers.md @@ -1,5 +1,5 @@ --- -'@varlock/bumpy': minor +'@varlock/bumpy': patch --- Support custom token for triggering CI on version PRs From 05a222309b7129311d2486b301b65a41af3fd1fe Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 15 Apr 2026 13:59:14 -0700 Subject: [PATCH 14/14] Remove made-up docs URL from warning message Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/bumpy/src/commands/ci.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/bumpy/src/commands/ci.ts b/packages/bumpy/src/commands/ci.ts index 8c4fad8..4fd28cf 100644 --- a/packages/bumpy/src/commands/ci.ts +++ b/packages/bumpy/src/commands/ci.ts @@ -212,8 +212,7 @@ function pushWithToken(rootDir: string, branch: string): void { if (!token && repo) { // Only warn on GitHub Actions — other CI providers don't have this limitation log.warn( - 'BUMPY_GH_TOKEN is not set — PR checks will not trigger automatically.\n' + - ' Run `bumpy ci setup` for help, or see https://bumpy.dev/docs/ci#pr-checks', + 'BUMPY_GH_TOKEN is not set — PR checks will not trigger automatically.\n' + ' Run `bumpy ci setup` for help.', ); } }