Merge pull request #776 from adamreese/feat/version

feat(version): statically link version at build time
pull/781/head
Adam Reese 8 years ago
commit 9295cb5438

@ -0,0 +1,21 @@
package main
import (
"fmt"
"github.com/kubernetes/helm/pkg/version"
"github.com/spf13/cobra"
)
func init() {
RootCommand.AddCommand(versionCmd)
}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the client version information.",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.Version)
},
}

@ -0,0 +1,10 @@
// Package version represents the current version of the project.
package version
// Version is the current version of the Helm.
// Update this whenever making a new release.
// The version is of the format Major.Minor.Patch
// Increment major number for new feature additions and behavioral changes.
// Increment minor number for bug fixes and performance enhancements.
// Increment patch number for critical fixes to existing releases.
var Version = "v2.0.0-alpha.1"

@ -1,11 +1,28 @@
MUTABLE_VERSION ?= canary
VERSION ?= git-$(shell git rev-parse --short HEAD)
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:${VERSION}
GIT_SHA := $(shell git rev-parse --short HEAD)
GIT_TAG := $(shell git describe --tags --abbrev=0 2>/dev/null)
ifdef VERSION
DOCKER_VERSION = $(VERSION)
BINARY_VERSION = $(VERSION)
endif
DOCKER_VERSION ?= git-${GIT_SHA}
BINARY_VERSION ?= ${GIT_TAG}+${GIT_SHA}
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:${DOCKER_VERSION}
MUTABLE_IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:${MUTABLE_VERSION}
LDFLAGS += -X github.com/kubernetes/helm/pkg/version.Version=${BINARY_VERSION}
DOCKER_PUSH = docker push
ifeq ($(DOCKER_REGISTRY),gcr.io)
DOCKER_PUSH = gcloud docker push
endif
info:
@echo "Build tag: ${VERSION}"
@echo "Build tag: ${DOCKER_VERSION}"
@echo "Registry: ${DOCKER_REGISTRY}"
@echo "Immutable tag: ${IMAGE}"
@echo "Mutable tag: ${MUTABLE_IMAGE}"
@ -15,16 +32,8 @@ docker-push: docker-mutable-push docker-immutable-push
.PHONY: docker-immutable-push
docker-immutable-push:
ifeq ($(DOCKER_REGISTRY),gcr.io)
gcloud docker push ${IMAGE}
else
docker push ${IMAGE}
endif
${DOCKER_PUSH} ${IMAGE}
.PHONY: docker-mutable-push
docker-mutable-push:
ifeq ($(DOCKER_REGISTRY),gcr.io)
gcloud docker push ${MUTABLE_IMAGE}
else
docker push ${MUTABLE_IMAGE}
endif
${DOCKER_PUSH} ${MUTABLE_IMAGE}

Loading…
Cancel
Save