mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
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:
+13
-1
@@ -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({
|
||||
script: publishScript,
|
||||
github,
|
||||
createGithubReleases: core.getBooleanInput("create-github-releases"),
|
||||
createGithubReleases,
|
||||
pushGitTags,
|
||||
cwd,
|
||||
});
|
||||
|
||||
|
||||
@@ -20,6 +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 = 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();
|
||||
@@ -39,6 +48,7 @@ async function main() {
|
||||
script,
|
||||
github,
|
||||
createGithubReleases,
|
||||
pushGitTags,
|
||||
cwd,
|
||||
fromPackDir,
|
||||
});
|
||||
|
||||
+13
-5
@@ -65,6 +65,7 @@ type PublishOptions = {
|
||||
script?: string;
|
||||
fromPackDir?: string;
|
||||
createGithubReleases: boolean;
|
||||
pushGitTags: boolean;
|
||||
github: GitHub;
|
||||
cwd: string;
|
||||
};
|
||||
@@ -87,6 +88,7 @@ export async function runPublish({
|
||||
fromPackDir,
|
||||
github,
|
||||
createGithubReleases,
|
||||
pushGitTags,
|
||||
cwd,
|
||||
}: PublishOptions): Promise<PublishResult> {
|
||||
const { octokit } = github;
|
||||
@@ -137,12 +139,16 @@ export async function runPublish({
|
||||
releasedPackages.push(pkg);
|
||||
}
|
||||
|
||||
if (createGithubReleases) {
|
||||
if (createGithubReleases || pushGitTags) {
|
||||
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 (pushGitTags) {
|
||||
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 (pushGitTags) {
|
||||
await github.pushTag(tagName);
|
||||
}
|
||||
if (createGithubReleases) {
|
||||
await createRelease(octokit, { pkg, tagName });
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user