mirror of
https://github.com/ipxe/ipxe
synced 2026-02-03 06:34:32 +03:00
[build] Allow GITVERSION to be specified as an environment variable
When using GitHub Actions with a job container that does not have the git tools installed, the actions/checkout step will download a snapshot instead of performing a git clone, and will therefore not create a .git directory. Allow the GITVERSION variable to be specified externally, so that the test suite logs can still display the commit of the build being tested. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
17
src/Makefile
17
src/Makefile
@@ -215,27 +215,24 @@ VERSION_MINOR := 21
|
||||
VERSION_PATCH := 1
|
||||
EXTRAVERSION := +
|
||||
ifneq ($(wildcard ../.git/HEAD),)
|
||||
GITHEAD := $(shell cat ../.git/HEAD)
|
||||
ifneq ($(firstword $(GITHEAD)),ref:)
|
||||
GITCOMMIT := $(GITHEAD)
|
||||
else
|
||||
GITREF := $(word 2,$(GITHEAD))
|
||||
GITVERSION := $(shell cat ../.git/HEAD)
|
||||
ifeq ($(firstword $(GITVERSION)),ref:)
|
||||
GITREF := $(word 2,$(GITVERSION))
|
||||
ifneq ($(wildcard ../.git/$(GITREF)),)
|
||||
GITCOMMIT := $(shell cat ../.git/$(GITREF))
|
||||
GITVERSION := $(shell cat ../.git/$(GITREF))
|
||||
else
|
||||
GITCOMMIT := $(shell awk -v ref="$(GITREF)" '$$2 == ref { print $1 }' \
|
||||
GITVERSION := $(shell awk -v ref="$(GITREF)" '$$2 == ref { print $1 }' \
|
||||
../.git/packed-refs)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(GITCOMMIT),)
|
||||
ifeq ($(GITVERSION),)
|
||||
$(error Unable to determine git commit ID)
|
||||
endif
|
||||
GITVERSION := g$(shell echo "$(GITCOMMIT)" | cut -c1-5)
|
||||
endif
|
||||
MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
|
||||
VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
|
||||
ifneq ($(GITVERSION),)
|
||||
VERSION += ($(GITVERSION))
|
||||
VERSION += (g$(shell echo "$(GITVERSION)" | cut -c1-5))
|
||||
endif
|
||||
version :
|
||||
@$(ECHO) "$(VERSION)"
|
||||
|
||||
Reference in New Issue
Block a user