-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from warm-metal/version
version command and build chain
- Loading branch information
Showing
8 changed files
with
92 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/_output | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM golang:1-buster as builder | ||
|
||
WORKDIR /go/src/kubectl-dev | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
COPY .git ./.git | ||
|
||
FROM builder as linux | ||
ENV GOOS=linux | ||
COPY cmd ./cmd | ||
COPY pkg ./pkg | ||
RUN CGO_ENABLED=0 go build \ | ||
-o kubectl-dev \ | ||
-ldflags "-X github.com/warm-metal/kubectl-dev/pkg/release.Version=$(git for-each-ref --points-at=HEAD --format='%(refname:short)' refs/tags --sort=-version:refname --count=2)$(git symbolic-ref -q --short HEAD) -X github.com/warm-metal/kubectl-dev/pkg/release.Commit=$(git rev-parse HEAD)" \ | ||
./cmd/dev | ||
|
||
FROM builder as macos | ||
ENV GOOS=darwin | ||
COPY cmd ./cmd | ||
COPY pkg ./pkg | ||
RUN CGO_ENABLED=0 go build \ | ||
-o kubectl-dev \ | ||
-ldflags "-X github.com/warm-metal/kubectl-dev/pkg/release.Version=$(git for-each-ref --points-at=HEAD --format='%(refname:short)' refs/tags --sort=-version:refname --count=2)$(git symbolic-ref -q --short HEAD) -X github.com/warm-metal/kubectl-dev/pkg/release.Commit=$(git rev-parse HEAD)" \ | ||
./cmd/dev | ||
|
||
FROM bash:5 as app | ||
COPY --from=linux /go/src/kubectl-dev/kubectl-dev /usr/local/bin/ | ||
ENTRYPOINT ["tail", "-f", "/dev/null"] | ||
|
||
FROM scratch as linux-cli | ||
COPY --from=linux /go/src/kubectl-dev/kubectl-dev . | ||
|
||
FROM scratch as mac-cli | ||
COPY --from=macos /go/src/kubectl-dev/kubectl-dev . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
"github.com/warm-metal/kubectl-dev/pkg/release" | ||
) | ||
|
||
func NewVersionCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "version", | ||
Short: "Print the version information.", | ||
Run: func(_ *cobra.Command, _ []string) { | ||
fmt.Println(release.Version, release.Commit) | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package release | ||
|
||
var Version = "v0.1.0" | ||
var Commit = "" |