Skip to content

Commit

Permalink
Add version flag (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
silas authored Nov 17, 2024
1 parent 4f403b2 commit aca343b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
FROM golang:1.23-bookworm AS go
WORKDIR /src
ARG VERSION=DEV
ADD go.mod go.sum /src/
RUN go mod download
ADD . /src
RUN mkdir -p /workspace
RUN go build -o /src/jimmy github.com/silas/jimmy
RUN go build \
-ldflags="-X 'github.com/silas/jimmy/internal/constants.Version=${VERSION}'" \
-o /src/jimmy \
github.com/silas/jimmy

FROM gcr.io/distroless/base-debian12
COPY --from=go /workspace /src/jimmy /
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ Flags:
-h, --help help for jimmy
-i, --instance string set Spanner instance ID
-p, --project string set Google project ID
-v, --version version for jimmy
```
1 change: 1 addition & 0 deletions internal/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func New() *cobra.Command {

cmd := &cobra.Command{
Use: constants.AppName,
Version: constants.Version,
SilenceUsage: false,
SilenceErrors: true,
}
Expand Down
5 changes: 5 additions & 0 deletions internal/constants/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package constants

var (
Version = "DEV"
)
File renamed without changes.

0 comments on commit aca343b

Please sign in to comment.