From 869795a530f6a5a4e28687c003300d39fbaee6e2 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 28 Mar 2024 15:45:51 +0100 Subject: [PATCH] [RELEASE] GITEA_VERSION is a fallback for FORGEJO_VERSION Existing Forgejo packages may rely on setting GITEA_VERSION to specify the version to build if: * they do not build from the git repository with the proper tag * they build from a source tarbal that does not have a VERSION file With 7.0 the logic of setting the version was modified in the `[RELEASE] Gitea version is for interoperability only` commit and ignores this variable which creates an unecessary breaking change. If GITEA_VERSION is set, the versions will be set on 7.0 exactly as they would have with version before and included 1.21. * If GITEA_VERSION is not set, all versions are the same * If GITEA_VERSION is set, there is a distinction between the version set in the binary are returned by the Gitea API and the version returned by the Forgejo API which includes metadata. Before: $ make GITEA_VERSION=7.0.0 show-version-full 7.0.0-dev-1809-cd6fa771ab+gitea-1.22.0 $ make GITEA_VERSION=7.0.0 show-version-api 7.0.0-dev-1809-cd6fa771ab+gitea-1.22.0 After: $ make GITEA_VERSION=7.0.0 show-version-full 7.0.0 $ make GITEA_VERSION=7.0.0 show-version-api 7.0.0+gitea-1.22.0 --- Makefile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b1c4864c7..16d7edb2d 100644 --- a/Makefile +++ b/Makefile @@ -88,8 +88,13 @@ STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null) ifneq ($(STORED_VERSION),) FORGEJO_VERSION ?= $(STORED_VERSION) else - # drop the "g" prefix prepended by git describe to the commit hash - FORGEJO_VERSION ?= $(shell git describe --exclude '*-test' --tags --always | sed 's/^v//' | sed 's/\-g/-/')+${GITEA_COMPATIBILITY} + ifneq ($(GITEA_VERSION),) + FORGEJO_VERSION ?= $(GITEA_VERSION) + FORGEJO_VERSION_API ?= $(GITEA_VERSION)+${GITEA_COMPATIBILITY} + else + # drop the "g" prefix prepended by git describe to the commit hash + FORGEJO_VERSION ?= $(shell git describe --exclude '*-test' --tags --always | sed 's/^v//' | sed 's/\-g/-/')+${GITEA_COMPATIBILITY} + endif endif FORGEJO_VERSION_MAJOR=$(shell echo $(FORGEJO_VERSION) | sed -e 's/\..*//') FORGEJO_VERSION_MINOR=$(shell echo $(FORGEJO_VERSION) | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/') @@ -106,7 +111,12 @@ show-version-minor: RELEASE_VERSION ?= ${FORGEJO_VERSION} VERSION ?= ${RELEASE_VERSION} -LDFLAGS := $(LDFLAGS) -X "main.ReleaseVersion=$(RELEASE_VERSION)" -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(FORGEJO_VERSION)" -X "main.Tags=$(TAGS)" -X "main.ForgejoVersion=$(FORGEJO_VERSION)" +FORGEJO_VERSION_API ?= ${FORGEJO_VERSION} + +show-version-api: + @echo ${FORGEJO_VERSION_API} + +LDFLAGS := $(LDFLAGS) -X "main.ReleaseVersion=$(RELEASE_VERSION)" -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(FORGEJO_VERSION)" -X "main.Tags=$(TAGS)" -X "main.ForgejoVersion=$(FORGEJO_VERSION_API)" LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64