From a398f824037d664f5743f26788042a1d08171362 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 20 Mar 2015 11:35:21 -0700 Subject: [PATCH] Add dynamic version string --- config/types.go | 8 +++++++- scripts/build | 4 +++- scripts/ci | 2 +- scripts/version | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 scripts/version diff --git a/config/types.go b/config/types.go index aa52cb49..f914a99c 100644 --- a/config/types.go +++ b/config/types.go @@ -1,7 +1,6 @@ package config const ( - VERSION = "0.2.0" CONSOLE_CONTAINER = "console" DOCKER_BIN = "/usr/bin/docker" DOCKER_SYSTEM_HOME = "/var/lib/system-docker" @@ -16,6 +15,7 @@ const ( ) var ( + VERSION string CloudConfigFile = "/var/lib/rancher/conf/cloud-config-rancher.yml" ConfigFile = "/var/lib/rancher/conf/rancher.yml" PrivateConfigFile = "/var/lib/rancher/conf/rancher-private.yml" @@ -103,3 +103,9 @@ type StateConfig struct { type CloudInit struct { Datasources []string `yaml:"datasources,omitempty"` } + +func init() { + if VERSION == "" { + VERSION = "v0.0.0-dev" + } +} diff --git a/scripts/build b/scripts/build index f81f1869..8415a2ca 100755 --- a/scripts/build +++ b/scripts/build @@ -3,6 +3,8 @@ set -x cd $(dirname $0)/.. +source scripts/version + if [ "$IN_DOCKER" != "true" ]; then cat > .dockerfile << "EOF" FROM rancher/dind:v0.1.0 @@ -39,5 +41,5 @@ fi echo export GOPATH=$GOPATH mkdir -p bin -go build -tags netgo -ldflags "-linkmode external -extldflags -static" -o bin/rancheros +go build -tags netgo -ldflags "-X github.com/rancherio/os/config.VERSION ${VERSION:-v0.0.0-dev} -linkmode external -extldflags -static" -o bin/rancheros strip --strip-all bin/rancheros diff --git a/scripts/ci b/scripts/ci index b2f496fc..b82652ef 100755 --- a/scripts/ci +++ b/scripts/ci @@ -54,6 +54,6 @@ for i in $(ls -d * .* | sort -u | grep -Ev '(\.|\.\.|\.dockerfile|build|dist|.gi ARGS="${ARGS} $i" fi done -run --assets "${ARGS}" ./scripts/build +run --assets ./scripts/version --assets "${ARGS}" ./scripts/build run --assets ./scripts/install ./scripts/package "$@" finish diff --git a/scripts/version b/scripts/version new file mode 100644 index 00000000..a3f7a59e --- /dev/null +++ b/scripts/version @@ -0,0 +1 @@ +VERSION=v0.2.0