Skip to content

Commit

Permalink
refactor(build): Remove Release Phase and only use Version
Browse files Browse the repository at this point in the history
`Version` is SemVer so we can add release candidate and other
designations as required.

Continue to use `dev` as default version, overridable by building with
ldflag set.
  • Loading branch information
kskewes-sf committed Mar 13, 2022
1 parent 3a49565 commit fa05b8b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
FROM golang:1.15 as build
ARG RELEASE_PHASE
ARG VERSION

WORKDIR /app
COPY ./ ./

ENV LD_RELEASE_PHASE="-X github.com/spinnaker/spin/version.ReleasePhase=${RELEASE_PHASE}"
ENV LD_VERSION="-X github.com/spinnaker/spin/version.Version=${VERSION}"

RUN GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build \
-ldflags "${LD_VERSION} ${LD_RELEASE_PHASE}" .
-ldflags "${LD_VERSION}" .

FROM alpine

Expand Down
14 changes: 1 addition & 13 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,13 @@

package version

import (
"fmt"
)

// Main version number being run right now.
var Version = ""

// A pre-release marker for the version. If this is an empty string,
// then the release is a final release. Otherwise this is a pre-release
// version e.g. "dev", "alpha", etc.
var ReleasePhase = "dev"
var Version = "dev"

// User Agent name set in requests.
const UserAgent = "Spin-CLI"

// String prints the version of the Spin CLI.
func String() string {
if ReleasePhase != "" {
return fmt.Sprintf("%s-%s", Version, ReleasePhase)
}
return Version
}

0 comments on commit fa05b8b

Please sign in to comment.