Skip to content

Commit

Permalink
[cicd/goreleaser] WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
lnquy committed Jun 16, 2020
1 parent eaab155 commit 828473d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
# you may remove this if you don't need go generate
- go generate ./...

builds:
- id: hcron
main: ./cmd/hcron/main.go
binary: hcron
flags:
- --trimpath
- -v
ldflags:
- -s -w -X main.build={{.Version}}
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- freebsd
- windows
goarch:
- 386
- amd64
ignore:
- goos: darwin
goarch: 386
skip: false

archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
10 changes: 10 additions & 0 deletions cmd/hcron/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ import (
)

var (
version string // Will be injected at build time

fLocale string
fInputFilePath string
fDayOfWeekStartsAtOne bool
fUse24HourTimeFormat bool
fVerbose bool
fVersion bool

acceptedCharsRegex = regexp.MustCompile(`^[wWlL /?,*#\-0-9]*$`)
)
Expand All @@ -28,6 +31,7 @@ func init() {
flag.BoolVar(&fDayOfWeekStartsAtOne, "dow-starts-at-one", false, "Is day of the week starts at 1 (Monday-Sunday: 1-7)")
flag.BoolVar(&fUse24HourTimeFormat, "24-hour", false, "Output description in 24 hour time format")
flag.BoolVar(&fVerbose, "verbose", false, "Output description in verbose format")
flag.BoolVar(&fVersion, "v", false, "Print app version then exit")
}

func main() {
Expand All @@ -44,6 +48,12 @@ Examples:
}
flag.Parse()

// Print app version
if fVersion {
fmt.Println(version)
return
}

exprDesc, locale, err := getExpressionDescriptor()
if err != nil {
fmt.Printf("failed to init expression descriptor: %s", err)
Expand Down

0 comments on commit 828473d

Please sign in to comment.