From ecf338f43b112c9f2d02614e955789a436be09b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Thu, 4 Jan 2024 13:55:28 +0100 Subject: [PATCH] scripts/build: Handle VERSION containing git ref MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Transform `VERSION` variable if it contains a git ref. This is the same as moby does (with "<<<" bashism removed). Signed-off-by: Paweł Gronowski --- scripts/build/.variables | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/build/.variables b/scripts/build/.variables index e0147655b4..a9371ebec2 100755 --- a/scripts/build/.variables +++ b/scripts/build/.variables @@ -22,6 +22,13 @@ else BUILDTIME=${BUILDTIME:-$(TZ=UTC date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ")} fi +case "$VERSION" in + refs/tags/v*) VERSION=${VERSION#refs/tags/v} ;; + refs/tags/*) VERSION=${VERSION#refs/tags/} ;; + refs/heads/*) VERSION=$(echo "${VERSION#refs/heads/}" | sed -r 's#/+#-#g') ;; + refs/pull/*) VERSION=pr-$(echo "$VERSION" | grep -o '[0-9]\+') ;; +esac + GOOS="$(go env GOOS)" GOARCH="$(go env GOARCH)" if [ "${GOARCH}" = "arm" ]; then