From ee9f8dacedaf4bf5c744b0b4fbd1068fabb85d07 Mon Sep 17 00:00:00 2001 From: Xabier Larrakoetxea Date: Mon, 13 May 2019 07:03:01 +0200 Subject: [PATCH] Add publishing artifact Signed-off-by: Xabier Larrakoetxea --- .circleci/config.yml | 39 +++++++++++++++++-- Makefile | 2 +- .../{travis-release.sh => ci-release.sh} | 6 +-- 3 files changed, 40 insertions(+), 7 deletions(-) rename hack/scripts/{travis-release.sh => ci-release.sh} (58%) diff --git a/.circleci/config.yml b/.circleci/config.yml index bcafaef..f236714 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ -version: 2 +version: 2.1 jobs: - build: + test: docker: - image: circleci/golang:1.12 environment: @@ -9,4 +9,37 @@ jobs: working_directory: /go/src/github.com/slok/grafterm steps: - checkout - - run: make ci \ No newline at end of file + - run: make ci + + release: + docker: + - image: circleci/golang:1.12 + environment: + GO111MODULE: "on" + GOPROXY: https://gocenter.io + working_directory: /go/src/github.com/slok/grafterm + steps: + - checkout + - run: make ci-release + - run: + name: "Publish Release on GitHub" + command: | + go get github.com/tcnksm/ghr + ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./bin/ + +workflows: + version: 2 + main: + jobs: + - test: + filters: + tags: + only: /.*/ + - release: + requires: + - test + filters: + branches: + ignore: /.*/ + tags: + only: /^v.*/ diff --git a/Makefile b/Makefile index 6ad9e6d..2ea10ab 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ MOCKS_CMD := ./hack/scripts/mockgen.sh DOCKER_RUN_CMD := docker run --env ostype=$(OSTYPE) -v ${PWD}:$(DOCKER_GO_SERVICE_PATH) --rm -it $(SERVICE_NAME) BUILD_BINARY_CMD := VERSION=${VERSION} ./hack/scripts/build.sh BUILD_IMAGE_CMD := IMAGE_VERSION=${VERSION} ./hack/scripts/build-image.sh -CI_RELEASE_CMD := ./hack/scripts/travis-release.sh +CI_RELEASE_CMD := ./hack/scripts/ci-release.sh DEPS_CMD := GO111MODULE=on go mod tidy && GO111MODULE=on go mod vendor diff --git a/hack/scripts/travis-release.sh b/hack/scripts/ci-release.sh similarity index 58% rename from hack/scripts/travis-release.sh rename to hack/scripts/ci-release.sh index e8d183d..e253671 100755 --- a/hack/scripts/travis-release.sh +++ b/hack/scripts/ci-release.sh @@ -2,13 +2,13 @@ current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -if [[ -n ${TRAVIS_TAG} ]]; then - echo "Tag ${TRAVIS_TAG}. building releases..." +if [[ -n ${CIRCLE_TAG} ]]; then + echo "Tag ${CIRCLE_TAG}. building releases..." archs=( Linux Darwin Windows ) for arch in "${archs[@]}" do - VERSION=${TRAVIS_TAG} ostype=${arch} ${current_dir}/build.sh + VERSION=${CIRCLE_TAG} ostype=${arch} ${current_dir}/build.sh done else echo "no tag, skipping release..."