-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add build flags #76
base: main
Are you sure you want to change the base?
Add build flags #76
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Ignore files | ||
*.md | ||
*.sh | ||
*.yml | ||
*.yaml | ||
.gitignore | ||
|
||
# Ignore folders | ||
.github/ | ||
.git/ | ||
contrib/ | ||
|
||
# Don't include a previously built binary | ||
unbound_exporter |
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] | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,28 @@ | ||||||||||||||||||
package build | ||||||||||||||||||
|
||||||||||||||||||
const Unspecified = "Unspecified" | ||||||||||||||||||
|
||||||||||||||||||
// BuildID is set by the compiler (using -ldflags "-X util.BuildID $(git rev-parse --short HEAD)") | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
// and is used by GetID | ||||||||||||||||||
var BuildID string | ||||||||||||||||||
Comment on lines
+5
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
// BuildBranch is set by the compiler and is used by GetBranch | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
var BuildBranch string | ||||||||||||||||||
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
// GetBuildID identifies what build is running. | ||||||||||||||||||
func GetID() (BuildID string) { | ||||||||||||||||||
if BuildID != "" { | ||||||||||||||||||
return BuildID | ||||||||||||||||||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
return Unspecified | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// GetBranch identifies the building host | ||||||||||||||||||
func GetBranch() (BuildBranch string) { | ||||||||||||||||||
if BuildBranch != "" { | ||||||||||||||||||
return BuildBranch | ||||||||||||||||||
Comment on lines
+21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
return Unspecified | ||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.