Skip to content

Commit

Permalink
Initial addition of goreleaser config
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu Vachon committed Feb 2, 2019
1 parent 8fce577 commit a9834ea
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Env
.envrc

## Go
/dist
/vendor
48 changes: 48 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
project_name: zap-pretty
before:
hooks:
- go mod download
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
archive:
replacements:
darwin: Darwin
linux: Linux
windows: Windows
amd64: x86_64
files:
- LICENSE.md
- README.md
- CHANGELOG.md
checksum:
name_template: 'checksums.txt'
sign:
cmd: keybase
args:
- sign
- --infile
- $artifact
- --binary
- --outfile
- $signature
- --detached
signature: ${artifact}.sig
artifacts: checksum
snapshot:
name_template: "{{ .Tag }}-dirty"
brew:
github:
owner: maoueh
name: homebrew-tap
homepage: "https://github.com/maoueh/zap-pretty"
description: "A tiny binary to pretty-print Zap production JSON lines"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^support:'
- '^chore:'
21 changes: 21 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"bytes"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"io/ioutil"
Expand All @@ -21,6 +22,13 @@ import (
var debug = log.New(ioutil.Discard, "", 0)
var severityToColor map[string]Color

// Provided via ldflags by goreleaser automatically
var (
version = "dev"
commit = "none"
date = "unknown"
)

var errNonZapLine = errors.New("non-zap line")

func init() {
Expand All @@ -43,7 +51,16 @@ type processor struct {
output io.Writer
}

var versionFlag = flag.Bool("version", false, "Prints version information and exit")

func main() {
flag.Parse()

if *versionFlag {
printVersion()
os.Exit(0)
}

processor := &processor{
scanner: bufio.NewScanner(os.Stdin),
output: os.Stdout,
Expand All @@ -52,6 +69,10 @@ func main() {
processor.process()
}

func printVersion() {
fmt.Printf("zap-pretty %s (commit: %s, date: %v)\n", version, commit, date)
}

func (p *processor) process() {
first := true
for p.scanner.Scan() {
Expand Down

0 comments on commit a9834ea

Please sign in to comment.