Skip to content

Commit

Permalink
Add version info as build vars, expose as metrics (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-helmich committed Apr 24, 2022
1 parent 171d51e commit 2bb00dd
Show file tree
Hide file tree
Showing 7 changed files with 335 additions and 11 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ jobs:
version: v1.8.3
args: check

- name: Set current date
id: set_date
run: |
echo "BUILD_DATE=$(date)" >> $GITHUB_ENV
- name: Build Goreleaser snapshot release
uses: goreleaser/goreleaser-action@v2
with:
version: v1.8.3
args: release --rm-dist --skip-publish --snapshot
args: release --rm-dist --skip-publish --snapshot
env:
BUILD_USER: ${{ github.actor }} (via Github Actions)
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ jobs:
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin quay.io
echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u helmich-bot --password-stdin
- name: Set current date
id: set_date
run: |
echo "BUILD_DATE=$(date)" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: v1.8.3
args: release --rm-dist
env:
BUILD_USER: ${{ github.actor }} (via Github Actions)
GITHUB_TOKEN: ${{ secrets.githubToken }}
10 changes: 10 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@ builds:
- GO111MODULE=on
goos:
- linux
- darwin
goarch:
- amd64
- arm64
ldflags:
- >
-s
-w
-X "github.com/prometheus/common/version.Version={{.Version}}"
-X "github.com/prometheus/common/version.Branch={{.Env.GITHUB_REF_NAME}}"
-X "github.com/prometheus/common/version.Revision={{.Env.GITHUB_SHA}}"
-X "github.com/prometheus/common/version.BuildUser={{ .Env.BUILD_USER }}"
-X "github.com/prometheus/common/version.BuildDate={{.Env.BUILD_DATE}}"
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/mitchellh/go-testing-interface v1.14.0 // indirect
github.com/mitchellh/mapstructure v1.3.3 // indirect
github.com/nxadm/tail v1.4.8
github.com/prometheus/client_golang v1.9.0
github.com/prometheus/client_golang v1.12.1
github.com/satyrius/gonx v1.3.1-0.20180709120835-47c52b995fe5
github.com/stretchr/testify v1.7.0
gopkg.in/mcuadros/go-syslog.v2 v2.3.0
Expand All @@ -16,11 +16,11 @@ require (
require (
github.com/armon/go-metrics v0.3.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-hclog v0.12.0 // indirect
github.com/hashicorp/go-immutable-radix v1.2.0 // indirect
Expand All @@ -36,10 +36,10 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.15.0 // indirect
github.com/prometheus/procfs v0.2.0 // indirect
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e // indirect
google.golang.org/protobuf v1.23.0 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
Expand Down
Loading

0 comments on commit 2bb00dd

Please sign in to comment.