From 4a397d4c1ee2265adc6fd503740f8263993318b3 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Thu, 17 Nov 2022 21:27:36 -0800 Subject: [PATCH] Add go generate script for calculating version number --- .goreleaser.yaml | 1 + main.go | 3 --- scripts/gen-version.sh | 3 +++ version.go | 8 ++++++++ 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100755 scripts/gen-version.sh create mode 100644 version.go diff --git a/.goreleaser.yaml b/.goreleaser.yaml index c17cc13..97ccb06 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,5 +1,6 @@ before: hooks: + - go generate - go mod tidy builds: - id: itd diff --git a/main.go b/main.go index c515726..0804475 100644 --- a/main.go +++ b/main.go @@ -39,9 +39,6 @@ import ( var k = koanf.New(".") -//go:embed version.txt -var version string - var ( firmwareUpdating = false // The FS must be updated when the watch is reconnected diff --git a/scripts/gen-version.sh b/scripts/gen-version.sh new file mode 100755 index 0000000..9eb213e --- /dev/null +++ b/scripts/gen-version.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +git describe --tags > version.txt \ No newline at end of file diff --git a/version.go b/version.go new file mode 100644 index 0000000..f31d4b5 --- /dev/null +++ b/version.go @@ -0,0 +1,8 @@ +package main + +import _ "embed" + +//go:generate scripts/gen-version.sh + +//go:embed version.txt +var version string