Skip to content

Commit

Permalink
fix: consistent version format
Browse files Browse the repository at this point in the history
- trim `v` if it exists in internal.Version
- trim `v` from tags when building Helm packages and Docker images
  • Loading branch information
mxyng committed Mar 15, 2022
1 parent d24e8e2 commit 31ecc2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tag := $(patsubst v%,%,$(shell git describe --tags))
version := $(tag:v%=%)

generate:
go generate ./...
Expand All @@ -15,7 +16,7 @@ test-all:

.PHONY: helm
helm:
helm package -d $@ helm/charts/* --version $(tag) --app-version $(tag)
helm package -d $@ helm/charts/* --version $(version) --app-version $(version)
helm repo index helm

helm/lint:
Expand Down Expand Up @@ -74,13 +75,13 @@ dev/clean:
helm $(NS) uninstall infra || true

docker:
docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg BUILDVERSION=$(tag) --build-arg TELEMETRY_WRITE_KEY=${TELEMETRY_WRITE_KEY} --build-arg CRASH_REPORTING_DSN=${CRASH_REPORTING_DSN} . -t infrahq/infra:$(tag)
docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg BUILDVERSION=$(version) --build-arg TELEMETRY_WRITE_KEY=${TELEMETRY_WRITE_KEY} --build-arg CRASH_REPORTING_DSN=${CRASH_REPORTING_DSN} . -t infrahq/infra:$(version)

release: goreleaser
goreleaser release -f .goreleaser.yml --rm-dist

release/docker:
docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg BUILDVERSION=$(tag) --build-arg TELEMETRY_WRITE_KEY=${TELEMETRY_WRITE_KEY} --build-arg CRASH_REPORTING_DSN=${CRASH_REPORTING_DSN} . -t infrahq/infra:$(tag) -t infrahq/infra
docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg BUILDVERSION=$(version) --build-arg TELEMETRY_WRITE_KEY=${TELEMETRY_WRITE_KEY} --build-arg CRASH_REPORTING_DSN=${CRASH_REPORTING_DSN} . -t infrahq/infra:$(version) -t infrahq/infra

release/helm: helm
aws s3 --region us-east-2 sync helm s3://helm.infrahq.com --exclude "*" --include "index.yaml" --include "*.tgz"
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"os"
"strings"
"text/tabwriter"

"github.com/infrahq/infra/internal"
Expand All @@ -14,7 +15,7 @@ func version() error {
defer w.Flush()

fmt.Fprintln(w)
fmt.Fprintln(w, "Client:\t", internal.Version)
fmt.Fprintln(w, "Client:\t", strings.TrimPrefix(internal.Version, "v"))

// Note that we use the client to get this version, but it is in fact the server version
client, err := defaultAPIClient()
Expand All @@ -33,7 +34,7 @@ func version() error {
return nil
}

fmt.Fprintln(w, "Server:\t", version.Version)
fmt.Fprintln(w, "Server:\t", strings.TrimPrefix(version.Version, "v"))
fmt.Fprintln(w)

return nil
Expand Down

0 comments on commit 31ecc2a

Please sign in to comment.