mirror of
https://github.com/ipxe/ipxe
synced 2026-02-28 03:11:18 +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
|
VERSION_PATCH := 1
|
||||||
EXTRAVERSION := +
|
EXTRAVERSION := +
|
||||||
ifneq ($(wildcard ../.git/HEAD),)
|
ifneq ($(wildcard ../.git/HEAD),)
|
||||||
GITHEAD := $(shell cat ../.git/HEAD)
|
GITVERSION := $(shell cat ../.git/HEAD)
|
||||||
ifneq ($(firstword $(GITHEAD)),ref:)
|
ifeq ($(firstword $(GITVERSION)),ref:)
|
||||||
GITCOMMIT := $(GITHEAD)
|
GITREF := $(word 2,$(GITVERSION))
|
||||||
else
|
|
||||||
GITREF := $(word 2,$(GITHEAD))
|
|
||||||
ifneq ($(wildcard ../.git/$(GITREF)),)
|
ifneq ($(wildcard ../.git/$(GITREF)),)
|
||||||
GITCOMMIT := $(shell cat ../.git/$(GITREF))
|
GITVERSION := $(shell cat ../.git/$(GITREF))
|
||||||
else
|
else
|
||||||
GITCOMMIT := $(shell awk -v ref="$(GITREF)" '$$2 == ref { print $1 }' \
|
GITVERSION := $(shell awk -v ref="$(GITREF)" '$$2 == ref { print $1 }' \
|
||||||
../.git/packed-refs)
|
../.git/packed-refs)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(GITCOMMIT),)
|
ifeq ($(GITVERSION),)
|
||||||
$(error Unable to determine git commit ID)
|
$(error Unable to determine git commit ID)
|
||||||
endif
|
endif
|
||||||
GITVERSION := g$(shell echo "$(GITCOMMIT)" | cut -c1-5)
|
|
||||||
endif
|
endif
|
||||||
MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
|
MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
|
||||||
VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
|
VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
|
||||||
ifneq ($(GITVERSION),)
|
ifneq ($(GITVERSION),)
|
||||||
VERSION += ($(GITVERSION))
|
VERSION += (g$(shell echo "$(GITVERSION)" | cut -c1-5))
|
||||||
endif
|
endif
|
||||||
version :
|
version :
|
||||||
@$(ECHO) "$(VERSION)"
|
@$(ECHO) "$(VERSION)"
|
||||||
|
|||||||
Reference in New Issue
Block a user