Merge pull request #65 from EmileVauge/version-in-binary
Adds version in binary
This commit is contained in:
commit
fd234c683c
4 changed files with 26 additions and 7 deletions
|
@ -6,6 +6,7 @@ machine:
|
||||||
environment:
|
environment:
|
||||||
REPO: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
|
REPO: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
|
||||||
DOCKER_HOST: tcp://172.17.42.1:2375
|
DOCKER_HOST: tcp://172.17.42.1:2375
|
||||||
|
VERSION: v1.0.alpha.$CIRCLE_BUILD_NUM
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
pre:
|
pre:
|
||||||
|
@ -27,8 +28,8 @@ deployment:
|
||||||
hub:
|
hub:
|
||||||
branch: master
|
branch: master
|
||||||
commands:
|
commands:
|
||||||
- ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --prerelease v1.0.alpha.$CIRCLE_BUILD_NUM dist/
|
- ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --prerelease ${VERSION} dist/
|
||||||
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
|
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
|
||||||
- docker push ${REPO,,}:latest
|
- docker push ${REPO,,}:latest
|
||||||
- docker tag ${REPO,,}:latest ${REPO,,}:v1.0.alpha.$CIRCLE_BUILD_NUM
|
- docker tag ${REPO,,}:latest ${REPO,,}:${VERSION}
|
||||||
- docker push ${REPO,,}:v1.0.alpha.$CIRCLE_BUILD_NUM
|
- docker push ${REPO,,}:${VERSION}
|
||||||
|
|
|
@ -8,6 +8,13 @@ fi
|
||||||
|
|
||||||
rm -f dist/traefik
|
rm -f dist/traefik
|
||||||
|
|
||||||
# Build binaries
|
if [ -z "$VERSION" ]; then
|
||||||
CGO_ENABLED=0 go build -a -installsuffix nocgo -o dist/traefik .
|
VERSION=$(git rev-parse HEAD)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DATE" ]; then
|
||||||
|
DATE=$(date -u '+%Y-%m-%d_%I:%M:%S%p')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build binaries
|
||||||
|
CGO_ENABLED=0 go build -ldflags "-X main.Version=$VERSION -X main.BuildDate=$DATE" -a -installsuffix nocgo -o dist/traefik .
|
||||||
|
|
|
@ -20,10 +20,17 @@ else
|
||||||
OS_ARCH_ARG=($2)
|
OS_ARCH_ARG=($2)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
VERSION=$(git rev-parse HEAD)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DATE" ]; then
|
||||||
|
DATE=$(date -u '+%Y-%m-%d_%I:%M:%S%p')
|
||||||
|
fi
|
||||||
|
|
||||||
# Get rid of existing binaries
|
# Get rid of existing binaries
|
||||||
rm -f dist/traefik_*
|
rm -f dist/traefik_*
|
||||||
|
|
||||||
# Build binaries
|
# Build binaries
|
||||||
gox "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" \
|
gox -ldflags "-X main.Version=$VERSION -X main.BuildDate=$DATE" "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" \
|
||||||
-output="dist/traefik_{{.OS}}-{{.Arch}}"
|
-output="dist/traefik_{{.OS}}-{{.Arch}}"
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Version = ""
|
||||||
|
BuildDate = ""
|
||||||
globalConfigFile = kingpin.Arg("conf", "Main configration file.").Default("traefik.toml").String()
|
globalConfigFile = kingpin.Arg("conf", "Main configration file.").Default("traefik.toml").String()
|
||||||
|
version = kingpin.Flag("version", "Get Version.").Short('v').Bool()
|
||||||
currentConfigurations = make(configs)
|
currentConfigurations = make(configs)
|
||||||
metrics = stats.New()
|
metrics = stats.New()
|
||||||
oxyLogger = &OxyLogger{}
|
oxyLogger = &OxyLogger{}
|
||||||
|
@ -49,6 +52,7 @@ type configs map[string]*Configuration
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
kingpin.Version(Version + " built on the " + BuildDate)
|
||||||
kingpin.Parse()
|
kingpin.Parse()
|
||||||
fmtlog.SetFlags(fmtlog.Lshortfile | fmtlog.LstdFlags)
|
fmtlog.SetFlags(fmtlog.Lshortfile | fmtlog.LstdFlags)
|
||||||
var srv *manners.GracefulServer
|
var srv *manners.GracefulServer
|
||||||
|
|
Loading…
Reference in a new issue