mirror of https://github.com/docker/cli.git
Merge pull request #3535 from thaJeztah/fix_date_on_macos
scripts/build: fix build-date generation on macOS, and make sure it's in UTC
This commit is contained in:
commit
73b05aaa82
|
@ -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 "<input format>" "<input value>" +"<output format>" (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)"
|
||||
|
|
Loading…
Reference in New Issue