Skip to content

Commit bf35658

Browse files
committed
Read version from .VERSION if not git dir
* Added a script for parsing the .VERSION file. * Updated cli Makefile to attempt .VERSION read if not git dir. .VERSION has a slug that will be populated by `git archive`.
1 parent ea3fd82 commit bf35658

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.version.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
read -r firstline < .VERSION
3+
last_half="${firstline##*tag: }"
4+
if [[ ${last_half::1} == "v" ]]; then
5+
version_string="${last_half%%[,)]*}"
6+
fi
7+
echo "${version_string:-v0.0.0}"

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@ all: build lint test
22

33
.PHONY: all
44

5+
# Version flags to embed in the binaries
6+
VERSION ?= $(shell [ -d .git ] && git describe --tags --always --dirty="-dev")
7+
# If we are not in an active git dir then try reading the version from .VERSION.
8+
# .VERSION contains a slug populated by `git archive`.
9+
VERSION := $(or $(VERSION),$(shell ./.version.sh .VERSION))
10+
511
-include make/common.mk
612
-include make/docker.mk

0 commit comments

Comments
 (0)