Skip to content

Commit

Permalink
Add build arch to the version output
Browse files Browse the repository at this point in the history
  • Loading branch information
rycus86 committed Jun 2, 2018
1 parent 7b7b28f commit 88cd277
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
--build-arg CC_PKG=$CC_PKG \
--build-arg CC_GOARCH=$CC_GOARCH \
--build-arg VERSION=$TRAVIS_BRANCH \
--build-arg BUILD_ARCH=$BUILD_ARCH \
--build-arg GIT_COMMIT=$TRAVIS_COMMIT \
--build-arg BUILD_TIMESTAMP=$(date +%s) \
.
Expand All @@ -48,17 +49,20 @@ jobs:
fi
env:
- DOCKER_TAG=amd64
- BUILD_ARCH=amd64

- <<: *deploy-stage
env:
- DOCKER_TAG=armhf
- BUILD_ARCH=arm32v6
- CC=arm-linux-gnueabihf-gcc
- CC_PKG=gccgo-arm-linux-gnueabihf
- CC_GOARCH=arm

- <<: *deploy-stage
env:
- DOCKER_TAG=aarch64
- BUILD_ARCH=arm64v8
- CC=aarch64-linux-gnu-gcc
- CC_PKG=gccgo-aarch64-linux-gnu
- CC_GOARCH=arm64
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ RUN if [ -n "$CC_PKG" ]; then \
FROM scratch

ARG VERSION="dev"
ARG BUILD_ARCH="unknown"
ARG GIT_COMMIT="unknown"
ARG BUILD_TIMESTAMP="unknown"

ENV VERSION="$VERSION"
ENV BUILD_ARCH="$BUILD_ARCH"
ENV GIT_COMMIT="$GIT_COMMIT"
ENV BUILD_TIMESTAMP="$BUILD_TIMESTAMP"

Expand Down
6 changes: 4 additions & 2 deletions config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

type Version struct {
Tag string
BuildArch string
GitCommit string
BuildDate time.Time
}
Expand All @@ -18,10 +19,10 @@ func (v *Version) StringForCommandLine() string {
return strings.TrimSpace(fmt.Sprintf(`
Podlike (https://github.com/rycus86/podlike)
--------------------------------------------
Version : %s
Version : %s-%s
Git commit : %s
Built at : %s
`, v.Tag, v.GitCommit, v.BuildDate.Format(time.RFC3339)))
`, v.Tag, v.BuildArch, v.GitCommit, v.BuildDate.Format(time.RFC3339)))
}

func parseVersion() *Version {
Expand All @@ -33,6 +34,7 @@ func parseVersion() *Version {

return &Version{
Tag: getEnv("VERSION", "dev"),
BuildArch: getEnv("BUILD_ARCH", "unknown"),
GitCommit: getEnv("GIT_COMMIT", "unknown"),
BuildDate: time.Unix(timeAsInt, 0),
}
Expand Down

0 comments on commit 88cd277

Please sign in to comment.