diff --git a/.gitignore b/.gitignore index ce8abec..98b0e38 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ _testmain.go # Ignore go.sum /go.sum +.idea/ +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..b5ab74d --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,62 @@ +# 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: + - main: ./cmd/transocks/main.go + env: + - CGO_ENABLED=0 + ldflags: + - -X main.VERSION={{.Version}} + goos: + - windows + - darwin + - linux + - freebsd + goarch: + - amd64 + - 386 + - arm + - arm64 + goarm: + - 6 + - 7 + ignore: + - goos: windows + goarch: arm + - goos: windows + goarch: arm64 + - goos: darwin + goarch: arm + - goos: darwin + goarch: arm64 + - goos: freebsd + goarch: arm + - goos: freebsd + goarch: arm64 +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 + format_overrides: + - goos: windows + format: zip + files: + - README*.md + - LICENSE + - ./cmd/transocks/*.toml +snapshot: + name_template: "{{ .Tag }}" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc09ce..d2ef373 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [1.1.2] - 2020-03-10 + +### Added +- Add goreleaser support +- Add version flag for transocks cmd + ## [1.1.1] - 2019-03-16 ### Changed diff --git a/cmd/transocks/main.go b/cmd/transocks/main.go index ad39070..f734412 100644 --- a/cmd/transocks/main.go +++ b/cmd/transocks/main.go @@ -5,6 +5,7 @@ import ( "fmt" "net" "net/url" + "os" "github.com/BurntSushi/toml" "github.com/cybozu-go/log" @@ -23,8 +24,10 @@ const ( ) var ( + VERSION = "Unknown" configFile = flag.String("f", "/etc/transocks.toml", "TOML configuration file path") + showVersion = flag.Bool("v", false, "show version and exit") ) func loadConfig() (*transocks.Config, error) { @@ -74,6 +77,11 @@ func serve(lns []net.Listener, c *transocks.Config) { func main() { flag.Parse() + if *showVersion { + fmt.Println(VERSION) + os.Exit(0) + } + c, err := loadConfig() if err != nil { log.ErrorExit(err) diff --git a/go.mod b/go.mod index 83eebc1..49644ad 100644 --- a/go.mod +++ b/go.mod @@ -8,3 +8,5 @@ require ( golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3 golang.org/x/sys v0.0.0-20180906133057-8cf3aee42992 ) + +go 1.13