Skip to content

Commit

Permalink
Upload to assets to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
koalaman committed Mar 8, 2020
1 parent 7b99823 commit 9b66bc2
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
57 changes: 57 additions & 0 deletions .github_deploy
Original file line number Diff line number Diff line change
@@ -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

5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -36,6 +36,7 @@ script:
- ./striptests
- set -ex; build_"$BUILD"; set +x;
- ./.prepare_deploy
- ./.github_deploy

after_failure: |
id
Expand All @@ -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
4 changes: 2 additions & 2 deletions Dockerfile.multi-arch
Original file line number Diff line number Diff line change
Expand Up @@ -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}"; \
Expand Down

0 comments on commit 9b66bc2

Please sign in to comment.