diff --git a/hack/build b/hack/build index f8cac9889845..5487230d6d15 100755 --- a/hack/build +++ b/hack/build @@ -8,7 +8,12 @@ set -e : "${REVISION=$(./hack/git-meta revision)}" : "${PRERELEASE=$(./hack/git-meta version | rev | cut -c3- | rev | cut -d'-' -f 2 | grep -E '(^tp|^rc).*')}" : "${REVISION_NUMBER=1}" -VERSION=$(printf "v%sm%s%s" "$(./hack/git-meta version | rev | cut -c3- | rev | cut -d'-' -f 1 | cut -c2-)" "${REVISION_NUMBER}" "-${PRERELEASE}") + +if [ -n "$PRERELEASE" ]; then + PRERELEASE="-$PRERELEASE" +fi + +VERSION=$(printf "v%sm%s%s" "$(./hack/git-meta version | rev | cut -c3- | rev | cut -d'-' -f 1 | cut -c2-)" "${REVISION_NUMBER}" "${PRERELEASE}") : "${CGO_ENABLED=0}" : "${GO_PKG=github.com/docker/buildx}" diff --git a/tests/version.go b/tests/version.go index da3cfdbf6e7a..a18a1796a244 100644 --- a/tests/version.go +++ b/tests/version.go @@ -45,8 +45,8 @@ func testVersion(t *testing.T, sb integration.Sandbox) { // This defaults to something that's still compatible // with semver. version := fields[1] - regex, err := regexp.CompilePOSIX("^v[0-9]+.[0-9]+.[0-9]+(m[0-9]+|m[0-9]+-rc[0-9]+|m[0-9]+-tp[0-9]+)$") - require.True(t, err == nil && regex.MatchString(version), "Second field was not valid: %+v", version) + regex := regexp.MustCompilePOSIX("^v[0-9]+.[0-9]+.[0-9]+(m[0-9]+|m[0-9]+-rc[0-9]+|m[0-9]+-tp[0-9]+)$") + require.True(t, regex.MatchString(version), "Second field was not valid: %+v", version) // Revision should be empty or should look like a git hash. if len(fields) > 2 && len(fields[2]) > 0 {