From b1244af2fa5da1b38349bb036157e1838d5689d8 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 16 Aug 2023 23:13:00 +0200 Subject: [PATCH 1/2] set correct version for release branch releases --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 88a23019b5..c5860703f2 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ endif VERSION ?= next VERSION_NUMBER ?= 0.0.0 +CI_COMMIT_SHA ?= $(shell git rev-parse HEAD) ifneq ($(CI_COMMIT_TAG),) VERSION := $(CI_COMMIT_TAG:v%=%) VERSION_NUMBER := ${VERSION} @@ -18,8 +19,11 @@ endif # append commit-sha to next version BUILD_VERSION ?= $(VERSION) ifeq ($(BUILD_VERSION),next) - CI_COMMIT_SHA ?= $(shell git rev-parse HEAD) - BUILD_VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | head -c 8)") + BUILD_VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | cut -c -10)") +endif +# append commit-sha to release branch version +ifeq ($(shell echo ${CI_COMMIT_BRANCH} | cut -c -9),release/v) + BUILD_VERSION := $(shell echo "$(shell echo ${CI_COMMIT_BRANCH} | cut -c 10-)-$(shell echo ${CI_COMMIT_SHA} | cut -c -10)") endif LDFLAGS := -s -w -extldflags "-static" -X github.com/woodpecker-ci/woodpecker/version.Version=${BUILD_VERSION} From 23a17f0bb17f9af44c72a5f73501582f29ed311a Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 16 Aug 2023 23:23:36 +0200 Subject: [PATCH 2/2] account for tagging too --- Makefile | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index c5860703f2..a47f7eac8d 100644 --- a/Makefile +++ b/Makefile @@ -11,19 +11,20 @@ endif VERSION ?= next VERSION_NUMBER ?= 0.0.0 CI_COMMIT_SHA ?= $(shell git rev-parse HEAD) + +# it's a tagged release ifneq ($(CI_COMMIT_TAG),) - VERSION := $(CI_COMMIT_TAG:v%=%) + BUILD_VERSION := $(CI_COMMIT_TAG:v%=%) VERSION_NUMBER := ${VERSION} -endif - -# append commit-sha to next version -BUILD_VERSION ?= $(VERSION) -ifeq ($(BUILD_VERSION),next) - BUILD_VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | cut -c -10)") -endif -# append commit-sha to release branch version -ifeq ($(shell echo ${CI_COMMIT_BRANCH} | cut -c -9),release/v) - BUILD_VERSION := $(shell echo "$(shell echo ${CI_COMMIT_BRANCH} | cut -c 10-)-$(shell echo ${CI_COMMIT_SHA} | cut -c -10)") +else + # append commit-sha to next version + ifeq ($(VERSION),next) + BUILD_VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | cut -c -10)") + endif + # append commit-sha to release branch version + ifeq ($(shell echo ${CI_COMMIT_BRANCH} | cut -c -9),release/v) + BUILD_VERSION := $(shell echo "$(shell echo ${CI_COMMIT_BRANCH} | cut -c 10-)-$(shell echo ${CI_COMMIT_SHA} | cut -c -10)") + endif endif LDFLAGS := -s -w -extldflags "-static" -X github.com/woodpecker-ci/woodpecker/version.Version=${BUILD_VERSION}