From c3a752cac17e2752fc253be29b584444185b91a4 Mon Sep 17 00:00:00 2001 From: Brian Akins Date: Wed, 1 May 2019 15:58:03 -0400 Subject: [PATCH] Add Circle-CI (#36) Add circle-ci --- .circleci/config.yml | 29 +++++++++++++++++++++++++++++ script/release | 27 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .circleci/config.yml create mode 100755 script/release diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..010a625 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,29 @@ +version: 2 +jobs: + test: + docker: + - image: circleci/golang:1.12 + environment: + GOFLAGS: -mod=vendor + steps: + - checkout + - run: go test -v ./... + release: + docker: + - image: circleci/golang:1.12 + steps: + - checkout + - run: ./script/release +workflows: + version: 2 + test_and_release: + jobs: + - test + - release: + requires: + - test + filters: + branches: + ignore: /.*/ + tags: + only: /v[0-9]+(\.[0-9]+)*(-.*)*/ diff --git a/script/release b/script/release new file mode 100755 index 0000000..bcbd4ec --- /dev/null +++ b/script/release @@ -0,0 +1,27 @@ +#!/bin/bash +set -e +TAR_FILE="/tmp/goreleaser.tar.gz" +RELEASES_URL="https://github.com/goreleaser/goreleaser/releases" +test -z "$TMPDIR" && TMPDIR="$(mktemp -d)" + +last_version() { + curl -sL -o /dev/null -w %{url_effective} "$RELEASES_URL/latest" | + rev | + cut -f1 -d'/'| + rev +} + +download() { + test -z "$VERSION" && VERSION="$(last_version)" + test -z "$VERSION" && { + echo "Unable to get goreleaser version." >&2 + exit 1 + } + rm -f "$TAR_FILE" + curl -s -L -o "$TAR_FILE" \ + "$RELEASES_URL/download/$VERSION/goreleaser_$(uname -s)_$(uname -m).tar.gz" +} + +download +tar -xf "$TAR_FILE" -C "$TMPDIR" +"${TMPDIR}/goreleaser" "$@"