Skip to content

Commit

Permalink
Move to Travis CI and add deploy script (#24)
Browse files Browse the repository at this point in the history
* Use travis CI

* Remove .github
  • Loading branch information
danieljharvey committed Jun 4, 2020
1 parent 0e3a17c commit cad6111
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 15 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/main.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
addons:
apt:
packages:
- libgmp-dev
language: c
sudo: false
cache:
directories:
- $HOME/.local/bin
- $HOME/.stack
os:
- linux
- osx
before_install:
- sh tools/install-stack.sh
- sh tools/install-ghr.sh
script:
- stack setup
- stack test
- stack build --ghc-options -O2 --pedantic
after_success:
- sh tools/attach-binary.sh
22 changes: 22 additions & 0 deletions tools/attach-binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set -o errexit -o verbose

if test ! "$TRAVIS_TAG"
then
echo 'This is not a release build.'
elif test ! "$GITHUB_TOKEN"
then
echo 'The GITHUB_TOKEN environment variable is not set!'
exit 1
else
echo "Attaching binary for $TRAVIS_OS_NAME to $TRAVIS_TAG..."
OWNER="$(echo "$TRAVIS_REPO_SLUG" | cut -f1 -d/)"
REPO="$(echo "$TRAVIS_REPO_SLUG" | cut -f2 -d/)"
BIN="$(stack path --local-install-root)/bin/$REPO"
BUNDLE_NAME="$REPO-$TRAVIS_TAG-$TRAVIS_OS_NAME.tar.gz"
cp "$BIN" "./$REPO"
chmod +x "./$REPO"
tar -czf "$BUNDLE_NAME" "$REPO"
echo "SHA256:"
shasum -a 256 "$BUNDLE_NAME"
ghr -t "$GITHUB_TOKEN" -u "$OWNER" -r "$REPO" --replace "$(git describe --tags)" "$BUNDLE_NAME"
fi
20 changes: 20 additions & 0 deletions tools/install-ghr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set -o errexit -o verbose

if test ! "$TRAVIS_TAG"
then
echo 'This is not a release build.'
else
if [ "$TRAVIS_OS_NAME" = "linux" ]
then
ARCH="linux"
else
ARCH="darwin"
fi
echo "Installing ghr"
URL="https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_${ARCH}_386.zip"
curl -L ${URL} > ghr.zip
mkdir -p "$HOME/bin"
export PATH="$HOME/bin:$PATH"
unzip ghr.zip -d "$HOME/bin"
rm ghr.zip
fi
17 changes: 17 additions & 0 deletions tools/install-stack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set -o errexit -o verbose

if test -f "$HOME/.local/bin/stack"
then
echo 'Stack is already installed.'
else
echo "Installing Stack for $TRAVIS_OS_NAME..."
URL="https://www.stackage.org/stack/$TRAVIS_OS_NAME-x86_64"
curl --location "$URL" > stack.tar.gz
gunzip stack.tar.gz
tar -x -f stack.tar --strip-components 1
mkdir -p "$HOME/.local/bin"
mv stack "$HOME/.local/bin/"
rm stack.tar
fi

stack --version

0 comments on commit cad6111

Please # to comment.