From bcfb9623de6fd1c19dde8a7a96111e32cfeb0d9c Mon Sep 17 00:00:00 2001 From: galargh Date: Wed, 31 Jul 2024 11:33:33 +0100 Subject: [PATCH] Added makeGitHubReleasesLatest input --- .changeset/tiny-boxes-visit.md | 5 +++++ README.md | 1 + action.yml | 4 ++++ src/index.ts | 1 + src/run.ts | 7 ++++++- 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .changeset/tiny-boxes-visit.md diff --git a/.changeset/tiny-boxes-visit.md b/.changeset/tiny-boxes-visit.md new file mode 100644 index 00000000..cc0f9bee --- /dev/null +++ b/.changeset/tiny-boxes-visit.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": minor +--- + +Added `makeGitHubReleasesLatest` input which controls whether created GitHub releases are marked as latest or not diff --git a/README.md b/README.md index cc7f703b..3ea32601 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ This action for [Changesets](https://github.com/atlassian/changesets) creates a - title - The pull request title. Default to `Version Packages` - setupGitUser - Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` - createGithubReleases - A boolean value to indicate whether to create Github releases after `publish` or not. Default to `true` +- makeGitHubReleasesLatest - A boolean value to indicate whether to make the created GitHub releases latest or not. Default to `true` - cwd - Changes node's `process.cwd()` if the project is not located on the root. Default to `process.cwd()` ### Outputs diff --git a/action.yml b/action.yml index 86b97909..fbf6f1b6 100644 --- a/action.yml +++ b/action.yml @@ -28,6 +28,10 @@ inputs: description: "A boolean value to indicate whether to create Github releases after `publish` or not" required: false default: true + makeGitHubReleasesLatest: + description: "A boolean value to indicate whether to make the created GitHub releases latest or not" + required: false + default: true branch: description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided required: false diff --git a/src/index.ts b/src/index.ts index 31aef207..41ca5f83 100644 --- a/src/index.ts +++ b/src/index.ts @@ -88,6 +88,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; script: publishScript, githubToken, createGithubReleases: core.getBooleanInput("createGithubReleases"), + makeGitHubReleasesLatest: core.getBooleanInput("makeGitHubReleasesLatest"), }); if (result.published) { diff --git a/src/run.ts b/src/run.ts index ea346bf6..9c2e732d 100644 --- a/src/run.ts +++ b/src/run.ts @@ -60,7 +60,7 @@ const setupOctokit = (githubToken: string) => { const createRelease = async ( octokit: ReturnType, - { pkg, tagName }: { pkg: Package; tagName: string } + { pkg, tagName, makeLatest }: { pkg: Package; tagName: string; makeLatest: boolean } ) => { try { let changelogFileName = path.join(pkg.dir, "CHANGELOG.md"); @@ -81,6 +81,7 @@ const createRelease = async ( tag_name: tagName, body: changelogEntry.content, prerelease: pkg.packageJson.version.includes("-"), + make_latest: makeLatest, ...github.context.repo, }); } catch (err) { @@ -100,6 +101,7 @@ type PublishOptions = { script: string; githubToken: string; createGithubReleases: boolean; + makeGitHubReleasesLatest: boolean; cwd?: string; }; @@ -118,6 +120,7 @@ export async function runPublish({ script, githubToken, createGithubReleases, + makeGitHubReleasesLatest, cwd = process.cwd(), }: PublishOptions): Promise { const octokit = setupOctokit(githubToken); @@ -161,6 +164,7 @@ export async function runPublish({ createRelease(octokit, { pkg, tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`, + makeLatest: makeGitHubReleasesLatest, }) ) ); @@ -184,6 +188,7 @@ export async function runPublish({ await createRelease(octokit, { pkg, tagName: `v${pkg.packageJson.version}`, + makeLatest: makeGitHubReleasesLatest, }); } break;