Skip to content

Commit babab7c

Browse files
committed
Makefile: source RELEASE.txt when git fails
With commits 31f64b8 and 714dfbe and recently released Git v2.32 we create a file RELEASE.txt that contains GIT_COMMIT and VERSION variables. This should happen automatically when GitHub creates the release archive or git-archive(1) is invoked directly. To test, create an archive $ git archive --format=tar HEAD | gzip >gscloud.tar.gz extract it and run make. The version strings produced by $ gscloud version should match those for the original repository. Fixes #131.
1 parent dba873c commit babab7c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
VERSION=$$(git describe --tags)
2-
GIT_COMMIT=$$(git rev-list -1 HEAD)
1+
VERSION := $(shell if ! git describe --tags 2>/dev/null; then \
2+
grep -Po '(?<=^VERSION=)v.*$$' $$PWD/RELEASE.txt; \
3+
fi; \
4+
)
5+
6+
GIT_COMMIT := $(shell if ! git rev-list -1 HEAD 2>/dev/null; then \
7+
grep -Po '(?<=^GIT_COMMIT=)\w*$$' $$PWD/RELEASE.txt; \
8+
fi; \
9+
)
310

411
default: build
512

0 commit comments

Comments
 (0)