Skip to content

Commit

Permalink
Autopublish release after accept PR to master branch
Browse files Browse the repository at this point in the history
Close #23
  • Loading branch information
rekby authored Apr 28, 2019
1 parent 3a3eab2 commit 39effc0
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
lets-proxy.iml
log.txt
storage/
output/
config.toml


Expand Down
47 changes: 30 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
env:
- GO111MODULE=on GOFLAGS=-mod=vendor CGO_ENABLED=0 TAG_PREFIX="v0.20.0"

language: go

addons:
apt:
packages:
- dos2unix

go:
- "1.12.4"
- "master"

env:
global:
- GO111MODULE=on
matrix:
- GOFLAGS=
- GOFLAGS=-mod=vendor
matrix:
exclude:
- go: "master"
env: GOFLAGS=-mod=vendor
fast_finish: true
allow_failures:
- go: "master"
- env: GOFLAGS=


services:
- docker
Expand All @@ -34,3 +25,25 @@ after_script:
- go get -mod= golang.org/x/tools/cmd/cover
- go get -mod= github.com/mattn/goveralls
- goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN

before_deploy:
- git config --local user.name "$GIT_NAME"
- git config --local user.email "$GIT_EMAIL"
- export TRAVIS_TAG="$TAG_PREFIX.$TRAVIS_BUILD_NUMBER"
- git tag $TRAVIS_TAG
- go get -mod= github.com/mitchellh/gox
- mkdir -p output
- OS_ARCH_BUILDS="darwin/amd64 linux/386 linux/amd64 linux/arm freebsd/386 freebsd/amd64 freebsd/arm windows/386 windows/amd64"
- gox --mod=vendor -osarch "$OS_ARCH_BUILDS" --ldflags "-X \"main.VERSION=$TRAVIS_TAG commit $TRAVIS_COMMIT\"" --output="output/lets-proxy_{{.OS}}_{{.Arch}}" -verbose --rebuild ./cmd/
- bash tests/make_archives.sh

deploy:
skip_cleanup: true
provider: releases
on:
repo: rekby/lets-proxy2
branch: master
api_key: $GITHUB_TOKEN
file_glob: true
file: output/*

1 change: 1 addition & 0 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import "flag"
var (
configFileP = flag.String("config", "", "Path to config file. Empty for no read config.")
defaultConfigP = flag.Bool("print-default-config", false, "Write default config to stdout and exit.")
versionP = flag.Bool("version", false, "print version and exit")
)
8 changes: 8 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net"
"net/http"
"os"
"runtime"
"strings"

_ "github.com/kardianos/minwinsvc"
Expand All @@ -20,6 +21,8 @@ import (
"go.uber.org/zap"
)

var VERSION = "custom" // need be var becouse it redefine by --ldflags "-X main.VERSION" during autobuild

const defaultDirMode = 0700

func main() {
Expand All @@ -33,6 +36,11 @@ func main() {
os.Exit(0)
}

if *versionP {
fmt.Printf("Version: '%v', Os: '%v', Arch: '%v'\n", VERSION, runtime.GOOS, runtime.GOARCH)
return
}

startProgram(getConfig(globalContext))
}

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/gojuno/minimock v0.0.0-20190201083043-bbb4f602d884
github.com/kardianos/minwinsvc v0.0.0-20151122163309-cad6b2b879b0
github.com/maxatome/go-testdeep v1.0.8
github.com/mitchellh/gox v1.0.1 // indirect
github.com/pelletier/go-toml v1.3.0
github.com/rekby/zapcontext v0.0.3
github.com/satori/go.uuid v1.2.0
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/gojuno/minimock v0.0.0-20190130082935-96af809257c4/go.mod h1:iOiCj/Xd
github.com/gojuno/minimock v0.0.0-20190201083043-bbb4f602d884 h1:/aJrUbmqgRvJgQrmzIdqeWJI0nG3H+APPnBReOuFnug=
github.com/gojuno/minimock v0.0.0-20190201083043-bbb4f602d884/go.mod h1:m23ur753eqrqUyg8lovbtFUCEu2mBDo1YEfqZKZPwRw=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8=
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/heschik/goimports v0.0.0-20181107214206-01b9d28a5b21/go.mod h1:OojSIbPeQjVvyxj5CBXMXtxP55vfvTHhWE8eKDpj6SM=
github.com/hexdigest/gowrap v1.1.1/go.mod h1:BJ3dVLFoWfoXxzpVf+q8UxFtPBz2j0RYwuELxA8qYOg=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
Expand All @@ -24,6 +26,10 @@ github.com/marwan-at-work/vgop v0.0.0-20180824202541-054e5a7d7b48/go.mod h1:8stA
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/maxatome/go-testdeep v1.0.8 h1:OORprsdGMEDRo1diHCQzxCAaZFWKlHDrBnPttC4wL8g=
github.com/maxatome/go-testdeep v1.0.8/go.mod h1:Vcp0RXXOMhUTw2S2HRmUIqHQpG2Oxz+HM/WSWK7yXto=
github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI=
github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4=
github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pelletier/go-toml v1.3.0 h1:e5+lF2E4Y2WCIxBefVowBuB0iHrUH4HZ8q+6mGF7fJc=
Expand Down
30 changes: 30 additions & 0 deletions tests/make_archives.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -ev

go run cmd/*.go --print-default-config > output/config_default.toml_

cd output

cp ../README.md ./README.md
unix2dos -n README.md README.txt

for FILE in `ls`; do
expr match "$FILE" '^lets-proxy_' > /dev/null || continue
echo "$FILE"
if expr match "$FILE" '^lets-proxy_windows' > /dev/null; then
mv "$FILE" lets-proxy.exe
unix2dos -n config_default.toml_ config_default.toml
zip "${FILE%.exe}.zip" lets-proxy.exe README.txt config_default.toml
rm config_default.toml
rm lets-proxy.exe
else
mv "$FILE" lets-proxy
cp config_default.toml_ config_default.toml
tar -zcvf "${FILE%.exe}.tar.gz" lets-proxy README.md config_default.toml
rm config_default.toml
rm lets-proxy
fi
done

rm config_default.toml_ README.md README.txt
ls

0 comments on commit 39effc0

Please sign in to comment.