As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit 9010cdcc authored by Stan Hu's avatar Stan Hu
Browse files

Add support for -version argument

This will help determine the version of the binary particularly on Cloud
Native GitLab, where VERSION may not be shipped with the binaries.
parent 890bda90
No related branches found
No related tags found
No related merge requests found
.PHONY: validate verify verify_ruby verify_golang test test_ruby test_golang coverage coverage_golang setup _install build compile check clean
GO_SOURCES := $(shell find . -name '*.go')
VERSION_STRING := $(shell git describe --match v* 2>/dev/null || cat VERSION 2>/dev/null || echo unknown)
BUILD_TIME := $(shell date -u +%Y%m%d.%H%M%S)
GOBUILD_FLAGS := -ldflags "-X main.Version=$(VERSION_STRING) -X main.BuildTime=$(BUILD_TIME)"
validate: verify test
Loading
Loading
@@ -37,7 +40,7 @@ _install:
build: bin/gitlab-shell
compile: bin/gitlab-shell
bin/gitlab-shell: $(GO_SOURCES)
GOBIN="$(CURDIR)/bin" go install ./cmd/...
GOBIN="$(CURDIR)/bin" go install $(GOBUILD_FLAGS) ./cmd/...
check:
bin/check
Loading
Loading
Loading
Loading
@@ -12,7 +12,21 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/internal/logger"
)
var (
// Version is the current version of gitlab-shell
Version = "(unknown version)" // Set at build time in the Makefile
// BuildTime signifies the time the binary was build
BuildTime = "19700101.000000" // Set at build time in the Makefile
)
func main() {
// We can't use the flag library because gitlab-shell receives other arguments
// that confuse the parser.
if len(os.Args) == 2 && os.Args[1] == "-version" {
fmt.Printf("gitlab-shell %s-%s\n", Version, BuildTime)
os.Exit(0)
}
readWriter := &readwriter.ReadWriter{
Out: os.Stdout,
In: os.Stdin,
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment