diff --git a/.compile_binaries b/.compile_binaries new file mode 100755 index 0000000..1aa18ad --- /dev/null +++ b/.compile_binaries @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# This script compile shellcheck binaries +set -ex + +# Remove all tests to reduce binary size +./striptests + +mkdir -p deploy + +_cleanup(){ + rm -rf dist shellcheck || true +} + +if [ "$TRAVIS_OS_NAME" = 'linux' ] +then + # Linux Docker image + name="$DOCKER_BASE" + DOCKER_BUILDS="$DOCKER_BUILDS $name" + docker build -t "$name:current" . + docker run "$name:current" --version + printf '%s\n' "#!/bin/sh" "echo 'hello world'" > myscript + docker run -v "$PWD:/mnt" "$name:current" myscript + + # Copy static executable from docker image + id=$(docker create "$name:current") + docker cp "$id:/bin/shellcheck" "shellcheck" + docker rm "$id" + ls -l shellcheck + ./shellcheck myscript + for tag in $TAGS + do + cp "shellcheck" "deploy/shellcheck-$tag.linux-x86_64"; + done + + # Linux Alpine based Docker image + name="$DOCKER_BASE-alpine" + DOCKER_BUILDS="$DOCKER_BUILDS $name" + sed -e '/DELETE-MARKER/,$d' Dockerfile > Dockerfile.alpine + docker build -f Dockerfile.alpine -t "$name:current" . + docker run "$name:current" sh -c 'shellcheck --version' + + # Linux armv6hf static executable + docker run -v "$PWD:/mnt" koalaman/armv6hf-builder -c 'compile-shellcheck' + for tag in $TAGS + do + cp "shellcheck" "deploy/shellcheck-$tag.linux-armv6hf"; + done + _cleanup + + # Windows .exe + docker run --user="$UID" -v "$PWD:/appdata" koalaman/winghc cuib + for tag in $TAGS + do + cp "dist/build/ShellCheck/shellcheck.exe" "deploy/shellcheck-$tag.exe"; + done + _cleanup +fi + +if [ "$TRAVIS_OS_NAME" = 'osx' ]; +then + # Darwin x86_64 static executable + sudo ln -s /usr/local/bin/gsha512sum /usr/local/bin/sha512sum + brew install cabal-install pandoc + cabal update + cabal new-build shellcheck + for tag in $TAGS + do + cp "$HOME/.cabal/dist/build/shellcheck/shellcheck" "deploy/shellcheck-$tag.darwin-x86_64"; + done + _cleanup +fi diff --git a/.prepare_deploy b/.prepare_deploy index dcf0346..490bf62 100755 --- a/.prepare_deploy +++ b/.prepare_deploy @@ -43,8 +43,19 @@ do rm "shellcheck" done +if [ "$TRAVIS_OS_NAME" = 'osx' ]; +then + brew install gnu-tar + for file in *.darwin-x86_64 + do + base="${file%.*}" + cp "$file" "shellcheck" + gtar -cJf "$base.darwin.x86_64.tar.xz" --transform="s:^:$base/:" README.txt LICENSE.txt shellcheck + rm "shellcheck" + done +fi + for file in ./* do sha512sum "$file" > "$file.sha512sum" done - diff --git a/.travis.yml b/.travis.yml index 8a86307..25ebbeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,67 +5,40 @@ language: sh services: - docker -before_install: - - DOCKER_BASE="$DOCKER_USERNAME/shellcheck" - - DOCKER_BUILDS="" - - TAGS="" - - test "$TRAVIS_BRANCH" = master && TAGS="$TAGS latest" || true - - test -n "$TRAVIS_TAG" && TAGS="$TAGS stable $TRAVIS_TAG" || true - - echo "Tags are $TAGS" +os: + - linux + - osx + +before_install: | + DOCKER_BASE="$DOCKER_USERNAME/shellcheck" + DOCKER_BUILDS="" + TAGS="" + test "$TRAVIS_BRANCH" = master && TAGS="$TAGS latest" || true + test -n "$TRAVIS_TAG" && TAGS="$TAGS stable $TRAVIS_TAG" || true + echo "Tags are $TAGS" script: - - mkdir deploy - # Remove all tests to reduce binary size - - ./striptests - # Linux Docker image - - name="$DOCKER_BASE" - - DOCKER_BUILDS="$DOCKER_BUILDS $name" - - docker build -t "$name:current" . - - docker run "$name:current" --version - - printf '%s\n' "#!/bin/sh" "echo 'hello world'" > myscript - - docker run -v "$PWD:/mnt" "$name:current" myscript - # Copy static executable from docker image - - id=$(docker create "$name:current") - - docker cp "$id:/bin/shellcheck" "shellcheck" - - docker rm "$id" - - ls -l shellcheck - - ./shellcheck myscript - - for tag in $TAGS; do cp "shellcheck" "deploy/shellcheck-$tag.linux-x86_64"; done - # Linux Alpine based Docker image - - name="$DOCKER_BASE-alpine" - - DOCKER_BUILDS="$DOCKER_BUILDS $name" - - sed -e '/DELETE-MARKER/,$d' Dockerfile > Dockerfile.alpine - - docker build -f Dockerfile.alpine -t "$name:current" . - - docker run "$name:current" sh -c 'shellcheck --version' - # Linux armv6hf static executable - - docker run -v "$PWD:/mnt" koalaman/armv6hf-builder -c 'compile-shellcheck' - - for tag in $TAGS; do cp "shellcheck" "deploy/shellcheck-$tag.linux-armv6hf"; done - - rm -f shellcheck || true - # Windows .exe - - docker run --user="$UID" -v "$PWD:/appdata" koalaman/winghc cuib - - for tag in $TAGS; do cp "dist/build/ShellCheck/shellcheck.exe" "deploy/shellcheck-$tag.exe"; done - - rm -rf dist shellcheck || true - # Misc packaging + - ./.compile_binaries - ./.prepare_deploy -after_success: - - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" - - for repo in $DOCKER_BUILDS; - do - for tag in $TAGS; - do +after_success: | + if [ "$TRAVIS_OS_NAME" = "linux" ]; then + docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" + for repo in $DOCKER_BUILDS; do + for tag in $TAGS; do echo "Deploying $repo:current as $repo:$tag..."; docker tag "$repo:current" "$repo:$tag" || exit 1; docker push "$repo:$tag" || exit 1; done; done; + fi -after_failure: - - id - - pwd - - df -h - - find . -name '*.log' -type f -exec grep "" /dev/null {} + - - find . -ls +after_failure: | + id + pwd + df -h + find . -name '*.log' -type f -exec grep "" /dev/null {} + + find . -ls deploy: provider: gcs diff --git a/README.md b/README.md index 6b789cd..4c9e9ae 100644 --- a/README.md +++ b/README.md @@ -257,9 +257,7 @@ ShellCheck is built and packaged using Cabal. Install the package `cabal-install On MacOS (OS X), you can do a fast install of Cabal using brew, which takes a couple of minutes instead of more than 30 minutes if you try to compile it from source. - brew install cask - brew cask install haskell-platform - cabal install cabal-install + $ brew install cabal-install On MacPorts, the package is instead called `hs-cabal-install`, while native Windows users should install the latest version of the Haskell platform from @@ -512,3 +510,4 @@ Happy ShellChecking! * The wiki has [long form descriptions](https://github.com/koalaman/shellcheck/wiki/Checks) for each warning, e.g. [SC2221](https://github.com/koalaman/shellcheck/wiki/SC2221). * ShellCheck does not attempt to enforce any kind of formatting or indenting style, so also check out [shfmt](https://github.com/mvdan/sh)! +