Skip to content

Commit 3902fa4

Browse files
authored
[main] Fix version meta (#798)
* Fix bug with BRO prod binaries missing version/git/date meta * Add conditional macOS target for easier local dev * nit: BRO is starting here not the controllers yet
1 parent 6d1f4d3 commit 3902fa4

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

.goreleaser.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,33 @@ builds:
1717
- -static
1818
- -s
1919
- -X github.com/rancher/backup-restore-operator/cmd/operator/version.Version={{.Version}}
20-
- -X github.com/rancher/backup-restore-operator/cmd/operator/version.Commit={{.Commit}}
20+
- -X github.com/rancher/backup-restore-operator/cmd/operator/version.GitCommit={{.Commit}}
2121
- -X github.com/rancher/backup-restore-operator/cmd/operator/version.Date={{.Date}}
2222
flags:
2323
- -trimpath
2424
env:
2525
- CGO_ENABLED=0
26+
27+
# macOS build, only when GOOS_DARWIN_DEV is set
28+
- id: backup-restore-operator-darwin
29+
main: ./cmd/operator/main.go
30+
goos:
31+
- darwin
32+
goarch:
33+
- amd64
34+
- arm64
35+
binary: backup-restore-operator
36+
ldflags:
37+
- -s
38+
- -X github.com/rancher/backup-restore-operator/cmd/operator/version.Version={{.Version}}
39+
- -X github.com/rancher/backup-restore-operator/cmd/operator/version.GitCommit={{.Commit}}
40+
- -X github.com/rancher/backup-restore-operator/cmd/operator/version.Date={{.Date}}
41+
flags:
42+
- -trimpath
43+
env:
44+
- CGO_ENABLED=0
45+
skip: '{{ not (index .Env "GOOS_DARWIN_DEV") }}'
46+
2647
archives:
2748
- id: backup-restore-operator
2849
builds:

cmd/operator/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func main() {
5353
logrus.Tracef("Loglevel set to [%v]", logrus.TraceLevel)
5454
}
5555

56-
logrus.Infof("Starting backup-restore controller version %s (%s) [built at %s]", version.Version, version.GitCommit, version.Date)
56+
logrus.Infof("Starting backup-restore-operator version %s (%s) [built at %s]", version.Version, version.GitCommit, version.Date)
5757
ctx := signals.SetupSignalContext()
5858
restKubeConfig, err := kubeconfig.GetNonInteractiveClientConfig(KubeConfig).ClientConfig()
5959
if err != nil {

scripts/build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ if [ "$(uname)" = "Linux" ]; then
1010
OTHER_LINKFLAGS="-extldflags -static -s -w"
1111
fi
1212

13-
LINKFLAGS="-X github.com/rancher/backup-restore-operator/cmd/operator/main.Version=$VERSION"
14-
LINKFLAGS="-X github.com/rancher/backup-restore-operator/cmd/operator/main.GitCommit=$COMMIT $LINKFLAGS"
13+
LINKFLAGS="-X github.com/rancher/backup-restore-operator/cmd/operator/version.Version=$VERSION"
14+
LINKFLAGS="-X github.com/rancher/backup-restore-operator/cmd/operator/version.GitCommit=$COMMIT $LINKFLAGS"
15+
LINKFLAGS="-X github.com/rancher/backup-restore-operator/cmd/operator/version.Date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") $LINKFLAGS"
1516

1617
CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o "bin/backup-restore-operator" ./cmd/operator/main.go

0 commit comments

Comments
 (0)