Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions hack/build
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ set -e
: "${PACKAGE=github.com/docker/buildx}"
: "${VERSION=$(./hack/git-meta version)}"
: "${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}"

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}"
: "${GO_EXTRA_FLAGS=}"
: "${GO_LDFLAGS=-X ${GO_PKG}/version.Version=${VERSION} -X ${GO_PKG}/version.Revision=${REVISION} -X ${GO_PKG}/version.Package=${PACKAGE}}"
: "${GO_EXTRA_LDFLAGS=}"


set -x
CGO_ENABLED=$CGO_ENABLED go build -mod vendor -trimpath ${GO_EXTRA_FLAGS} -ldflags "${GO_LDFLAGS} ${GO_EXTRA_LDFLAGS}" -o "${DESTDIR}/docker-buildx" ./cmd/buildx
5 changes: 3 additions & 2 deletions tests/version.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package tests

import (
"regexp"
"strings"
"testing"

"github.com/moby/buildkit/util/testutil/integration"
"github.com/stretchr/testify/require"
"golang.org/x/mod/module"
"golang.org/x/mod/semver"
)

var versionTests = []func(t *testing.T, sb integration.Sandbox){
Expand Down Expand Up @@ -45,7 +45,8 @@ func testVersion(t *testing.T, sb integration.Sandbox) {
// This defaults to something that's still compatible
// with semver.
version := fields[1]
require.True(t, semver.IsValid(version), "Second field was not valid semver: %+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 {
Expand Down