-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Output unadorned version tag for releases (#862)
There's stuff out there with pretty weird ideas as to what constitutes a "correct" version number. We have been trying to solve this problem of "incorrect versioning" for over 30 years with no success. You have to wonder why that is. For the specific case of releases, in addition to using vX.Y.Z-0-sha, also output a vX.Y.Z tag. That allows stuff to be happy about seeing something that matches its expectations in terms of version numbers. We still need to output something else in the n != 0 case, because we need to be able to differentiate between intermediate builds. It's incorrect in semver terms, because those are prereleases that sort _before_ vX.Y.Z, not after it. To do it correctly, we would have to transform vX.Y.Z to vX.Y.(Z+1) and append the prerelease bit to that. Since that would become confusing really fast (in the face of existing practice), let's not do that. As long as nothing tries to "upgrade" vX.Y.Z-n-sha to vX.Y.Z, we shoud be OK. Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>
- Loading branch information
Showing
3 changed files
with
34 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
set -u | ||
|
||
# If an optional suffix is provided, append it to all the tags as `-suffix`. | ||
# Note that this breaks the semver format, because appending -foobar means it's | ||
# a pre-release version, not a "flavor" as some people claim. The more | ||
# appropriate way to express this would be to use `+suffix`, but we'll defer | ||
# that until we have fixed the different places where this might be used. | ||
suffix=${1:+-}${1:-} | ||
|
||
rootdir=$(git rev-parse --show-toplevel) | ||
version=$("${rootdir}/scripts/version") | ||
|
||
version_base=$(echo "${version}" | cut -d- -f1) | ||
version_seq=$(echo "${version}" | cut -d- -f2) | ||
|
||
printf "%s," "latest${suffix}" | ||
printf "%s" "${version}${suffix}" | ||
if [ "${version_seq}" = "0" ]; then | ||
# Strip the additional -0-* suffix to generate a additional tag that looks like vX.Y.Z | ||
printf ",%s" "${version_base}${suffix}" | ||
fi |