mirror of
https://github.com/cmur2/miflorad.git
synced 2024-12-21 16:54:24 +01:00
module: bump minimum Go version to 1.18 and use debug.ReadBuildInfo()
This commit is contained in:
parent
0268126d70
commit
72c4c94cb7
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
go:
|
||||
- '1.17'
|
||||
- '1.18'
|
||||
env:
|
||||
GO111MODULE: on
|
||||
GOPROXY: direct
|
||||
|
6
Makefile
6
Makefile
@ -53,8 +53,8 @@ remote-run: clean ## Run clean, build $RUN_COMMAND for Linux on ARM and launch i
|
||||
release: ## Build and upload release version of miflorad to Github
|
||||
mkdir -p pkg
|
||||
pushd cmd/miflorad
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-amd64" -ldflags="-s -w -X main.version=$(MIFLORAD_VERSION)"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-arm" -ldflags="-s -w -X main.version=$(MIFLORAD_VERSION)"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-amd64" -ldflags="-s -w"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-arm" -ldflags="-s -w"
|
||||
popd
|
||||
# github-release "v$(MIFLORAD_VERSION)" pkg/miflorad-$(MIFLORAD_VERSION)-* --commit "master" --tag "v$(MIFLORAD_VERSION)" --prerelease --github-repository "cmur2/miflorad"
|
||||
github-release "v$(MIFLORAD_VERSION)" pkg/miflorad-$(MIFLORAD_VERSION)-* --commit "master" --tag "v$(MIFLORAD_VERSION)" --github-repository "cmur2/miflorad"
|
||||
@ -62,7 +62,7 @@ release: ## Build and upload release version of miflorad to Github
|
||||
.PHONY: cmd/miflorad/miflorad
|
||||
cmd/miflorad/miflorad:
|
||||
pushd cmd/miflorad
|
||||
CGO_ENABLED=0 go build -buildmode=pie -ldflags "-X main.version=$(MIFLORAD_VERSION)"
|
||||
CGO_ENABLED=0 go build -buildmode=pie
|
||||
|
||||
.PHONY: cmd/munin-miflora/munin-miflora
|
||||
cmd/munin-miflora/munin-miflora:
|
||||
|
@ -1,12 +1,21 @@
|
||||
package main
|
||||
|
||||
// program version, will be populated on build
|
||||
var version string
|
||||
import (
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
func getVersion() string {
|
||||
if version == "" {
|
||||
return "dev"
|
||||
} else {
|
||||
return version
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
for _, kv := range info.Settings {
|
||||
switch kv.Key {
|
||||
case "vcs.revision":
|
||||
return kv.Value[0:8]
|
||||
}
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user