Skip to content

Commit

Permalink
add a goreleaser config
Browse files Browse the repository at this point in the history
  • Loading branch information
jrockway committed Nov 23, 2020
1 parent 820f9d1 commit 95492f9
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ coverage.html
testlog
log
*.log

# goreleaser outputs
dist/
66 changes: 66 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
project_name: jlog
env_files:
github_token: ~/.github_token
before:
hooks:
- go mod download
- go test ./...
- golangci-lint run
builds:
- id: jlog
dir: .
main: ./cmd/jlog/main.go
binary: jlog
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm
- arm64
ignore:
- goos: darwin
goarch: arm
- goos: darwin
goarch: arm64
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
ldflags:
- "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X
main.date={{.CommitDate}} -X main.builtBy=goreleaser"
mod_timestamp: "{{.CommitTimestamp}}"
flags: -trimpath
archives:
- id: jlog
builds:
- jlog
format: binary
wrap_in_directory: false
name_template: "jlog_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
release:
github:
owner: jrockway
name: json-logs
ids:
- jlog
draft: true
prerelease: auto
name_template: "jlog {{.Version}}"
disable: false
source:
enabled: false
14 changes: 11 additions & 3 deletions cmd/jlog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ import (
"github.com/mattn/go-isatty"
)

var (
version = "dev"
commit = "none"
date = "unknown"
builtBy = "unknown"
)

type output struct {
NoElideDuplicates bool `long:"no-elide" description:"Disable eliding repeated fields. By default, fields that have the same value as the line above them have their values replaced with '↑'." env:"JLOG_NO_ELIDE_DUPLICATES"`
RelativeTimestamps bool `short:"r" long:"relative" description:"Print timestamps as a duration since the program started instead of absolute timestamps." env:"JLOG_RELATIVE_TIMESTAMPS"`
Expand All @@ -30,9 +37,9 @@ type output struct {
}

type general struct {
JQ string `short:"e" description:"A jq program to run on the processed input; use this to ignore certain lines, add fields, etc."`
JQ string `short:"e" description:"A jq program to run on each record in the processed input; use this to ignore certain lines, add fields, etc. Hint: 'select(condition)' will remove lines that don't match 'condition'."`
NoColor bool `short:"M" long:"no-color" description:"Disable the use of color." env:"JLOG_FORCE_MONOCHROME"`
NoMonochrome bool `short:"C" long:"no-monochrome" description:"Force the use of color." ENV:"JLOG_FORCE_COLOR"`
NoMonochrome bool `short:"C" long:"no-monochrome" description:"Force the use of color. Note: the short flag will change in a future release." ENV:"JLOG_FORCE_COLOR"`
Profile string `long:"profile" description:"If set, collect a CPU profile and write it to this file."`
}

Expand Down Expand Up @@ -60,7 +67,8 @@ func main() {

if _, err := fp.Parse(); err != nil {
if ferr, ok := err.(*flags.Error); ok && ferr.Type == flags.ErrHelp {
fmt.Fprintf(os.Stderr, "jlog - Search and pretty-print your JSON logs.\n\nMore info: https://github.com/jrockway/json-logs\n")
fmt.Fprintf(os.Stderr, "jlog - Search and pretty-print your JSON logs.\nMore info: https://github.com/jrockway/json-logs\n")
fmt.Fprintf(os.Stderr, "Version %s (%s) built on %s by %s\n", version, commit, date, builtBy)
fmt.Fprintf(os.Stderr, ferr.Message)
os.Exit(2)
}
Expand Down

0 comments on commit 95492f9

Please sign in to comment.