Add version to executable

This commit is contained in:
Ash Keel 2021-12-06 14:47:38 +01:00
parent 65d6be5ec3
commit 84bef02a42
No known key found for this signature in database
GPG Key ID: BAD8D93E7314ED3E
2 changed files with 9 additions and 0 deletions

2
build.ps1 Normal file
View File

@ -0,0 +1,2 @@
$APPVERSION=git describe --tags --always
go build -ldflags "-X main.appVersion=$APPVERSION"

View File

@ -34,6 +34,8 @@ const AppHeader = `
(_-< _| '_| | ' \/ -_) '_| _| || | |
/__/\__|_| |_|_|_|_\___|_| \__|\_,_|_| `
var appVersion = "v0.0.0-UNKNOWN"
const DefaultBind = "localhost:4337"
//go:embed frontend/dist/*
@ -78,6 +80,8 @@ func main() {
if !*noheader {
// Print the app header :D
fmt.Println(AppHeader)
// Print version info
fmt.Printf("\n %s - %s/%s (%s)\n\n", appVersion, runtime.GOOS, runtime.GOARCH, runtime.Version())
}
// Create module manager
@ -88,6 +92,9 @@ func main() {
failOnError(err, "Could not open DB")
defer db.Close()
// Set meta keys
_ = db.PutKey("stul-meta/version", []byte(appVersion))
// Check if onboarding was completed
var moduleConfig modules.ModuleConfig
err = db.GetJSON(modules.ModuleConfigKey, &moduleConfig)