diff --git a/scripts/build/.variables b/scripts/build/.variables index 76b0602f06..f14e54f2f4 100755 --- a/scripts/build/.variables +++ b/scripts/build/.variables @@ -12,7 +12,15 @@ TARGET=${TARGET:-"build"} PLATFORM=${PLATFORM:-} VERSION=${VERSION:-$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags | sed 's/^v//' 2>/dev/null || echo "unknown-version" )} GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)} -BUILDTIME=${BUILDTIME:-$(date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ")} + +if [ "$(uname)" = "Darwin" ]; then + # Using BSD date (macOS), which doesn't suppoort the --date option + # date -jf "" "" +"" (https://unix.stackexchange.com/a/86510) + BUILDTIME=${BUILDTIME:-$(TZ=UTC date -jf "%s" "${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ")} +else + # Using GNU date (Linux) + BUILDTIME=${BUILDTIME:-$(TZ=UTC date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ")} +fi GOOS="$(go env GOOS)" GOARCH="$(go env GOARCH)"