Display proper version information
- The cli version defaults to "unknown-version" unless set via the VERSION env var
- The commit version can be overridden via GITCOMMIT env var
- The build time can be overridden via BUILDTIME env var
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Upstream-commit: cf51bde7d9
Component: cli
This commit is contained in:
5
components/cli/scripts/build/binary
Executable file
5
components/cli/scripts/build/binary
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
source ./scripts/build/ldflags
|
||||
|
||||
go build -o ./build/docker --ldflags "${LDFLAGS}" github.com/docker/cli/cmd/docker
|
||||
8
components/cli/scripts/build/cross
Executable file
8
components/cli/scripts/build/cross
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
source ./scripts/build/ldflags
|
||||
|
||||
gox -output build/docker-{{.OS}}-{{.Arch}} \
|
||||
-osarch="linux/arm linux/amd64 darwin/amd64 windows/amd64" \
|
||||
--ldflags "${LDFLAGS}" \
|
||||
github.com/docker/cli/cmd/docker
|
||||
9
components/cli/scripts/build/ldflags
Executable file
9
components/cli/scripts/build/ldflags
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
VERSION=${VERSION:-"unknown-version"}
|
||||
GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)}
|
||||
BUILDTIME=${BUILDTIME:-$(date --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')}
|
||||
|
||||
export LDFLAGS="-X github.com/docker/cli/cli.GitCommit=${GITCOMMIT} \
|
||||
-X github.com/docker/cli/cli.BuildTime=${BUILDTIME} \
|
||||
-X github.com/docker/cli/cli.Version=${VERSION} ${LDFLAGS}"
|
||||
Reference in New Issue
Block a user