mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Added createGithubReleases input option (defaults to true) to control whether to create Github releases during publish or not (#130)
* allow skipping creation of Github releases * fixes for PR review * minor improvements * add changeset * nits Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
This commit is contained in:
co-authored by
Mateusz Burzyński
parent
f4afbea27e
commit
5c0997b25e
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@changesets/action": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Added `createGithubReleases` input option (defaults to `true`) to control whether to create Github releases during publish or not.
|
||||||
@@ -21,6 +21,10 @@ inputs:
|
|||||||
description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
|
description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
|
||||||
required: false
|
required: false
|
||||||
default: true
|
default: true
|
||||||
|
createGithubReleases:
|
||||||
|
description: "A boolean value to indicate whether to create Github releases after `publish` or not"
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
outputs:
|
outputs:
|
||||||
published:
|
published:
|
||||||
description: A boolean value to indicate whether a publishing is happened or not
|
description: A boolean value to indicate whether a publishing is happened or not
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
|
|||||||
const result = await runPublish({
|
const result = await runPublish({
|
||||||
script: publishScript,
|
script: publishScript,
|
||||||
githubToken,
|
githubToken,
|
||||||
|
createGithubReleases: core.getBooleanInput("createGithubReleases"),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.published) {
|
if (result.published) {
|
||||||
|
|||||||
+18
-12
@@ -51,6 +51,7 @@ const createRelease = async (
|
|||||||
type PublishOptions = {
|
type PublishOptions = {
|
||||||
script: string;
|
script: string;
|
||||||
githubToken: string;
|
githubToken: string;
|
||||||
|
createGithubReleases: boolean;
|
||||||
cwd?: string;
|
cwd?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ type PublishResult =
|
|||||||
export async function runPublish({
|
export async function runPublish({
|
||||||
script,
|
script,
|
||||||
githubToken,
|
githubToken,
|
||||||
|
createGithubReleases,
|
||||||
cwd = process.cwd(),
|
cwd = process.cwd(),
|
||||||
}: PublishOptions): Promise<PublishResult> {
|
}: PublishOptions): Promise<PublishResult> {
|
||||||
let octokit = github.getOctokit(githubToken);
|
let octokit = github.getOctokit(githubToken);
|
||||||
@@ -104,14 +106,16 @@ export async function runPublish({
|
|||||||
releasedPackages.push(pkg);
|
releasedPackages.push(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(
|
if (createGithubReleases) {
|
||||||
releasedPackages.map((pkg) =>
|
await Promise.all(
|
||||||
createRelease(octokit, {
|
releasedPackages.map((pkg) =>
|
||||||
pkg,
|
createRelease(octokit, {
|
||||||
tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`,
|
pkg,
|
||||||
})
|
tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`,
|
||||||
)
|
})
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (packages.length === 0) {
|
if (packages.length === 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -127,10 +131,12 @@ export async function runPublish({
|
|||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
releasedPackages.push(pkg);
|
releasedPackages.push(pkg);
|
||||||
await createRelease(octokit, {
|
if (createGithubReleases) {
|
||||||
pkg,
|
await createRelease(octokit, {
|
||||||
tagName: `v${pkg.packageJson.version}`,
|
pkg,
|
||||||
});
|
tagName: `v${pkg.packageJson.version}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user