From 2a96c314e21add8076e7b0ee756c961f9cd46171 Mon Sep 17 00:00:00 2001 From: Chris Watson Date: Thu, 21 Nov 2024 20:56:36 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20version=20metadata=20?= =?UTF-8?q?including=20revision,=20date=20and=20commit=20hash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 5 +++++ pkg/version/version.go | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65f1ff8..cf068bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,12 @@ jobs: ref: main - name: Update version run: | + COMMIT=$(git rev-parse HEAD) + DATE=$(date -u +"%Y-%m-%d") sed -i "s/const Version = \".*\"/const Version = \"${GITHUB_REF_NAME}\"/" pkg/version/version.go + sed -i "s/const Revision = \".*\"/const Revision = \"${GITHUB_SHA}\"/" pkg/version/version.go + sed -i "s/const Date = \".*\"/const Date = \"${DATE}\"/" pkg/version/version.go + sed -i "s/const Commit = \".*\"/const Commit = \"${COMMIT}\"/" pkg/version/version.go git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" git add pkg/version/version.go diff --git a/pkg/version/version.go b/pkg/version/version.go index 332b544..40cc29e 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -2,3 +2,12 @@ package version // Version is the current version of goshot const Version = "v0.4.4" + +// Revision is the current git revision of goshot +const Revision = "HEAD" + +// Date is the build date of goshot +const Date = "unknown" + +// Commit is the git commit of goshot +const Commit = "unknown"