From 3f28d61d83492083ba3d262634bccc89e84c966d Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 4 Oct 2024 00:35:28 +0200 Subject: [PATCH] miniupnpd/gitrev.mk: use GitHub Actions variables GITHUB_REF_TYPE / GITHUB_REF_NAME / GITHUB_SHA --- miniupnpd/gitrev.mk | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/miniupnpd/gitrev.mk b/miniupnpd/gitrev.mk index f1a529c..ecc4b3a 100644 --- a/miniupnpd/gitrev.mk +++ b/miniupnpd/gitrev.mk @@ -4,11 +4,17 @@ # CI_COMMIT_TAG / CI_COMMIT_BRANCH / CI_COMMIT_SHORT_SHA are gitlab-ci # predefined variables # see https://docs.gitlab.com/ee/ci/variables/predefined_variables.html +# GITHUB_SHA / GITHUB_REF_NAME / GITHUB_REF_TYPE are variable defined by +# GitHub Actions +# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables ifneq ($(CI_COMMIT_TAG),) GITREF = $(CI_COMMIT_TAG) -else -ifneq ($(CI_COMMIT_BRANCH),) +else ifneq ($(CI_COMMIT_BRANCH),) GITREF = $(CI_COMMIT_BRANCH)-$(CI_COMMIT_SHORT_SHA) +else ifeq ($(GITHUB_REF_TYPE),tag) +GITREF = $(GITHUB_REF_NAME) +else ifeq ($(GITHUB_REF_TYPE),branch) +GITREF := $(GITHUB_REF_NAME)-$(shell echo "$(GITHUB_SHA)" | cut -c1-8) else ISGITREPO := $(shell git rev-parse --is-inside-work-tree) ifeq ($(ISGITREPO),true) @@ -16,7 +22,6 @@ ifeq ($(ISGITREPO),true) GITREF := $(shell git describe --exact-match --tags 2> /dev/null || echo "`git rev-parse --abbrev-ref HEAD`-`git rev-parse --short HEAD`" ) endif endif -endif ifneq ($(GITREF),) CPPFLAGS += -DMINIUPNPD_GIT_REF=\"$(GITREF)\"