Skip to content

Commit 9bd30ca

Browse files
committed
Fix version number evaluation
1 parent 86e3a9f commit 9bd30ca

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Makefile

+9-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ PYTHON ?= /usr/bin/python3
44
OS_CODENAME ?= $(shell grep VERSION_CODENAME= /etc/os-release | cut -f2 -d=)
55

66
ifneq ("$(wildcard .git)","")
7-
COMMIT ?= $(or $(shell git rev-parse HEAD), local)
8-
VERSION ?= $(or $(shell $(PYTHON) ./version.py $(shell git show -s --format="%ct" $(shell git rev-parse HEAD)) $(shell git rev-parse --abbrev-ref HEAD)), 0.0.0)
9-
SOURCE_DATE_EPOCH ?= $(or $(shell git show -s --format="%ct" $(shell git rev-parse HEAD)), $(shell date "+%s"))
7+
RELEASE ?= $(shell git describe --all --match master --match 'release-*' --abbrev=0 HEAD | sed 's#heads/##g')
8+
COMMIT ?= $(shell git rev-parse HEAD)
9+
SOURCE_DATE_EPOCH ?= $(or $(shell git show -s --format="%ct" $(COMMIT)), $(shell date "+%s"))
10+
VERSION ?= $(shell $(PYTHON) ./version.py $(SOURCE_DATE_EPOCH) $(RELEASE))
1011
else
11-
COMMIT ?= local
12-
VERSION ?= 0.0.0
12+
COMMIT ?= release
1313
SOURCE_DATE_EPOCH ?= $(shell date "+%s")
14+
VERSION ?= $(or $(shell basename $(PWD) | grep -E -o '[0-9]+.[0-9]+(.[0-9]+)?$'), 0.0.0)
1415
endif
1516

1617
ENV ?= $(PWD)/env
@@ -26,6 +27,9 @@ _CFLAGS := $(CFLAGS) -Wall -O2 -fno-strict-aliasing -DWFB_VERSION='"$(VERSION)-$
2627

2728
all: all_bin gs.key test
2829

30+
version:
31+
@echo -e "RELEASE=$(RELEASE)\nCOMMIT=$(COMMIT)\nVERSION=$(VERSION)\nSOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)"
32+
2933
$(ENV):
3034
$(PYTHON) -m virtualenv --download $(ENV)
3135
$$(PATH=$(ENV)/bin:$(ENV)/local/bin:$(PATH) which python3) -m pip install --upgrade pip setuptools $(STDEB)

0 commit comments

Comments
 (0)