diff --git a/.gitignore b/.gitignore index 08d98f8cd..4707afc86 100644 --- a/.gitignore +++ b/.gitignore @@ -65,5 +65,6 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST +.GIT_TAG_INFO test.tar diff --git a/MANIFEST.in b/MANIFEST.in index ab316f0cb..91bab2ab7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,6 +4,7 @@ include Makefile include .goreleaser.yaml .goreleaser/*.Dockerfile include pkg/* cmd/* include go.mod go.sum +include .GIT_TAG_INFO prune examples prune docs prune .github diff --git a/Makefile b/Makefile index c1d3e6a34..adf78a14c 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,7 @@ BUILD_DIR := ./build VERSION ?= $(shell git describe --match 'v[0-9]*' --always --tags --abbrev=0) BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') GIT_COMMIT=$(shell git rev-parse HEAD) -GIT_TAG=$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi) +GIT_TAG ?= $(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi) GIT_TREE_STATE=$(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi) GITSHA ?= $(shell git rev-parse --short HEAD) GIT_LATEST_TAG ?= $(shell git describe --tags --abbrev=0) @@ -110,6 +110,7 @@ build-release: -X $(ROOT)/pkg/version.gitTag=$(GIT_TAG)" \ $(CMD_DIR)/$${target}; \ done + @[[ ! -z "$(GIT_TAG)" ]] && echo "$(GIT_TAG)" > .GIT_TAG_INFO help: ## Display this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) diff --git a/setup.py b/setup.py index a6b926ada..f7c7797de 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,15 @@ def build_envd_if_not_found(): if not os.path.exists("bin/envd"): logging.info("envd not found. Build from scratch") - errno = subprocess.call(["make", "build-release"]) + try: + with open(".GIT_TAG_INFO") as f: + logging.info("Use build_tag from envd._version") + tag = f.read().strip() + errno = subprocess.call( + ["make", "build-release", "GIT_TAG={}".format(tag)] + ) + except: + errno = subprocess.call(["make", "build-release"]) assert errno == 0, "Failed to build envd"