From 6decf111a132a869f9e5c6f4d20e368b8f74309f Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 21 Jun 2023 16:44:33 +0200 Subject: [PATCH] [CI] Forgejo Actions based release process (squash) version use Actions environment variables in Makefile (#25319) (#25318) uses Actions variable to determine the version. But Forgejo builds happen in a container where they are not available. Do not use them. Also verify the version of the binary is as expected for sanity check. --- .forgejo/actions/build-release/action.yml | 8 ++++++++ Makefile | 24 ++--------------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/.forgejo/actions/build-release/action.yml b/.forgejo/actions/build-release/action.yml index 6773a8c109..ad9818e9f0 100644 --- a/.forgejo/actions/build-release/action.yml +++ b/.forgejo/actions/build-release/action.yml @@ -129,6 +129,14 @@ runs: docker create --platform $platform --name forgejo-$arch ${{ steps.registry.outputs.host-port }}/${{ inputs.owner }}/${{ inputs.repository }}:${{ inputs.tag-version }}${{ inputs.suffix }} binary="${{ inputs.binary-name }}-${{ inputs.tag-version }}-linux" docker cp forgejo-$arch:${{ inputs.binary-path }} $binary-$arch + chmod +x $binary-$arch + # the displayed version is converted with - sometime changed into +, deal with it + pattern=$(echo "${{ inputs.tag-version }}" | tr - .) + if ! ./$binary-$arch --version | grep "$pattern" ; then + echo "ERROR: expected version pattern $pattern not found in the output of $binary-$arch --version" + ./$binary-$arch --version + exit 1 + fi xz --keep -9 $binary-$arch shasum -a 256 $binary-$arch > $binary-$arch.sha256 shasum -a 256 $binary-$arch.xz > $binary-$arch.xz.sha256 diff --git a/Makefile b/Makefile index deb5b91a8b..23e8caa3ef 100644 --- a/Makefile +++ b/Makefile @@ -79,28 +79,8 @@ endif STORED_VERSION_FILE := VERSION HUGO_VERSION ?= 0.111.3 -ifneq ($(GITHUB_REF_TYPE),branch) - VERSION ?= $(subst v,,$(GITHUB_REF_NAME)) - GITEA_VERSION ?= $(GITHUB_REF_NAME) -else - ifneq ($(GITHUB_REF_NAME),) - VERSION ?= $(subst release/v,,$(GITHUB_REF_NAME)) - else - VERSION ?= main - endif - - STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null) - ifneq ($(STORED_VERSION),) - GITEA_VERSION ?= $(STORED_VERSION) - else - GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//') - endif -endif - -# if version = "main" then update version to "nightly" -ifeq ($(VERSION),main) - VERSION := main-nightly -endif +GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//') +VERSION = ${GITEA_VERSION} LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"