1
0
mirror of https://github.com/cmur2/miflorad.git synced 2024-12-10 01:04:19 +01:00

module: bump minimum Go version to 1.18 and use debug.ReadBuildInfo()

This commit is contained in:
cn 2022-03-18 00:21:53 +01:00
parent 0268126d70
commit 72c4c94cb7
4 changed files with 20 additions and 11 deletions

View File

@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
go:
- '1.17'
- '1.18'
env:
GO111MODULE: on
GOPROXY: direct

View File

@ -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:

View File

@ -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"
}

2
go.mod
View File

@ -1,6 +1,6 @@
module miflorad
go 1.17
go 1.18
require (
github.com/currantlabs/gatt v0.0.0-20161006170101-f949eac78f4e