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..."