diff --git a/.travis.yml b/.travis.yml index b201781..4c97142 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,8 @@ env: - GO_BOOTSTRAP_VERSION=1.7.5 - GOPATH="${HOME}/gopath" - PATH="${HOME}/bin:${PATH}" - - SHELLCHECK_URL="https://s3.amazonaws.com/travis-blue-public/binaries/ubuntu/14.04/x86_64/shellcheck-0.4.4.tar.bz2" - - SHFMT_URL="https://github.com/mvdan/sh/releases/download/v1.0.0/shfmt_v1.0.0_linux_amd64" + - SHELLCHECK_URL="https://s3.amazonaws.com/travis-blue-public/binaries/ubuntu/14.04/x86_64/shellcheck-0.4.6.tar.bz2" + - SHFMT_URL="https://github.com/mvdan/sh/releases/download/v1.3.1/shfmt_v1.3.1_linux_amd64" matrix: - TARGET=native GO_VERSIONS="$(sed -n -e '/^[^#]/p' < .testdata/sample-binary-$UNAME) $(sed -n -e '/^[^#]/p' < .testdata/source-$UNAME)" - TARGET=arm GO_VERSIONS="master" @@ -34,9 +34,10 @@ script: curl -sSL "${SHELLCHECK_URL}" | tar -C "${HOME}/bin" -xjf -; shellcheck --version; fi -- if ! command -v shfmt ; then - curl -sSL "${SHFMT_URL}" -o "${HOME}/bin/shfmt" ; - chmod +x "${HOME}/bin/shfmt" ; +- if [ $UNAME = linux ] && [[ $(shfmt -version 2>/dev/null) != v1.3.1 ]] ; then + curl -sSL "${SHFMT_URL}" -o "${HOME}/bin/shfmt"; + chmod +x "${HOME}/bin/shfmt"; + shfmt -version; fi - if [ $UNAME = linux ]; then make lint; fi - git diff --exit-code diff --git a/CHANGELOG.md b/CHANGELOG.md index 30aa5f7..e956057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,29 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] + +### Added + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security + +## [1.2.0] - 2017-07-09 + +### Added +- support for `stable` alias which auto-updates to point at latest release +- flag/command `-k|--known|known` to list known go versions + +### Fixed +- always set `GOROOT` when installing official binaries + ## [1.1.0] - 2016-12-07 ### Added - Windows binary downloads @@ -80,7 +103,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - Initial release! -[Unreleased]: https://github.com/travis-ci/gimme/compare/v1.1.0...HEAD +[Unreleased]: https://github.com/travis-ci/gimme/compare/v1.2.0...HEAD +[1.2.0]: https://github.com/travis-ci/gimme/compare/v1.1.0...v1.2.0 [1.1.0]: https://github.com/travis-ci/gimme/compare/v1.0.4...v1.1.0 [1.0.0]: https://github.com/travis-ci/gimme/compare/v0.2.4...v1.0.0 [0.2.4]: https://github.com/travis-ci/gimme/compare/v0.2.3...v0.2.4 diff --git a/gimme b/gimme index 973d775..ce495c1 100755 --- a/gimme +++ b/gimme @@ -49,9 +49,9 @@ set -o pipefail [[ ${GIMME_DEBUG} ]] && set -x -GIMME_VERSION="v1.1.0" +GIMME_VERSION="v1.2.0" GIMME_COPYRIGHT="Copyright (c) 2016 Dan Buch, Tianon Gravi, Travis CI GmbH" -GIMME_LICENSE_URL="https://raw.githubusercontent.com/travis-ci/gimme/v1.1.0/LICENSE" +GIMME_LICENSE_URL="https://raw.githubusercontent.com/travis-ci/gimme/v1.2.0/LICENSE" export GIMME_VERSION export GIMME_COPYRIGHT export GIMME_LICENSE_URL @@ -101,7 +101,7 @@ _binary() { urls=( "${GIMME_DOWNLOAD_BASE}/go${version}.${GIMME_OS}-${arch}.tar.gz" ) - if [[ "${GIMME_OS}" = 'darwin' && "${GIMME_BINARY_OSX}" ]]; then + if [[ "${GIMME_OS}" == 'darwin' && "${GIMME_BINARY_OSX}" ]]; then urls=( "${GIMME_DOWNLOAD_BASE}/go${version}.${GIMME_OS}-${arch}-${GIMME_BINARY_OSX}.tar.gz" "${urls[@]}" @@ -155,8 +155,8 @@ _checkout() { git reset -q --hard "origin/${1}" \ || git reset -q --hard "origin/go${1}" \ || { [ "${1}" = 'tip' ] && git reset -q --hard origin/master; } \ - || git reset -q --hard "refs/tags/${1}" \ - || git reset -q --hard "refs/tags/go${1}" + || git reset -q --hard "refs/tags/${1}" \ + || git reset -q --hard "refs/tags/go${1}" } 2>/dev/null) } @@ -253,12 +253,12 @@ _env() { # Tools like `gimme` are the reason that GOROOT-in-env exists. echo - if [[ "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTOS)" = "${GIMME_OS}" ]]; then + if [[ "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTOS)" == "${GIMME_OS}" ]]; then echo 'unset GOOS;' else echo 'export GOOS="'"${GIMME_OS}"'";' fi - if [[ "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTARCH)" = "${GIMME_ARCH}" ]]; then + if [[ "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTARCH)" == "${GIMME_ARCH}" ]]; then echo 'unset GOARCH;' else echo 'export GOARCH="'"${GIMME_ARCH}"'";' @@ -281,7 +281,7 @@ _env_alias() { return fi - if [[ "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTOS)" = "${GIMME_OS}" && "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTARCH)" = "${GIMME_ARCH}" ]]; then + if [[ "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTOS)" == "${GIMME_OS}" && "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTARCH)" == "${GIMME_ARCH}" ]]; then local dest="${GIMME_ENV_PREFIX}/go${GIMME_GO_VERSION}.env" cp "${2}" "${dest}" ln -sf "${dest}" "${GIMME_ENV_PREFIX}/latest.env" @@ -390,7 +390,7 @@ _list_versions() { local cleaned="${d##*/go}" cleaned="${cleaned%%.${GIMME_OS}.*}" echo -en "${cleaned}" - if [[ "${cleaned}" = "${current_version}" ]]; then + if [[ "${cleaned}" == "${current_version}" ]]; then echo -en ' <= current' >&2 fi echo @@ -423,8 +423,12 @@ _realpath() { _get_curr_stable() { local stable="${GIMME_VERSION_PREFIX}/stable" + local now_secs + now_secs="$(date +%s)" + local stable_age + stable_age="$(_stat_unix "${stable}" 2>/dev/null || echo 0)" local age - age=$(($(date +%s) - $(_stat_unix "${stable}" 2>/dev/null || echo 0))) + age=$((now_secs - stable_age)) if [[ "${age}" -gt 86400 ]]; then _update_stable "${stable}" @@ -610,7 +614,7 @@ case "${GIMME_ARCH}" in echo >&2 "try go1.5 or newer" exit 1 fi - if [[ "${GIMME_HOSTOS}" = "linux" && "${GIMME_HOSTARCH}" != "${GIMME_ARCH}" ]]; then + if [[ "${GIMME_HOSTOS}" == "linux" && "${GIMME_HOSTARCH}" != "${GIMME_ARCH}" ]]; then : "${GIMME_CC_FOR_TARGET:="aarch64-linux-gnu-gcc"}" fi ;; diff --git a/runtests b/runtests index 0e6f34a..99f6480 100755 --- a/runtests +++ b/runtests @@ -21,7 +21,7 @@ _test_native() { echo "---> eval \$(./gimme ${v})" ( eval "$(./gimme "${v}")" - [[ "$(go env GOOS)" = "$(go env GOHOSTOS)" && "$(go env GOARCH)" = "$(go env GOHOSTARCH)" ]] || exit 1 + [[ "$(go env GOOS)" == "$(go env GOHOSTOS)" && "$(go env GOARCH)" == "$(go env GOHOSTARCH)" ]] || exit 1 ) || exit 1 done } @@ -31,7 +31,7 @@ _test_arm() { echo "---> eval \$(GIMME_OS=linux GIMME_ARCH=arm ./gimme ${v})" ( eval "$(GIMME_OS=linux GIMME_ARCH=arm ./gimme "${v}")" - [[ "$(go env GOOS)" = 'linux' && "$(go env GOARCH)" = 'arm' ]] || exit 1 + [[ "$(go env GOOS)" == 'linux' && "$(go env GOARCH)" == 'arm' ]] || exit 1 ) || exit 1 done } @@ -42,11 +42,11 @@ _test_arm64() { echo "---> skipping ${v} because it probably won't work o_o" continue fi - if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then cgo=1; else cgo=0; fi + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cgo=1; else cgo=0; fi echo "---> eval \$(GIMME_OS=linux GIMME_ARCH=arm64 GIMME_CGO_ENABLED=$cgo ./gimme $v)" ( eval "$(GIMME_OS=linux GIMME_ARCH=arm64 GIMME_CGO_ENABLED=$cgo ./gimme "${v}")" - [[ "$(go env GOOS)" = 'linux' && "$(go env GOARCH)" = 'arm64' ]] || exit 1 + [[ "$(go env GOOS)" == 'linux' && "$(go env GOARCH)" == 'arm64' ]] || exit 1 ) || exit 1 done }