From 1903c6162752ac818ff13b822ce98fe0df31c279 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 8 Oct 2026 19:49:59 +0200 Subject: [PATCH] fix(build): use the VERSION file consistently in docker builds and source tarballs (#39683) Fix two builds that reported a non-semver version. Docker images built with a `VERSION` file reported a bare commit hash as their version, and binaries built from the nightly source tarball reported `main-nightly`. Docker builds now honor `VERSION` like `make` does, and the nightly source tarball stores the actual version. Also remove the obsolete `main` to `main-nightly` rename, the branch case already appends `-nightly`. | Build | Before | After | |---|---|---| | Docker release | `28.1.0` | `28.1.0` | | Docker nightly | `29.0.0+dev-83-gab9bcd6a79` | `29.0.0+dev-83-gab9bcd6a79` | | Docker with `VERSION` | `c55da3e` | `29.0.0+custom` | | Release tarball | `28.1.0` | `28.1.0` | | Nightly tarball | `main-nightly` | `29.0.0+dev-83-gab9bcd6a79` | --- .dockerignore | 1 - Makefile | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.dockerignore b/.dockerignore index f61d8aea3f3..db9b5ff9990 100644 --- a/.dockerignore +++ b/.dockerignore @@ -63,7 +63,6 @@ cpu.out /public/assets/fonts /public/assets/img/avatar /vendor -/VERSION /.air /.go-licenses /Dockerfile diff --git a/Makefile b/Makefile index 77b9cc96825..b06c8f455ee 100644 --- a/Makefile +++ b/Makefile @@ -75,8 +75,7 @@ STORED_VERSION_FILE := VERSION GITHUB_REF_TYPE ?= branch GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) -# VERSION: the branch name for the build and filenames, e.g.: "feature/foo-bar", "main" -# branch name "release/v1.27.2" is stripped to "1.27.2". +# VERSION: the name for the build and filenames, e.g.: "1.2.3" for tag "v1.2.3", "main-nightly" for branch "main" # GITEA_VERSION: the Gitea's internal version for display, e.g. "1.28.0+dev-356-ge47d0b66ea" ifeq ($(GITHUB_REF_TYPE),tag) # convert tag "v1.2.3" to "1.2.3" @@ -101,11 +100,6 @@ else $(error unsupported ref type $(GITHUB_REF_TYPE)) endif -# if version == "main" then add "-nightly" to the version for nightly builds: "main-nightly" -ifeq ($(VERSION),main) - VERSION := main-nightly -endif - LDFLAGS := $(LDFLAGS) -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)" RELEASE_ENV = GO="$(GO)" TAGS="$(TAGS)" LDFLAGS="$(LDFLAGS)" DIST="$(DIST)" VERSION="$(VERSION)" @@ -556,7 +550,7 @@ release-compress: | $(DIST_DIRS) .PHONY: release-sources release-sources: | $(DIST_DIRS) - echo $(VERSION) > $(STORED_VERSION_FILE) + echo $(GITEA_VERSION) > $(STORED_VERSION_FILE) # bsdtar needs a ^ to prevent matching subdirectories $(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./) # use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s