This repository was archived by the owner on Mar 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ VERSION_MAJOR ?= 0
2
2
VERSION_MINOR ?= 2
3
3
VERSION_BUILD ?= 0
4
4
5
+ VERSION ?= v$(VERSION_MAJOR ) .$(VERSION_MINOR ) .$(VERSION_BUILD )
6
+
5
7
GOOS ?= $(shell go env GOOS)
6
8
GOARCH = amd64
7
9
BUILD_DIR ?= ./out
@@ -17,13 +19,14 @@ BUILD_PACKAGE = $(REPOPATH)
17
19
# container_image_ostree_stub allows building the library without requiring the libostree development libraries
18
20
# container_image_openpgp forces a Golang-only OpenPGP implementation for signature verification instead of the default cgo/gpgme-based implementation
19
21
GO_BUILD_TAGS := "container_image_ostree_stub containers_image_openpgp"
22
+ GO_LDFLAGS := "-X $(REPOPATH ) /version.version=$(VERSION ) "
20
23
GO_FILES := $(shell go list -f '{{join .Deps "\n"}}' $(BUILD_PACKAGE ) | grep $(ORG ) | xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}')
21
24
22
25
$(BUILD_DIR ) /$(PROJECT ) : out/$(PROJECT ) -$(GOOS ) -$(GOARCH )
23
26
cp $(BUILD_DIR ) /$(PROJECT ) -$(GOOS ) -$(GOARCH ) $@
24
27
25
28
$(BUILD_DIR ) /$(PROJECT ) -% -$(GOARCH ) : $(GO_FILES ) $(BUILD_DIR )
26
- GOOS=$* GOARCH=$(GOARCH ) go build -tags $(GO_BUILD_TAGS ) -o $@ $(BUILD_PACKAGE )
29
+ GOOS=$* GOARCH=$(GOARCH ) go build -tags $(GO_BUILD_TAGS ) -ldflags $( GO_LDFLAGS ) - o $@ $(BUILD_PACKAGE )
27
30
28
31
$(BUILD_DIR ) :
29
32
mkdir -p $(BUILD_DIR )
Original file line number Diff line number Diff line change
1
+ package cmd
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/GoogleCloudPlatform/container-diff/version"
7
+ "github.com/spf13/cobra"
8
+ )
9
+
10
+ var versionCmd = & cobra.Command {
11
+ Use : "version" ,
12
+ Short : "Print the version of container-diff" ,
13
+ Long : `Print the version of container-diff.` ,
14
+ Run : func (command * cobra.Command , args []string ) {
15
+ fmt .Println (version .GetVersion ())
16
+ },
17
+ }
18
+
19
+ func init () {
20
+ RootCmd .AddCommand (versionCmd )
21
+ }
Original file line number Diff line number Diff line change
1
+ package version
2
+
3
+ var version = "v0.0.0-unset"
4
+
5
+ func GetVersion () string {
6
+ return version
7
+ }
You can’t perform that action at this time.
0 commit comments