[feat]add goreleaser support

This commit is contained in:
orange_wolf 2020-03-10 17:40:04 +08:00
parent f4d0785d6b
commit 48c504dacb
5 changed files with 80 additions and 0 deletions

2
.gitignore vendored
View File

@ -31,3 +31,5 @@ _testmain.go
# Ignore go.sum
/go.sum
.idea/
dist/

62
.goreleaser.yml Normal file
View File

@ -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:'

View File

@ -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

View File

@ -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)

2
go.mod
View File

@ -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