Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added makeGitHubReleasesLatest input #385

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tiny-boxes-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/action": minor
---

Added `makeGitHubReleasesLatest` input which controls whether created GitHub releases are marked as latest or not
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const setupOctokit = (githubToken: string) => {

const createRelease = async (
octokit: ReturnType<typeof setupOctokit>,
{ pkg, tagName }: { pkg: Package; tagName: string }
{ pkg, tagName, makeLatest }: { pkg: Package; tagName: string; makeLatest: boolean }
) => {
try {
let changelogFileName = path.join(pkg.dir, "CHANGELOG.md");
Expand All @@ -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) {
Expand All @@ -100,6 +101,7 @@ type PublishOptions = {
script: string;
githubToken: string;
createGithubReleases: boolean;
makeGitHubReleasesLatest: boolean;
cwd?: string;
};

Expand All @@ -118,6 +120,7 @@ export async function runPublish({
script,
githubToken,
createGithubReleases,
makeGitHubReleasesLatest,
cwd = process.cwd(),
}: PublishOptions): Promise<PublishResult> {
const octokit = setupOctokit(githubToken);
Expand Down Expand Up @@ -161,6 +164,7 @@ export async function runPublish({
createRelease(octokit, {
pkg,
tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`,
makeLatest: makeGitHubReleasesLatest,
})
)
);
Expand All @@ -184,6 +188,7 @@ export async function runPublish({
await createRelease(octokit, {
pkg,
tagName: `v${pkg.packageJson.version}`,
makeLatest: makeGitHubReleasesLatest,
});
}
break;
Expand Down