This repository was archived by the owner on Feb 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed
Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 3131 TAGS : ${{ github.ref_name }},${{ github.sha }},latest
3232 shell : bash
3333 run : |
34+ go generate -x ./...
3435 ./build.sh "$VERSION"
3536 export KO_DOCKER_REPO="ghcr.io/${GITHUB_REPOSITORY}"
3637 ko build --bare --platform=all --tags=$TAGS .
Original file line number Diff line number Diff line change 2222
2323mikrotik-exporter
2424test-config.yml
25+ version.go
Original file line number Diff line number Diff line change 1+ //go:generate sh -c "printf 'package main\nconst appVersion = \"%s\"' $VERSION > version.go"
2+
13package main
24
35import (
@@ -8,6 +10,7 @@ import (
810 "mikrotik-exporter/config"
911 "net/http"
1012 "os"
13+ "runtime/debug"
1114
1215 "github.com/prometheus/client_golang/prometheus"
1316 "github.com/prometheus/client_golang/prometheus/collectors"
@@ -63,19 +66,26 @@ var (
6366
6467 cfg * config.Config
6568
66- appVersion = "DEVELOPMENT"
67- shortSha = "0xDEADBEEF"
69+ vcsRevision = "0xDEADBEEF"
6870)
6971
7072func init () {
73+ bi , ok := debug .ReadBuildInfo ()
74+ if ok {
75+ for _ , s := range bi .Settings {
76+ if s .Key == "vcs.revision" {
77+ vcsRevision = s .Value
78+ }
79+ }
80+ }
7181 prometheus .MustRegister (version .NewCollector ("mikrotik_exporter" ))
7282}
7383
7484func main () {
7585 flag .Parse ()
7686
7787 if * ver {
78- fmt .Printf ("\n Version: %s\n Short SHA : %s\n \n " , appVersion , shortSha )
88+ fmt .Printf ("Version: %s\n SHA : %s\n " , appVersion , vcsRevision )
7989 os .Exit (0 )
8090 }
8191
You can’t perform that action at this time.
0 commit comments