Skip to content

Commit

Permalink
refactor(ci): Correctly pass Version to Docker builds and remove Rele…
Browse files Browse the repository at this point in the history
…ase Phase var (#328)

* refactor(docker): Consolidate on single Dockerfile

Also correctly pass Version & Release Phase values via ldflags to `go
build` so `spin --version` outputs correct values.

* chore(ci): Remove redundant build.sh file

Only `./Dockerfile` was calling `build.sh` and it doesn't in previous
commit.

Future CI jobs can run `go build` directly supplying OS & ARCH matrix and
LDFLAGS.

For local development we can simply run `go build`.

* refactor(build): Remove Release Phase and only use Version

`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 authored Mar 18, 2022
1 parent 6ccf799 commit 9e12725
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 106 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ ARG VERSION
WORKDIR /app
COPY ./ ./

RUN ./build.sh --go-os linux --go-arch amd64 --version "${VERSION:-}"
ENV LD_VERSION="-X github.com/spinnaker/spin/version.Version=${VERSION}"

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

FROM alpine

Expand Down
9 changes: 0 additions & 9 deletions Dockerfile.slim

This file was deleted.

83 changes: 0 additions & 83 deletions build.sh

This file was deleted.

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 9e12725

Please sign in to comment.