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

Goreleaser #394

Merged
merged 1 commit into from
Feb 5, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -621,3 +627,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