-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ jobs: | |
persist-credentials: false | ||
|
||
- name: build binary | ||
run: go build | ||
run: go build -ldflags "-X github.com/letsencrypt/unbound_exporter/util.BuildID=$(git rev-parse --short HEAD) -X github.com/letsencrypt/unbound_exporter/util.BuildBranch=$(git rev-parse --abbrev-ref HEAD) -X github.com/letsencrypt/unbound_exporter/util.BuildTime=$(date +%F-%T -u)" | ||
|
||
- name: install nfpm | ||
run: go install github.com/goreleaser/nfpm/v2/cmd/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package util | ||
|
||
import ( | ||
"expvar" | ||
) | ||
|
||
const Unspecified = "Unspecified" | ||
|
||
// BuildID is set by the compiler (using -ldflags "-X util.BuildID $(git rev-parse --short HEAD)") | ||
// and is used by GetBuildID | ||
var BuildID string | ||
|
||
// BuildHost is set by the compiler and is used by GetBuildHost | ||
var BuildHost string | ||
|
||
// BuildTime is set by the compiler and is used by GetBuildTime | ||
var BuildTime string | ||
|
||
// BuildBranch is set by the compiler and is used by GetBuildBranch | ||
var BuildBranch string | ||
|
||
func init() { | ||
expvar.NewString("BuildID").Set(BuildID) | ||
expvar.NewString("BuildTime").Set(BuildTime) | ||
} | ||
|
||
// GetBuildID identifies what build is running. | ||
func GetBuildID() (retID string) { | ||
retID = BuildID | ||
if retID == "" { | ||
retID = Unspecified | ||
} | ||
return | ||
} | ||
|
||
// GetBuildTime identifies when this build was made | ||
func GetBuildTime() (retID string) { | ||
retID = BuildTime | ||
if retID == "" { | ||
retID = Unspecified | ||
} | ||
return | ||
} | ||
|
||
// GetBuildHost identifies the building host | ||
func GetBuildHost() (retID string) { | ||
retID = BuildHost | ||
if retID == "" { | ||
retID = Unspecified | ||
} | ||
return | ||
} | ||
|
||
// GetBuildBranch identifies the building host | ||
func GetBuildBranch() (retID string) { | ||
retID = BuildBranch | ||
if retID == "" { | ||
retID = Unspecified | ||
} | ||
return | ||
} |