From e942d49401d9ecb746c75f55ab31373de98d75da Mon Sep 17 00:00:00 2001 From: bluwy Date: Mon, 29 Jun 2026 10:25:38 +0800 Subject: [PATCH 1/3] Split git tag and github release options --- .changeset/chubby-geese-sink.md | 7 +++++++ action.yml | 6 ++++++ publish/action.yml | 6 ++++++ src/index.ts | 6 +++++- src/publish/index.ts | 3 +++ src/run.ts | 18 +++++++++++++----- 6 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 .changeset/chubby-geese-sink.md diff --git a/.changeset/chubby-geese-sink.md b/.changeset/chubby-geese-sink.md new file mode 100644 index 00000000..dc5617ac --- /dev/null +++ b/.changeset/chubby-geese-sink.md @@ -0,0 +1,7 @@ +--- +"@changesets/action": major +--- + +Add a new `create-git-tags` option that complements `create-github-releases` to control specifically if git tags should be created but not GitHub releases. + +If `create-github-releases` was previously set to `false`, which also indirectly disabled git tag creation, git tags will now be created instead by default. If this is not desired, set `create-git-tags` to `false` explicitly. diff --git a/action.yml b/action.yml index 8f2ccb18..9019b72b 100644 --- a/action.yml +++ b/action.yml @@ -29,6 +29,12 @@ inputs: description: "A boolean value to indicate whether to create Github releases after `publish` or not" required: false default: true + create-git-tags: + description: > + Whether to create git tags after publish. If `create-github-releases` is set to `true`, + this option will also always be `true`. + required: false + default: true commitMode: description: > An enum to specify the commit mode. Use "git-cli" to push changes using the Git CLI, diff --git a/publish/action.yml b/publish/action.yml index b90c0c54..7b19a315 100644 --- a/publish/action.yml +++ b/publish/action.yml @@ -18,6 +18,12 @@ inputs: description: "Whether to create Github releases after publish" required: false default: true + create-git-tags: + description: > + Whether to create git tags after publish. If `create-github-releases` is set to `true`, + this option will also always be `true`. + required: false + default: true outputs: published: description: "A boolean value to indicate whether a publishing has happened or not" diff --git a/src/index.ts b/src/index.ts index ef4b317e..2c8993f8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -110,10 +110,14 @@ import { fileExists, getOptionalInput } from "./utils.ts"; ); } + const createGithubReleases = core.getBooleanInput("createGithubReleases"); + const createGitTags = + createGithubReleases || core.getBooleanInput("create-git-tags"); const result = await runPublish({ script: publishScript, github, - createGithubReleases: core.getBooleanInput("createGithubReleases"), + createGithubReleases, + createGitTags, cwd, }); diff --git a/src/publish/index.ts b/src/publish/index.ts index fd6ce2d2..a38c4dbd 100644 --- a/src/publish/index.ts +++ b/src/publish/index.ts @@ -20,6 +20,8 @@ async function main() { const script = getOptionalInput("script"); const packDirArtifactId = getOptionalInput("pack-dir-artifact-id"); const createGithubReleases = core.getBooleanInput("create-github-releases"); + const createGitTags = + createGithubReleases || core.getBooleanInput("create-git-tags"); // If the user needs to change the cwd, set `working-directory` in the step instead const cwd = process.cwd(); @@ -39,6 +41,7 @@ async function main() { script, github, createGithubReleases, + createGitTags, cwd, fromPackDir, }); diff --git a/src/run.ts b/src/run.ts index 20931091..111f5fea 100644 --- a/src/run.ts +++ b/src/run.ts @@ -65,6 +65,7 @@ type PublishOptions = { script?: string; fromPackDir?: string; createGithubReleases: boolean; + createGitTags: boolean; github: GitHub; cwd: string; }; @@ -87,6 +88,7 @@ export async function runPublish({ fromPackDir, github, createGithubReleases, + createGitTags, cwd, }: PublishOptions): Promise { const { octokit } = github; @@ -137,12 +139,16 @@ export async function runPublish({ releasedPackages.push(pkg); } - if (createGithubReleases) { + if (createGithubReleases || createGitTags) { await Promise.all( releasedPackages.map(async (pkg) => { const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`; - await github.pushTag(tagName); - await createRelease(octokit, { pkg, tagName }); + if (createGitTags) { + await github.pushTag(tagName); + } + if (createGithubReleases) { + await createRelease(octokit, { pkg, tagName }); + } }), ); } @@ -161,9 +167,11 @@ export async function runPublish({ if (match) { releasedPackages.push(pkg); - if (createGithubReleases) { - const tagName = `v${pkg.packageJson.version}`; + const tagName = `v${pkg.packageJson.version}`; + if (createGitTags) { await github.pushTag(tagName); + } + if (createGithubReleases) { await createRelease(octokit, { pkg, tagName }); } break; From 5eaf46bfd97bbf1e32af05bd8e5694eb928fcf56 Mon Sep 17 00:00:00 2001 From: bluwy Date: Tue, 30 Jun 2026 09:40:51 +0800 Subject: [PATCH 2/3] Rename to push-git-tags --- .changeset/chubby-geese-sink.md | 4 ++-- action.yml | 2 +- publish/action.yml | 2 +- src/index.ts | 6 +++--- src/publish/index.ts | 6 +++--- src/run.ts | 10 +++++----- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.changeset/chubby-geese-sink.md b/.changeset/chubby-geese-sink.md index dc5617ac..c1dad759 100644 --- a/.changeset/chubby-geese-sink.md +++ b/.changeset/chubby-geese-sink.md @@ -2,6 +2,6 @@ "@changesets/action": major --- -Add a new `create-git-tags` option that complements `create-github-releases` to control specifically if git tags should be created but not GitHub releases. +Add a new `push-git-tags` option that complements `create-github-releases` to control specifically if git tags should be created but not GitHub releases. -If `create-github-releases` was previously set to `false`, which also indirectly disabled git tag creation, git tags will now be created instead by default. If this is not desired, set `create-git-tags` to `false` explicitly. +If `create-github-releases` was previously set to `false`, which also indirectly disabled git tag creation, git tags will now be created instead by default. If this is not desired, set `push-git-tags` to `false` explicitly. diff --git a/action.yml b/action.yml index 9019b72b..ed585f39 100644 --- a/action.yml +++ b/action.yml @@ -29,7 +29,7 @@ inputs: description: "A boolean value to indicate whether to create Github releases after `publish` or not" required: false default: true - create-git-tags: + push-git-tags: description: > Whether to create git tags after publish. If `create-github-releases` is set to `true`, this option will also always be `true`. diff --git a/publish/action.yml b/publish/action.yml index 7b19a315..809c5509 100644 --- a/publish/action.yml +++ b/publish/action.yml @@ -18,7 +18,7 @@ inputs: description: "Whether to create Github releases after publish" required: false default: true - create-git-tags: + push-git-tags: description: > Whether to create git tags after publish. If `create-github-releases` is set to `true`, this option will also always be `true`. diff --git a/src/index.ts b/src/index.ts index 83b652e5..4d214139 100644 --- a/src/index.ts +++ b/src/index.ts @@ -111,13 +111,13 @@ import { fileExists, getOptionalInput, getRequiredInput } from "./utils.ts"; } const createGithubReleases = core.getBooleanInput("createGithubReleases"); - const createGitTags = - createGithubReleases || core.getBooleanInput("create-git-tags"); + const pushGitTags = + createGithubReleases || core.getBooleanInput("push-git-tags"); const result = await runPublish({ script: publishScript, github, createGithubReleases, - createGitTags, + pushGitTags, cwd, }); diff --git a/src/publish/index.ts b/src/publish/index.ts index a38c4dbd..c3f9fa02 100644 --- a/src/publish/index.ts +++ b/src/publish/index.ts @@ -20,8 +20,8 @@ async function main() { const script = getOptionalInput("script"); const packDirArtifactId = getOptionalInput("pack-dir-artifact-id"); const createGithubReleases = core.getBooleanInput("create-github-releases"); - const createGitTags = - createGithubReleases || core.getBooleanInput("create-git-tags"); + const pushGitTags = + createGithubReleases || core.getBooleanInput("push-git-tags"); // If the user needs to change the cwd, set `working-directory` in the step instead const cwd = process.cwd(); @@ -41,7 +41,7 @@ async function main() { script, github, createGithubReleases, - createGitTags, + pushGitTags, cwd, fromPackDir, }); diff --git a/src/run.ts b/src/run.ts index 111f5fea..7c8b8233 100644 --- a/src/run.ts +++ b/src/run.ts @@ -65,7 +65,7 @@ type PublishOptions = { script?: string; fromPackDir?: string; createGithubReleases: boolean; - createGitTags: boolean; + pushGitTags: boolean; github: GitHub; cwd: string; }; @@ -88,7 +88,7 @@ export async function runPublish({ fromPackDir, github, createGithubReleases, - createGitTags, + pushGitTags, cwd, }: PublishOptions): Promise { const { octokit } = github; @@ -139,11 +139,11 @@ export async function runPublish({ releasedPackages.push(pkg); } - if (createGithubReleases || createGitTags) { + if (createGithubReleases || pushGitTags) { await Promise.all( releasedPackages.map(async (pkg) => { const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`; - if (createGitTags) { + if (pushGitTags) { await github.pushTag(tagName); } if (createGithubReleases) { @@ -168,7 +168,7 @@ export async function runPublish({ if (match) { releasedPackages.push(pkg); const tagName = `v${pkg.packageJson.version}`; - if (createGitTags) { + if (pushGitTags) { await github.pushTag(tagName); } if (createGithubReleases) { From 39422af4bb17640466d1c5b6239e9bf41c2a36cd Mon Sep 17 00:00:00 2001 From: bluwy Date: Tue, 30 Jun 2026 16:59:53 +0800 Subject: [PATCH 3/3] Validate inputs --- src/index.ts | 14 +++++++++++--- src/publish/index.ts | 11 +++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index ff10a5ee..aa2b5e1c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -122,9 +122,17 @@ import { ); } - const createGithubReleases = core.getBooleanInput("create-github-releases"); - const pushGitTags = - createGithubReleases || core.getBooleanInput("push-git-tags"); + const createGithubReleases = core.getBooleanInput( + "create-github-releases", + ); + const pushGitTags = core.getBooleanInput("push-git-tags"); + if (createGithubReleases && !pushGitTags) { + throw new Error( + "The input 'create-github-releases' is set to true, but 'push-git-tags' is set to false. " + + "Creating GitHub releases requires pushing git tags. Please set 'push-git-tags' to true " + + "or set 'create-github-releases' to false.", + ); + } const result = await runPublish({ script: publishScript, github, diff --git a/src/publish/index.ts b/src/publish/index.ts index c3f9fa02..15bf8ab3 100644 --- a/src/publish/index.ts +++ b/src/publish/index.ts @@ -20,8 +20,15 @@ async function main() { const script = getOptionalInput("script"); const packDirArtifactId = getOptionalInput("pack-dir-artifact-id"); const createGithubReleases = core.getBooleanInput("create-github-releases"); - const pushGitTags = - createGithubReleases || core.getBooleanInput("push-git-tags"); + const pushGitTags = core.getBooleanInput("push-git-tags"); + + if (createGithubReleases && !pushGitTags) { + throw new Error( + "The input 'create-github-releases' is set to true, but 'push-git-tags' is set to false. " + + "Creating GitHub releases requires pushing git tags. Please set 'push-git-tags' to true " + + "or set 'create-github-releases' to false.", + ); + } // If the user needs to change the cwd, set `working-directory` in the step instead const cwd = process.cwd();