From 5cb14d95b7061fe32a25ac8b38d822b52efdd47f Mon Sep 17 00:00:00 2001 From: Julian Meyer Date: Tue, 7 May 2019 18:09:17 -0700 Subject: [PATCH] Add build and deploy script to travis --- .gitignore | 1 + .travis.yml | 12 +++++++++++- deploy.sh | 20 ++++++++++++++++++++ go.mod | 1 + go.sum | 2 ++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 deploy.sh diff --git a/.gitignore b/.gitignore index e168caa8..84514a9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.prof *.test +dist # binaries synapsebeacon diff --git a/.travis.yml b/.travis.yml index 5bfbaf1c..0607f1ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,10 @@ env: go: - 1.11.4 +sudo: required +services: + - docker + # Only clone the most recent commit. git: depth: 1 @@ -17,6 +21,9 @@ git: notifications: email: false +before_install: + - go get github.com/tcnksm/ghr + # Anything in before_script that returns a nonzero exit code will flunk the # build and immediately stop. It's sorta like having set -e enabled in bash. # Make sure golangci-lint is vendored. @@ -31,4 +38,7 @@ script: - make integrationtests after_success: -- bash <(curl -s https://codecov.io/bash) + - bash <(curl -s https://codecov.io/bash) + - ./deploy.sh + +secure: "UnH2bHP7/LZy3S4iXuno+9xbo1oRsVAUIOLdj4g2EJIJvAVjHd4eHcHy3+mCoF9KXYIszyDn6KEKIeegAissqsOnKDFBsSPs0Lmuy2AEfWELVjC7BF5Ld3/lejhdFwOTDFHy3qTN0015MTIucjx/mz8gamHBRzJI8EKYT+hanOagBgVnRLFz35MqXDvups+iXM6hCoXbwSlBQBKSP281fudMnfIokOV02EA74pS5aADcYoCcZc2MUlwTcSbhNy/z9eJrpVNk3KsC7dsIeqXwoUnRYJ9/64HvikMhgqeT49LCTMaUhCh5HSmJT8Ab3rsKyM023Raxat2XiMdKRidCz0XW1K2Jzj6BuRzCqTy7SIxQ752Is57B2ililoDfmY0qxB0dIca1gJihf0r1np0ijW0PYmBIZ/ubLclTaJknK7CqMWLyd9ydedzA3QFgdBVgd4qapamJU99w49YeKP7LAzXgj2Ye0SeuPVdEFNKUPn3r5wtMgNQhpND7AbqWt3BhFa6SP3X5cfEM4BjuyKHofLl4b0JJefa+EFK73Dy94ac8QCrmRgBbfqPqvsIN9UOvg3bla1sMRF84YXeL98NXLOYdMPoYrUL8pEdG9xnhO2MC7+rGzSkck4gmhQv2LtL/XqXiYBSDeLf8/+I/dADUzGI6gmvfD4Vqga66JVfayLQ=" diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 00000000..67d1543f --- /dev/null +++ b/deploy.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ ! -z "$TRAVIS_TAG" ] && + [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + echo "This will deploy!" + + # Cross-compile for all platforms + export CGO_ENABLED=1 + docker pull karalabe/xgo-latest + go get github.com/karalabe/xgo + mkdir dist/ && cd dist/ + xgo --targets=windows/amd64,darwin/amd64,linux/amd64 ../cmd/beacon + xgo --targets=windows/amd64,darwin/amd64,linux/amd64 ../cmd/validator + xgo --targets=windows/amd64,darwin/amd64,linux/amd64 ../cmd/keygen + chmod +x * + # Upload to GitHub Release page + ghr --username phoreproject -t $GITHUB_TOKEN --replace --prerelease --debug $TRAVIS_TAG . +else + echo "This will not deploy!" +fi diff --git a/go.mod b/go.mod index 639478c3..bd82e395 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ require ( github.com/go-test/deep v1.0.1 github.com/golang/protobuf v1.3.0 github.com/google/pprof v0.0.0-20190502144155-8358a9778bd1 // indirect + github.com/karalabe/xgo v0.0.0-20190301120235-2d6d1848fb02 // indirect github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.2.8 // indirect github.com/libp2p/go-libp2p v0.0.1 diff --git a/go.sum b/go.sum index a19c2e85..dfd2bab3 100644 --- a/go.sum +++ b/go.sum @@ -85,6 +85,8 @@ github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8 h1:bspPhN+oKYFk5f github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8/go.mod h1:Ly/wlsjFq/qrU3Rar62tu1gASgGw6chQbSh/XgIIXCY= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= +github.com/karalabe/xgo v0.0.0-20190301120235-2d6d1848fb02 h1:nI4Q7WQDcng8eRmi8bRP1SXlJIYLkgdgR7ZhJuzPbhs= +github.com/karalabe/xgo v0.0.0-20190301120235-2d6d1848fb02/go.mod h1:iYGcTYIPUvEWhFo6aKUuLchs+AV4ssYdyuBbQJZGcBk= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=