diff --git a/.github_deploy b/.github_deploy new file mode 100755 index 0000000..8f648ed --- /dev/null +++ b/.github_deploy @@ -0,0 +1,57 @@ +#!/bin/bash +set -x +shopt -s extglob + +if [[ "$TRAVIS_SECURE_ENV_VARS" != "true" ]] +then + echo >&2 "Missing TRAVIS_SECURE_ENV_VARS. Skipping GitHub deployment." + exit 0 +fi + +install_deps() { + version="2.7.0" # 2.14.1 fails to overwrite duplicates + case "$(uname)" in + Linux) + sudo apt-get update + sudo apt-get install curl + curl -L "https://github.com/github/hub/releases/download/v$version/hub-linux-amd64-$version.tgz" | tar xvz --strip-components=1 "hub-linux-amd64-$version/bin/hub" + ;; + Darwin) + curl -L "https://github.com/github/hub/releases/download/v$version/hub-darwin-amd64-$version.tgz" | tar xvz --strip-components=1 "hub-darwin-amd64-$version/bin/hub" + ;; + *) + echo "Unknown: $(uname)" + exit 1 + ;; + esac + + hub_path="$PWD/bin/hub" + hub() { + "$hub_path" "$@" + } +} +install_deps + +export EDITOR="touch" + +# Sanity check +hub release show latest || exit 1 + +for tag in $TAGS +do + if ! hub release show "$tag" + then + echo "Creating new release $tag" + git show --no-patch --format='format:%B' > description + hub release create -F description "$tag" + fi + + files=() + for file in deploy/* + do + [[ $file == *.@(xz|gz|zip) ]] || continue + files+=(-a "$file") + done + hub release edit "${files[@]}" "$tag" || exit 1 +done + diff --git a/.travis.yml b/.travis.yml index 6a6c435..ac53f0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ jobs: before_install: | DOCKER_BASE="$DOCKER_USERNAME/shellcheck" DOCKER_BUILDS="" - TAGS="" + export TAGS="" test "$TRAVIS_BRANCH" = master && TAGS="$TAGS latest" || true test -n "$TRAVIS_TAG" && TAGS="$TAGS stable $TRAVIS_TAG" || true echo "Tags are $TAGS" @@ -36,6 +36,7 @@ script: - ./striptests - set -ex; build_"$BUILD"; set +x; - ./.prepare_deploy + - ./.github_deploy after_failure: | id @@ -54,5 +55,5 @@ deploy: local_dir: deploy on: repo: koalaman/shellcheck - condition: $TRAVIS_BUILD_STAGE_NAME = Test + condition: $TRAVIS_BUILD_STAGE_NAME = "Build binaries" all_branches: true diff --git a/Dockerfile.multi-arch b/Dockerfile.multi-arch index 193e762..217aa74 100644 --- a/Dockerfile.multi-arch +++ b/Dockerfile.multi-arch @@ -11,8 +11,8 @@ RUN set -x; \ if [ "${arch}" = 'armv7l' ]; then \ arch='armv6hf'; \ fi; \ - url_base='https://shellcheck.storage.googleapis.com/'; \ - tar_file="shellcheck-${tag}.linux.${arch}.tar.xz"; \ + url_base='https://github.com/koalaman/shellcheck/releases/download/'; \ + tar_file="${tag}/shellcheck-${tag}.linux.${arch}.tar.xz"; \ wget "${url_base}${tar_file}" -O - | tar xJf -; \ mv "shellcheck-${tag}/shellcheck" /bin/; \ rm -rf "shellcheck-${tag}"; \