diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 894a57b4..db005eb8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,9 @@ -name: Go package +name: Core Build on: [push] jobs: - build: + ubuntu-build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -27,7 +27,7 @@ jobs: CI: "" - name: go build - run: go build -v ./... + run: go build -ldflags "-X github.com/openziti-test-kitchen/zrok/build.Version=${{ github.ref }} -X github.com/openziti-test-kitchen/zrok/build.Hash=${{ github.sha }}" ./... - name: test run: go test -v ./... \ No newline at end of file diff --git a/build/metadata.go b/build/metadata.go new file mode 100644 index 00000000..bafe5aa5 --- /dev/null +++ b/build/metadata.go @@ -0,0 +1,14 @@ +package build + +import "fmt" + +var Version string +var Hash string + +func String() string { + if Version != "" { + return fmt.Sprintf("%v [%v]", Version, Hash) + } else { + return "" + } +} diff --git a/controller/controller.go b/controller/controller.go index 2c4912b3..77c16b96 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -16,8 +16,6 @@ var str *store.Store var mtr *metricsAgent var idb influxdb2.Client -const version = "v0.2.0" - func Run(inCfg *Config) error { cfg = inCfg diff --git a/controller/enable.go b/controller/enable.go index f536792d..b84bb432 100644 --- a/controller/enable.go +++ b/controller/enable.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "github.com/go-openapi/runtime/middleware" + "github.com/openziti-test-kitchen/zrok/build" "github.com/openziti-test-kitchen/zrok/controller/store" "github.com/openziti-test-kitchen/zrok/rest_model_zrok" "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity" @@ -165,7 +166,7 @@ func (self *enableHandler) createEdgeRouterPolicy(id string, edge *rest_manageme func (self *enableHandler) zrokTags() *rest_model_edge.Tags { return &rest_model_edge.Tags{ SubTags: map[string]interface{}{ - "zrok": version, + "zrok": build.String(), }, } } diff --git a/controller/tunnel.go b/controller/tunnel.go index 1b7f570b..003307e1 100644 --- a/controller/tunnel.go +++ b/controller/tunnel.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "github.com/go-openapi/runtime/middleware" + "github.com/openziti-test-kitchen/zrok/build" "github.com/openziti-test-kitchen/zrok/controller/store" "github.com/openziti-test-kitchen/zrok/model" "github.com/openziti-test-kitchen/zrok/rest_model_zrok" @@ -264,7 +265,7 @@ func (self *tunnelHandler) proxyUrl(svcName string) string { func (self *tunnelHandler) zrokTags(svcName string) *rest_model.Tags { return &rest_model.Tags{ SubTags: map[string]interface{}{ - "zrok": version, + "zrok": build.String(), "zrok-service-name": svcName, }, } diff --git a/controller/version.go b/controller/version.go index 320a4f57..38bf3a39 100644 --- a/controller/version.go +++ b/controller/version.go @@ -2,9 +2,11 @@ package controller import ( "github.com/go-openapi/runtime/middleware" + "github.com/openziti-test-kitchen/zrok/build" + "github.com/openziti-test-kitchen/zrok/rest_model_zrok" "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/metadata" ) func versionHandler(_ metadata.VersionParams) middleware.Responder { - return metadata.NewVersionOK().WithPayload(version) + return metadata.NewVersionOK().WithPayload(rest_model_zrok.Version(build.String())) }