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

Add support for make_latest option when creating or updating a release #283

Merged
merged 1 commit into from
Dec 11, 2022
Merged

Add support for make_latest option when creating or updating a release #283

merged 1 commit into from
Dec 11, 2022

Conversation

ericcornelissen
Copy link
Contributor

@ericcornelissen ericcornelissen commented Dec 1, 2022

Closes #268

Add a new input named makeLatest (chosen based on the official docs) to configure whether the created or updated release should be marked as "Latest" or not.

From the make_latest documentation:

Specifies whether this release should be set as the latest release for the repository. Drafts and prereleases cannot be set as latest. Defaults to true for newly published releases. legacy specifies that the latest release should be determined based on the release creation date and higher semantic version.

Default: true

Can be one of: true, false, legacy

I'm unsure about the behavior for updating a release: in particular if the default for makeLatest is true, updating a release might unexpectedly make that release the latest release?

I'm also unsure whether or not this action's documentation should include a note that "Drafts and prereleases cannot be set as latest." It seems self-evident to me so I didn't include it.

@ericcornelissen
Copy link
Contributor Author

Thanks for running the CI for this branch @ncipollo 🙂 I updated my contribution based on the CI logs:

  1. Ran yarn build and included the resulting changes.
  2. Added a test for the makeLatest input to the CoreInputs test suite to reach the coverage thresholds. Doing this made me realize my implementation was probably wrong, so changed the implementation as well.

Copy link
Owner

@ncipollo ncipollo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!!🎉

I had the following change requests:

  • I think we probably want to make this input a string to match the API.
  • I think we want to default the input to legacy so the default behavior is unchanged for folks.
  • Had a minor nitpick about method argument ordering.

src/Releases.ts Outdated Show resolved Hide resolved
src/Releases.ts Outdated
@@ -88,7 +91,8 @@ export class GithubReleases implements Releases {
prerelease: prerelease,
repo: this.inputs.repo,
target_commitish: commitHash,
tag_name: tag
tag_name: tag,
make_latest: makeLatest
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm should this be a string? The documentation indicates this should be a string with 3 values: true, false & legacy.

Copy link
Contributor Author

@ericcornelissen ericcornelissen Dec 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes sense but it looks like make_latest is not yet included in the package that provides these types (which I believe is @octokit/plugin-rest-endpoint-methods?). I tried re-installing @actions/github locally, but I still didn't get type hints for this field (currently used is v5.13.0, after re-install I got v5.16.2, but latest is v6.7.0)...

action.yml Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/Inputs.ts Outdated
@@ -136,6 +137,14 @@ export class CoreInputs implements Inputs {
return generate == 'true'
}

get makeLatest(): boolean {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a string input so we can select true, false or legacy.

Copy link
Contributor Author

@ericcornelissen ericcornelissen Dec 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updates this to return undefined if the input isn't provided. Not sure if that's what you want or if it instead should return "legacy" 🤔

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure - my guess would be undefined == legacy, so either would probably be sufficient. I can test with my playground repo and we can always change the default if it's wrong after.

@ncipollo ncipollo merged commit 0bf6967 into ncipollo:main Dec 11, 2022
@ericcornelissen ericcornelissen deleted the 268-make-latest-input branch December 11, 2022 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Explicitly Set the Latest Release
2 participants