Add -latest flag to specify latest release or not #152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.51.al/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