-
Notifications
You must be signed in to change notification settings - Fork 80
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 -latest flag to specify latest release or not #152
Conversation
Sorry for the delay; thanks for the pull request. I understand the issue. It is reasonable. I will check the contents and let you know. |
Rebased from current master |
@Songmu thanks for the update. Have you had a chance to take a look at the contents? I'm open to any feedback you may have. |
any updates on this? it is a really cool feature and I'd love to see it getting merged 🥹 I have a use case where a new release containing assets is generated based on the original release, I'd like to see the original release being set as latest, not the assets one and I think this would solve that problem |
Sorry for my slow response. I'll review it this weekend ant try to merge. |
Good! Thank you. |
Merged and released as v0.17.0. Thank you! @danudey @schneiderl |
By default, creating a new release automatically sets the new release as the 'latest'. For repositories which maintain multiple version streams (e.g. v3.25.x and v3.26.x), this can result in setting the 'latest' version to the latest version of an older release stream.
Functionality
This PR adds the -latest flag, which accepts three options:
true
, the default, which always marks the release as the 'latest'false
, which never doesauto
, which does the following:tagName
from the latest release to thetagName
from the release we're about to try to createtagName
is higher, set this release as the latest; otherwise, do not.Even though I feel that
auto
is the 'correct' (or, at least, more sensible) behavior, and probably should be the default, I madetrue
the default for two main reasons:New stuff
This PR has added some other internal functionality to the tool in order to support the
auto
workflow:GetLatestRelease()
was added, which simply fetches and returns the release marked as 'latest' from the project. Note that this is whichever release is marked as 'latest', and not the most recent release chronologicallyIsNewerSemverRelease()
was added, which accepts twogithub.RepositoryRelease
objects and returns whether the first is 'newer' than the second, based on semver comparisons of theirTagName
fieldsTesting
Testing was run, including adding a new test,
TestGHR_GetLatestRelease
, forGetLatestRelease()
.Dependencies
Two changes were made to dependencies:
github.com/google/go-github
was bumped from v47 to v55 (the latest) in order to get theMakeLatest
field ongithub.RepositoryRelease
, which was necessary for this featuregithub.com/thediveo/enumflag
was added, which provides functionality to set a command-line flag which is limited to the values in an enum (in this case, 'true', 'false', and 'auto')Other notes
CREDITS
file seems to contain the licenses for every library this project uses, but I wasn't sure if this was generated automatically or not. I changed the version on thego-github
entry just as a reminder to myself, but if there's a specific way to update this file please let me know