From 5064cb2a46e4b7ca6a834b3c48a409eec8ca1830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deluan=20Quint=C3=A3o?= Date: Thu, 15 Jul 2021 09:49:34 -0400 Subject: [PATCH] Add git version info to release source (#1250) --- .github/workflows/pipeline.yml | 3 +++ .gitignore | 2 +- Makefile | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index a421eac6..1451eeed 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -127,6 +127,9 @@ jobs: - name: Show Version run: git describe --tags + - name: Generate .gitinfo + run: make .gitinfo + - name: Run GoReleaser - SNAPSHOT if: startsWith(github.ref, 'refs/tags/') != true uses: docker://deluan/ci-goreleaser:1.16.4-1 diff --git a/.gitignore b/.gitignore index bba4da22..1c19ebfc 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ docker-compose.yml navidrome.db-shm navidrome.db-wal tags - +.gitinfo diff --git a/Makefile b/Makefile index 648ecaee..1c3028b6 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,12 @@ GO_VERSION=$(shell grep "^go " go.mod | cut -f 2 -d ' ') NODE_VERSION=$(shell cat .nvmrc) +ifneq ("$(wildcard .git)","") GIT_SHA=$(shell git rev-parse --short HEAD) GIT_TAG=$(shell git describe --tags `git rev-list --tags --max-count=1`) +else ifneq ("$(wildcard .gitinfo)","") +include .gitinfo +endif CI_RELEASER_VERSION=1.16.4-1 ## https://github.com/navidrome/ci-goreleaser @@ -92,6 +96,11 @@ single: ##@Cross_Compilation Build binaries for a single supported platforms. It ########################################## #### Miscellaneous +.gitinfo: + @echo "export GIT_SHA=${GIT_SHA}" > .gitinfo + @echo "export GIT_TAG=${GIT_TAG}" >> .gitinfo +.PHONY: .gitinfo + release: @if [[ ! "${V}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$$ ]]; then echo "Usage: make release V=X.X.X"; exit 1; fi go mod tidy