diff --git a/internal/version/version.go b/internal/version/version.go index 328ab7db..e882c190 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -120,7 +120,6 @@ const ( vFmtGOARCHHdr = "GOARCH: " + runtime.GOARCH vFmtGOARMHdr = "GOARM: " vFmtGOMIPSHdr = "GOMIPS: " - vFmtMainHdr = "Main module:" vFmtDepsHdr = "Dependencies:" ) @@ -172,8 +171,6 @@ func Verbose() (v string) { return b.String() } - aghstrings.WriteToBuilder(b, nl, vFmtMainHdr, nltb, fmtModule(&info.Main)) - if len(info.Deps) == 0 { return b.String() } diff --git a/scripts/README.md b/scripts/README.md index e4e1e7f1..3ae37ef5 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -89,10 +89,11 @@ Optional environment: * `VERBOSE`: verbosity level. `1` shows every command that is run and every Go package that is processed. `2` also shows subcommands and environment. The default value is `0`, don't be verbose. + * `VERSION`: release version. Will be set by `version.sh` if it is unset or + if it has the default `Makefile` value of `v0.0.0`. Required environment: * `CHANNEL`: release channel, see above. - * `VERSION`: release version. ### `go-deps.sh`: Install Backend Dependencies diff --git a/scripts/make/build-release.sh b/scripts/make/build-release.sh index 8b6668d9..2ebde2d5 100644 --- a/scripts/make/build-release.sh +++ b/scripts/make/build-release.sh @@ -52,11 +52,10 @@ readonly channel # Check VERSION against the default value from the Makefile. If it is that, use # the version calculation script. -if [ "${VERSION:-}" = 'v0.0.0' ] || [ "${VERSION:-}" = '' ] +version="${VERSION:-}" +if [ "$version" = 'v0.0.0' ] || [ "$version" = '' ] then version="$( sh ./scripts/make/version.sh )" -else - version="$VERSION" fi readonly version diff --git a/scripts/make/go-build.sh b/scripts/make/go-build.sh index ecf572e1..da2d106e 100644 --- a/scripts/make/go-build.sh +++ b/scripts/make/go-build.sh @@ -56,10 +56,13 @@ in ;; esac -# Require the version to be set. -# -# TODO(a.garipov): Additional validation? -version="$VERSION" +# Check VERSION against the default value from the Makefile. If it is that, use +# the version calculation script. +version="${VERSION:-}" +if [ "$version" = 'v0.0.0' ] || [ "$version" = '' ] +then + version="$( sh ./scripts/make/version.sh )" +fi readonly version # Set date and time of the current build unless already set. diff --git a/scripts/make/version.sh b/scripts/make/version.sh index 51efc580..93dfef5d 100644 --- a/scripts/make/version.sh +++ b/scripts/make/version.sh @@ -84,6 +84,9 @@ in # minor release. If the current commit is the new minor release, # num_commits_since_minor is zero. num_commits_since_minor="$( git rev-list "${last_minor_zero}..HEAD" | wc -l )" + # The output of darwin's implementation of wc needs to be trimmed from + # redundant spaces. + num_commits_since_minor="$( echo ${num_commits_since_minor} | tr -d '[:space:]' )" readonly num_commits_since_minor # next_minor is the next minor release version. @@ -126,7 +129,7 @@ in esac # Finally, make sure that we don't output invalid versions. -if ! echo "$version" | grep -E -e '^v[0-9]+\.[0-9]+\.[0-9]+(-[ab]\.[0-9]+)?(\+[[:xdigit:]]+)?' -q +if ! echo "$version" | grep -E -e '^v[0-9]+\.[0-9]+\.[0-9]+(-[ab]\.[0-9]+)?(\+[[:xdigit:]]+)?$' -q then echo "generated an invalid version '$version'" 1>&2