Add support for creating pre-release tags from last stable tag #14
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.
This change enhances the
autotag
package to support including pre-releaseinformation on to a generated tag. This functionality is being added to
facilitate the tagging of releases that aren't considered ready for stable
release, while being able to generate a tag that's useful for humans and
automated tooling.
Note: this change introduces a breaking API change to the
NewRepo()
function. Instead of taking two string parameters, the function now takes an
autotag.GitRepoConfig
instance. This is because we added two new user-providedparameters to the
GitRepo
struct.In our organization, we have the need to create releases from branches before
the merge to the stable (
master
) branch happens. This need isn't part of ournormal release workflow, and is reserved for situations where a release is
needed from a branch (think hotfix, or similar).
To accomplish the creation of pre-release tags, we added two new parameters that
can be used to configure the GitRepo:
NAME
to use in the tag (e.g.,v1.2.3-NAME
)LAYOUT
to use to generate the timestamp (e.g.,v1.2.3-LAYOUT
) -- this a layout string from thetime
packageIf either of these values are set, or both, a hyphen is added to the tag and the
respective values are added to the end of the tag. If these two values are
combined, and name is
test
and the layout isepoch
, the tag would looksomething like
v1.2.4-test.1499323531
.Within the
autotag
package itself, this is done by calculating the new stabletag (e.g.,
v1.2.4
) and then appending the pre-release information to the endof it. The
autotag
code path that determines the latest tag now explicitlyskips over tags with pre-release information attached. This is to ensure our
pre-release tags are only cut from stable ones.
Within the
autotag
binary, two more command line flags have been added:The
-p
flag allows users to specify the pre-release-name. While theautotag
package allows us to specify any string we want, the
autotag
binary onlyaccepts a subset of values to use (to promote good practices). The help output
lists the possible values.
The
-T
flag supports either setting adatetime
(YYYYMMDDHHMMSS
) timestamp,or a UNIX
epoch
timestamp.Here is an example of them being used:
In addition to the changes made, extra tests were added to assert the new
functionality of the package. None of the older tests were changed, which
indicates the behavior of the
autotag
binary should be backwards compatiblewith previous versions.
Signed-off-by: Tim Heckman t@heckman.io
This change is