Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ before:
builds:
- env:
- CGO_ENABLED=0
ldflags:
- -s -w -X github.com/release-tools/since/cmd.Version={{ .Version }}
goos:
- linux
- windows
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM golang:1.20 AS builder

ARG VERSION=dev
WORKDIR /src

COPY go.mod go.sum ./
RUN go mod download

COPY . .

RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /since
RUN CGO_ENABLED=0 go build -ldflags="-s -w -X github.com/release-tools/since/cmd.Version=${VERSION}" -o /since

FROM scratch

Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export CGO_ENABLED ?= 0

VERSION ?= dev

.PHONY: build
build:
go build -o since
go build -ldflags="-s -w -X github.com/release-tools/since/cmd.Version=$(VERSION)" -o since

.PHONY: fmt
fmt:
Expand Down
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"os"
)

var Version = "dev"

var rootArgs struct {
logLevel string
quiet bool
Expand All @@ -38,6 +40,7 @@ var rootCmd = &cobra.Command{
func init() {
cobra.OnInitialize(initLogging)

rootCmd.Version = Version
rootCmd.PersistentFlags().StringVarP(&rootArgs.logLevel, "log-level", "l", "debug", "Log level (debug, info, warn, error, fatal, panic)")
rootCmd.PersistentFlags().BoolVarP(&rootArgs.quiet, "quiet", "q", false, "Disable logging (useful for scripting)")
}
Expand Down
Loading