From 5b2ec71feed26db2c05fc58bdcb6d48a4f447fb1 Mon Sep 17 00:00:00 2001 From: Mike Simons Date: Fri, 15 Sep 2017 13:54:47 +0200 Subject: [PATCH 1/3] Adds github release publishing from travis --- .travis.yml | 16 +++++++++++----- build | 5 ++++- test | 2 ++ tests/basic_test.go | 12 ++++++++---- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7d3890..6854f94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: go - sudo: false - go: - 1.5.x - 1.6.x @@ -9,13 +7,21 @@ go: - 1.8.x - 1.9.x - tip - +deploy: + provider: releases + api_key: $GITHUB_TOKEN + file: + - bin/certstrap-${TRAVIS_TAG}-linux-amd64 + - bin/certstrap-${TRAVIS_TAG}-darwin-amd64 + - bin/certstrap-${TRAVIS_TAG}-windows-amd64 + skip_cleanup: true + on: + tags: true + go: 1.8 install: - go get -d -t -v ./... - go get github.com/tools/godep - before_script: - ./build - script: - ./test diff --git a/build b/build index e182592..d3d8181 100755 --- a/build +++ b/build @@ -4,6 +4,7 @@ ORG_PATH="github.com/square" REPO_PATH="${ORG_PATH}/certstrap" +BUILD_TAG="${TRAVIS_TAG:-$(git describe --all | sed -e's/.*\///g')}" export GOPATH=${PWD}/gopath @@ -13,4 +14,6 @@ ln -s ${PWD} $GOPATH/src/${REPO_PATH} eval $(go env) -go build -o bin/certstrap ${REPO_PATH} +GOARCH=amd64 GOOS=linux go build -o bin/certstrap-${BUILD_TAG}-linux-amd64 ${REPO_PATH} +GOARCH=amd64 GOOS=darwin go build -o bin/certstrap-${BUILD_TAG}-darwin-amd64 ${REPO_PATH} +GOARCH=amd64 GOOS=windows go build -o bin/certstrap-${BUILD_TAG}-windows-amd64 ${REPO_PATH} diff --git a/test b/test index 113e48c..f9a1f58 100755 --- a/test +++ b/test @@ -8,6 +8,8 @@ if [ -z "$PKG" ]; then PKG="cmd depot pkix tests" fi +export BUILD_TAG="${TRAVIS_TAG:-$(git describe --all | sed -e's/.*\///g')}" + # Unit tests echo for mod in $PKG; do diff --git a/tests/basic_test.go b/tests/basic_test.go index 3b8f57a..8b16ae5 100644 --- a/tests/basic_test.go +++ b/tests/basic_test.go @@ -23,15 +23,19 @@ import ( "os/exec" "strings" "testing" + "runtime" + "fmt" + "os" ) const ( - binPath = "../bin/certstrap" - depotDir = ".certstrap-test" - hostname = "host1" - passphrase = "123456" + depotDir = ".certstrap-test" + hostname = "host1" + passphrase = "123456" ) +var binPath = fmt.Sprintf("../bin/certstrap-%s-%s-amd64", os.Getenv("BUILD_TAG"), runtime.GOOS) + func run(command string, args ...string) (string, string, error) { var stdoutBytes, stderrBytes bytes.Buffer args = append([]string{"--depot-path", depotDir}, args...) From fa82aba33d2d029a951a3c43d90b7c64f3c01630 Mon Sep 17 00:00:00 2001 From: Cedric Staub Date: Wed, 20 Sep 2017 16:04:24 -0700 Subject: [PATCH 2/3] Add GitHub API key for automatic releases --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6854f94..bf49b48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,11 @@ language: go sudo: false go: - 1.5.x -- 1.6.x -- 1.7.x -- 1.8.x - 1.9.x -- tip deploy: provider: releases - api_key: $GITHUB_TOKEN + api_key: + secure: 'kewugKeaEgDvNMaapSbhMTgWXO1tje4sbyF8D77lbceOviTfKZkDKuuwVSwTU1NTKuHk5DnC00Rrfy7d4HP1xPT94P4AnI6oEjUvQvi43U8Ub/YGbrwTAZpqUyZJWwmkHaEikeFRIRuyTnHztM8/IQaEQyOvxtu2NOFnMVCpagQ=' file: - bin/certstrap-${TRAVIS_TAG}-linux-amd64 - bin/certstrap-${TRAVIS_TAG}-darwin-amd64 From 9cafaff5cc8792b695cd891265784e0608112673 Mon Sep 17 00:00:00 2001 From: Cedric Staub Date: Wed, 20 Sep 2017 16:07:39 -0700 Subject: [PATCH 3/3] Update Go for release build to 1.9 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bf49b48..adf5e90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ deploy: skip_cleanup: true on: tags: true - go: 1.8 + go: 1.9 install: - go get -d -t -v ./... - go get github.com/tools/godep