diff --git a/.gitignore b/.gitignore index 96ad0d3..aee9137 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ bin **/node_modules **/build docs + +dist/ +completions/ diff --git a/Makefile b/Makefile index 4e9d0fb..dd2f3fe 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ MODULE = go.linka.cloud/artifact-registry +GITHUB_REPO = linka-cloud/artifact-registry + PROJECT = artifact-registry REPOSITORY = linkacloud @@ -22,7 +24,10 @@ install: build-ui DOCKER_BUILDX_ARGS := build --pull --load --build-arg VERSION=$(VERSION) -docker: docker-build docker-push +docker: docker-build docker-scan docker-push + +docker-scan: + @trivy image --severity "HIGH,CRITICAL" --exit-code 100 $(REPOSITORY)/$(PROJECT):$(VERSION) .PHONY: docker-build docker-build: @@ -39,8 +44,33 @@ ifneq ($(TAG),) @docker image push $(REPOSITORY)/$(PROJECT):latest endif +.PHONY: completions +completions: + @rm -rf completions + @mkdir -p completions + @for shell in bash zsh fish powershell; do \ + go run ./cmd/lkar completion $$shell > completions/lkar.$$shell; \ + done + .PHONY: cli-docs cli-docs: @rm -rf ./docs/{lkar,lkard} @go run -tags=docs ./cmd/lkar docs ./docs/lkar @go run -tags=docs ./cmd/lkard docs ./docs/lkard + +PHONY: build-snapshot +build-snapshot: build-ui + @VERSION=$(VERSION) REPO=$(GITHUB_REPO) goreleaser build --snapshot --clean --parallelism 8 + +.PHONY: release-snapshot +release-snapshot: build-ui + @VERSION=$(VERSION) REPO=$(GITHUB_REPO) goreleaser release --snapshot --clean --skip=sign,publish,announce --parallelism 8 + +.PHONY: build +build: build-ui + @VERSION=$(VERSION) REPO=$(GITHUB_REPO) goreleaser build --clean --parallelism 8 + +.PHONY: release +release: build-ui + @VERSION=$(VERSION) REPO=$(GITHUB_REPO) goreleaser release --clean --parallelism 8 + diff --git a/cmd/lkar/main.go b/cmd/lkar/main.go index 84af391..d34c470 100644 --- a/cmd/lkar/main.go +++ b/cmd/lkar/main.go @@ -58,6 +58,7 @@ var ( Short: "An OCI based Artifact Registry", SilenceUsage: true, PersistentPreRunE: setup, + Version: artifact_registry.Version, } ) diff --git a/cmd/lkar/version.go b/cmd/lkar/version.go index 64a49a6..aea0447 100644 --- a/cmd/lkar/version.go +++ b/cmd/lkar/version.go @@ -25,9 +25,12 @@ import ( var ( cmdVersion = &cobra.Command{ Use: "version", - Short: "Print the version and build date of lk-artifact-registry", + Short: "Print the version informations and exit", Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("%s\n%s\n", artifact_registry.Version, artifact_registry.BuildDate) + fmt.Printf("Version: %s\n", artifact_registry.Version) + fmt.Printf("Commit: %s\n", artifact_registry.Commit) + fmt.Printf("Date: %s\n", artifact_registry.Date) + fmt.Printf("Repo: https://github.com/%s\n", artifact_registry.Repo) }, } ) diff --git a/cmd/lkard/main.go b/cmd/lkard/main.go index 73b9fec..dd819ed 100644 --- a/cmd/lkard/main.go +++ b/cmd/lkard/main.go @@ -87,6 +87,7 @@ var ( Short: "An OCI based Artifact Registry", Args: cobra.MaximumNArgs(1), SilenceUsage: true, + Version: artifact_registry.Version, Run: func(cmd *cobra.Command, args []string) { if aesKey == "" { logrus.Fatalf("environment variable $%s must be set", EnvKey) @@ -156,9 +157,13 @@ var ( }, } cmdVersion = &cobra.Command{ - Use: "version", + Use: "version", + Short: "Print the version informations and exit", Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("%s (%s)\n", artifact_registry.Version, artifact_registry.BuildDate) + fmt.Printf("Version: %s\n", artifact_registry.Version) + fmt.Printf("Commit: %s\n", artifact_registry.Commit) + fmt.Printf("Date: %s\n", artifact_registry.Date) + fmt.Printf("Repo: https://github.com/%s\n", artifact_registry.Repo) }, } ) diff --git a/version.go b/version.go index cd49770..8a61b92 100644 --- a/version.go +++ b/version.go @@ -15,6 +15,8 @@ package artifact_registry var ( - Version = "dev" - BuildDate = "" + Version = "0.0.0-dev" + Commit = "none" + Date = "" + Repo = "linka-cloud/artifact-registry" )