diff --git a/.travis.yml b/.travis.yml index e38fbdd..1da28b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,33 @@ language: go - +sudo: false go: - - 1.15.x \ No newline at end of file + - tip # Latest go version + +before_install: + # gox simplifies building for multiple architectures + - go get github.com/mitchellh/gox + +install: + - # skip + +script: + - go get -t -v ./... + - diff -u <(echo -n) <(gofmt -d .) + - go vet $(go list ./... | grep -v /vendor/) + - gox -cgo -os="linux" -arch="amd64 arm arm64" -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-X main.Version=`git rev-parse --short HEAD`" -verbose ./... + +deploy: + provider: releases + skip_cleanup: true # Important, otherwise the build output would be purged. + api_key: + # *encrypted* GitHub key, as the output of the Travis CI CLI tool + secure: TODO... + file: + - dist/wg-portal_linux_amd64 + - dist/wg-portal_linux_arm64 + - dist/wg-portal_linux_arm + - dist/wg-portal.env + - dist/wg-portal.service + on: + repo: h44z/wg-portal + tags: true # The deployment happens only if the commit has a tag. diff --git a/Makefile b/Makefile index 5265ea1..7ebbaf3 100644 --- a/Makefile +++ b/Makefile @@ -10,15 +10,14 @@ IMAGE=h44z/wg-portal all: dep build -build: dep $(addsuffix -amd64,$(addprefix $(BUILDDIR)/,$(BINARIES))) - cp scripts/wg-portal.service $(BUILDDIR) - cp scripts/wg-portal.env $(BUILDDIR) - -build-cross-plat: dep build $(addsuffix -arm,$(addprefix $(BUILDDIR)/,$(BINARIES))) $(addsuffix -arm64,$(addprefix $(BUILDDIR)/,$(BINARIES))) +build: dep + mkdir -p $(BUILDDIR) cp scripts/wg-portal.service $(BUILDDIR) cp scripts/wg-portal.env $(BUILDDIR) + gox -cgo -os="linux" -arch="amd64 arm arm64" -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-X main.Version=`git rev-parse --short HEAD`" -verbose ./... dep: + $(GOCMD) get github.com/mitchellh/gox $(GOCMD) mod download validate: dep diff --git a/cmd/wg-portal/main.go b/cmd/wg-portal/main.go index 7febe38..d814b2f 100644 --- a/cmd/wg-portal/main.go +++ b/cmd/wg-portal/main.go @@ -12,13 +12,15 @@ import ( "github.com/sirupsen/logrus" ) +var Version string = "unknown (local build)" + func main() { _ = setupLogger(logrus.StandardLogger()) c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP) - logrus.Infof("Starting WireGuard Portal Server...") + logrus.Infof("Starting WireGuard Portal Server [%s]...", Version) // Context for clean shutdown ctx, cancel := context.WithCancel(context.Background()) diff --git a/go.mod b/go.mod index 8096c73..d7c1adf 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/jordan-wright/email v4.0.1-0.20200917010138-e1c00e156980+incompatible github.com/kelseyhightower/envconfig v1.4.0 github.com/milosgajdos/tenus v0.0.3 + github.com/mitchellh/gox v1.0.1 // indirect github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.7.0 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e