From b1e1f5c97b21ff35055a85815d1615e7dba650e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=BE=E9=9B=A8?= Date: Wed, 11 Aug 2021 11:40:25 +0800 Subject: [PATCH] always pick the latest sem ver with same hash (#33) Co-authored-by: nyanpassu --- .github/workflows/goreleaser.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index c2c1c1f..2a58ac2 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -16,7 +16,7 @@ jobs: - name: Set up environment variables run: | - echo "VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV + echo "VERSION=$(git tag --contains $(git rev-list --tags --max-count=1) | sed '/-/!{s/$/_/}' | sort -V -r | sed 's/_$//' | head -1)" >> $GITHUB_ENV - name: Set up Go uses: actions/setup-go@v2 diff --git a/Makefile b/Makefile index af94fe5..f051037 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ REPO_PATH := github.com/projecteru2/barrel REVISION := $(shell git rev-parse HEAD || unknown) BUILTAT := $(shell date +%Y-%m-%dT%H:%M:%S) BUILD_PATH := target -VERSION := $(shell git describe --tags $(shell git rev-list --tags --max-count=1)) +VERSION := $(shell git tag --contains $(shell git rev-list --tags --max-count=1) | sed '/-/!{s/$/_/}' | sort -V -r | sed 's/_$//' | head -1) GO_LDFLAGS ?= -s -X $(REPO_PATH)/versioninfo.REVISION=$(REVISION) \ -X $(REPO_PATH)/versioninfo.BUILTAT=$(BUILTAT) \ -X $(REPO_PATH)/versioninfo.VERSION=$(VERSION)