Split git tag and github release options (#680)

* Split git tag and github release options

* Rename to push-git-tags

* Validate inputs
This commit is contained in:
Bjorn Lu
2026-07-01 07:30:13 +00:00
committed by GitHub
parent 0eae789230
commit ca57073900
6 changed files with 55 additions and 6 deletions
+7
View File
@@ -0,0 +1,7 @@
---
"@changesets/action": major
---
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 `push-git-tags` to `false` explicitly.
+6
View File
@@ -29,6 +29,12 @@ inputs:
description: "A boolean value to indicate whether to create Github releases after `publish` or not" description: "A boolean value to indicate whether to create Github releases after `publish` or not"
required: false required: false
default: true default: true
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`.
required: false
default: true
commit-mode: commit-mode:
description: > description: >
An enum to specify the commit mode. Use "git-cli" to push changes using the Git CLI, An enum to specify the commit mode. Use "git-cli" to push changes using the Git CLI,
+6
View File
@@ -18,6 +18,12 @@ inputs:
description: "Whether to create Github releases after publish" description: "Whether to create Github releases after publish"
required: false required: false
default: true default: true
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`.
required: false
default: true
outputs: outputs:
published: published:
description: "A boolean value to indicate whether a publishing has happened or not" description: "A boolean value to indicate whether a publishing has happened or not"
+13 -1
View File
@@ -122,10 +122,22 @@ import {
); );
} }
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({ const result = await runPublish({
script: publishScript, script: publishScript,
github, github,
createGithubReleases: core.getBooleanInput("create-github-releases"), createGithubReleases,
pushGitTags,
cwd, cwd,
}); });
+10
View File
@@ -20,6 +20,15 @@ async function main() {
const script = getOptionalInput("script"); const script = getOptionalInput("script");
const packDirArtifactId = getOptionalInput("pack-dir-artifact-id"); const packDirArtifactId = getOptionalInput("pack-dir-artifact-id");
const createGithubReleases = core.getBooleanInput("create-github-releases"); 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.",
);
}
// If the user needs to change the cwd, set `working-directory` in the step instead // If the user needs to change the cwd, set `working-directory` in the step instead
const cwd = process.cwd(); const cwd = process.cwd();
@@ -39,6 +48,7 @@ async function main() {
script, script,
github, github,
createGithubReleases, createGithubReleases,
pushGitTags,
cwd, cwd,
fromPackDir, fromPackDir,
}); });
+10 -2
View File
@@ -65,6 +65,7 @@ type PublishOptions = {
script?: string; script?: string;
fromPackDir?: string; fromPackDir?: string;
createGithubReleases: boolean; createGithubReleases: boolean;
pushGitTags: boolean;
github: GitHub; github: GitHub;
cwd: string; cwd: string;
}; };
@@ -87,6 +88,7 @@ export async function runPublish({
fromPackDir, fromPackDir,
github, github,
createGithubReleases, createGithubReleases,
pushGitTags,
cwd, cwd,
}: PublishOptions): Promise<PublishResult> { }: PublishOptions): Promise<PublishResult> {
const { octokit } = github; const { octokit } = github;
@@ -137,12 +139,16 @@ export async function runPublish({
releasedPackages.push(pkg); releasedPackages.push(pkg);
} }
if (createGithubReleases) { if (createGithubReleases || pushGitTags) {
await Promise.all( await Promise.all(
releasedPackages.map(async (pkg) => { releasedPackages.map(async (pkg) => {
const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`; const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`;
if (pushGitTags) {
await github.pushTag(tagName); await github.pushTag(tagName);
}
if (createGithubReleases) {
await createRelease(octokit, { pkg, tagName }); await createRelease(octokit, { pkg, tagName });
}
}), }),
); );
} }
@@ -161,9 +167,11 @@ export async function runPublish({
if (match) { if (match) {
releasedPackages.push(pkg); releasedPackages.push(pkg);
if (createGithubReleases) {
const tagName = `v${pkg.packageJson.version}`; const tagName = `v${pkg.packageJson.version}`;
if (pushGitTags) {
await github.pushTag(tagName); await github.pushTag(tagName);
}
if (createGithubReleases) {
await createRelease(octokit, { pkg, tagName }); await createRelease(octokit, { pkg, tagName });
} }
break; break;