Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Goreleaser (#394)
Browse files Browse the repository at this point in the history
When publishing binaries using Goreleaser use build flags.

Also remove custom archives and checksum name_templates because
Goreleaser has reasonable defaults, see https://goreleaser.com/customization/#Archive
  • Loading branch information
Filip Nguyen committed Feb 5, 2020
1 parent 41fe4f7 commit 0188501
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
15 changes: 7 additions & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ builds:
- GOPROXY=https://proxy.golang.org
- GOSUMDB=sum.golang.org
main: ./mockgen/
archive:
format: tar.gz
wrap_in_directory: true
name_template: '{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
files:
- LICENSE
- README.md

archives:
- format: tar.gz
wrap_in_directory: true
files:
- LICENSE
- README.md
checksum:
name_template: '{{ .Binary }}-{{ .Version }}-checksums.txt'
snapshot:
name_template: "snap-{{ .Commit }}"
changelog:
Expand Down
18 changes: 16 additions & 2 deletions mockgen/mockgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const (
gomockImportPath = "github.com/golang/mock/gomock"
)

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

var (
source = flag.String("source", "", "(source mode) Input Go source file; enables source mode.")
destination = flag.String("destination", "", "Output file; defaults to stdout.")
Expand All @@ -55,14 +61,14 @@ var (
copyrightFile = flag.String("copyright_file", "", "Copyright file used to add copyright header")

debugParser = flag.Bool("debug_parser", false, "Print out parser results only.")
version = flag.Bool("version", false, "Print version.")
showVersion = flag.Bool("version", false, "Print version.")
)

func main() {
flag.Usage = usage
flag.Parse()

if *version {
if *showVersion {
printVersion()
return
}
Expand Down Expand Up @@ -633,3 +639,11 @@ func lookupPackageName(importPath string) (string, bool) {
}
return pkg.Name, true
}

func printVersion() {
if version != "" {
fmt.Printf("v%s\nCommit: %s\nDate: %s\n", version, commit, date)
} else {
printModuleVersion()
}
}
2 changes: 1 addition & 1 deletion mockgen/version.1.11.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"log"
)

func printVersion() {
func printModuleVersion() {
log.Printf("No version information is available for Mockgen compiled with " +
"version 1.11")
}
2 changes: 1 addition & 1 deletion mockgen/version.1.12.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"runtime/debug"
)

func printVersion() {
func printModuleVersion() {
if bi, exists := debug.ReadBuildInfo(); exists {
fmt.Println(bi.Main.Version)
} else {
Expand Down

0 comments on commit 0188501

Please sign in to comment.