cmd/dist: include version in release
All checks were successful
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 2m42s
Test / ShareFS (push) Successful in 3m46s
Test / Hakurei (push) Successful in 3m56s
Test / Sandbox (race detector) (push) Successful in 5m20s
Test / Hakurei (race detector) (push) Successful in 6m27s
Test / Flake checks (push) Successful in 1m20s
All checks were successful
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 2m42s
Test / ShareFS (push) Successful in 3m46s
Test / Hakurei (push) Successful in 3m56s
Test / Sandbox (race detector) (push) Successful in 5m20s
Test / Hakurei (race detector) (push) Successful in 6m27s
Test / Flake checks (push) Successful in 1m20s
This makes HAKUREI_VERSION optional during build. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
1
cmd/dist/VERSION
vendored
Normal file
1
cmd/dist/VERSION
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
v0.4.2
|
||||||
7
cmd/dist/main.go
vendored
7
cmd/dist/main.go
vendored
@@ -18,8 +18,13 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate sh -c "git describe --tags > VERSION"
|
||||||
|
//go:embed VERSION
|
||||||
|
var version string
|
||||||
|
|
||||||
// getenv looks up an environment variable, and returns fallback if it is unset.
|
// getenv looks up an environment variable, and returns fallback if it is unset.
|
||||||
func getenv(key, fallback string) string {
|
func getenv(key, fallback string) string {
|
||||||
if v, ok := os.LookupEnv(key); ok {
|
if v, ok := os.LookupEnv(key); ok {
|
||||||
@@ -47,7 +52,7 @@ func main() {
|
|||||||
|
|
||||||
verbose := os.Getenv("VERBOSE") != ""
|
verbose := os.Getenv("VERBOSE") != ""
|
||||||
runTests := os.Getenv("HAKUREI_DIST_MAKE") == ""
|
runTests := os.Getenv("HAKUREI_DIST_MAKE") == ""
|
||||||
version := getenv("HAKUREI_VERSION", "untagged")
|
version = getenv("HAKUREI_VERSION", strings.TrimSpace(version))
|
||||||
prefix := getenv("PREFIX", "/usr")
|
prefix := getenv("PREFIX", "/usr")
|
||||||
destdir := getenv("DESTDIR", "dist")
|
destdir := getenv("DESTDIR", "dist")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user