diff --git a/.travis.yml b/.travis.yml index 6c905b9e..afbedab9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ go: - 1.9.x script: go test -v . ./regressiontests before_deploy: - - ./package.sh + - ./scripts/package.sh deploy: provider: releases api_key: @@ -18,7 +18,10 @@ deploy: file: - dist/gometalinter-*.zip - dist/gometalinter-*.tar.bz2 + - dist/gometalinter-*.sha256 skip_cleanup: true on: tags: true repo: alecthomas/gometalinter + condition: $TRAVIS_GO_VERSION =~ ^1\.9\.[0-9]+$ + diff --git a/README.md b/README.md index 2ca9c20a..2ec15d26 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,13 @@ +- [Installing](#installing) - [Editor integration](#editor-integration) - [Supported linters](#supported-linters) - [Configuration file](#configuration-file) -- [Installing](#installing) + - [`Format` key](#format-key) + - [Format Methods](#format-methods) + - [Adding Custom linters](#adding-custom-linters) - [Comment directives](#comment-directives) - [Quickstart](#quickstart) - [FAQ](#faq) @@ -39,6 +42,16 @@ eg. It is intended for use with editor/IDE integration. +## Installing + +There are two options for installing gometalinter. + +1. Install a stable version, eg. `go get -u gopkg.in/alecthomas/gometalinter.v2`. + I will generally only tag a new stable version when it has passed the Travis + regression tests. The downside is that the binary will be called `gometalinter.v2`. +2. Install from HEAD with: `go get -u github.com/alecthomas/gometalinter`. + This has the downside that changes to gometalinter may break. + ## Editor integration - [SublimeLinter plugin](https://github.com/alecthomas/SublimeLinter-contrib-gometalinter). @@ -161,16 +174,6 @@ Example: $ gometalinter --linter='vet:go tool vet -printfuncs=Infof,Debugf,Warningf,Errorf:PATH:LINE:MESSAGE' . ``` -## Installing - -There are two options for installing gometalinter. - -1. Install a stable version, eg. `go get -u gopkg.in/alecthomas/gometalinter.v2`. - I will generally only tag a new stable version when it has passed the Travis - regression tests. The downside is that the binary will be called `gometalinter.v2`. -2. Install from HEAD with: `go get -u github.com/alecthomas/gometalinter`. - This has the downside that changes to gometalinter may break. - ## Comment directives gometalinter supports suppression of linter messages via comment directives. The diff --git a/scripts/installer.sh b/scripts/installer.sh new file mode 100755 index 00000000..b500ea84 --- /dev/null +++ b/scripts/installer.sh @@ -0,0 +1,28 @@ +#!/bin/sh +set -e + +TAR_FILE="/tmp/gometalinter.tar.gz" +RELEASES_URL="https://github.com/gometalinter/gometalinter/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 gometalinter version." >&2 + exit 1 + } + rm -f "$TAR_FILE" + curl -s -L -o "$TAR_FILE" \ + "$RELEASES_URL/download/$VERSION/gometalinter_$(uname -s)_$(uname -m).tar.gz" +} + +download +tar -xf "$TAR_FILE" -C "$TMPDIR" +"${TMPDIR}/gometalinter" "$@" diff --git a/package.sh b/scripts/package.sh similarity index 83% rename from package.sh rename to scripts/package.sh index fe365d25..27001511 100755 --- a/package.sh +++ b/scripts/package.sh @@ -59,9 +59,11 @@ function install_go_binary() { function packager() { if [ "$GOOS" = "windows" ]; then - zip -9 -r -o "${1}".zip "${1}" + zip -9 -r -o "${1}".zip "${1}" 1>&2 + echo "${1}".zip else - tar cvfj "${1}".tar.bz2 "${1}" + tar cvfj "${1}".tar.bz2 "${1}" 1>&2 + echo "${1}".tar.bz2 fi } @@ -78,14 +80,7 @@ for GOOS in linux darwin windows; do DEST="${PWD}/dist/gometalinter-${TAG}-${GOOS}-${GOARCH}" install -d -m 755 "${DEST}/linters" install -m 644 COPYING "${DEST}" - cat << EOF > "${DEST}/README.txt" -gometalinter is a tool to normalise the output of Go linters. -See https://github.com/alecthomas/gometalinter for more information. - -This is a binary distribution of gometalinter ${TAG}. - -All binaries must be installed in the PATH for gometalinter to operate correctly. -EOF + install -m 644 README.md "${DEST}" echo "${DEST}" export GOOS GOARCH @@ -99,6 +94,7 @@ EOF install_go_binary $(basename ${LINTER}) "${DEST}/linters" done - (cd "${DEST}/.." && packager "$(basename ${DEST})") + OUTPUT="$(cd "${PWD}/dist" && packager "$(basename ${DEST})")" + (cd "${PWD}/dist" && shasum -a 256 "${OUTPUT}" > "${OUTPUT}.sha256") done done