-
Notifications
You must be signed in to change notification settings - Fork 218
Build macOS binaries with Travis #1101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
132def3
Build macOS binaries with Travis
f-f ea32a64
Update .travis.yml
f-f 26e88be
Update .travis.yml
f-f 8aadcf1
Update .travis.yml
f-f e6434dc
API_KEY → GITHUB_OAUTH_TOKEN
f-f 2ec2c53
Move functions to external script
f-f 8c642e4
Blob stack install in a single block
f-f ab1e0f4
gsed → sed
f-f acba8b6
Address review
f-f 2ddcf8b
Typo
f-f 5695463
Remove before_deploy stage
f-f 19c6cc2
Merge branch 'master' into f-f/travis-macos
f-f File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
get_cabal_version() { cat $1/$1.cabal | grep '^Version: ' | sed -e 's/^Version: //g'; } | ||
|
||
mk_release_name() { echo "$1-$(get_cabal_version $1)-x86_64-macos.tar.bz2"; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,72 @@ | ||
# This file has been generated -- see https://github.com/hvr/multi-ghc-travis | ||
language: c | ||
sudo: false | ||
sudo: required | ||
|
||
language: generic | ||
|
||
cache: | ||
directories: | ||
- $HOME/.cabsnap | ||
- $HOME/.cabal/packages | ||
|
||
before_cache: | ||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log | ||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar | ||
- $HOME/.ghc | ||
- $HOME/.cabal | ||
- $HOME/.stack | ||
- $HOME/.local/bin | ||
- $TRAVIS_BUILD_DIR/.stack-work | ||
|
||
matrix: | ||
include: | ||
- env: CABALVER=1.24 GHCVER=8.0.1 DEPLOY_GITHUB_RELEASE=true | ||
compiler: ": #GHC 8.0.1" | ||
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}} | ||
- env: CABALVER=1.24 GHCVER=8.0.1 DEPLOY_GITHUB_RELEASE=true | ||
compiler: ": #GHC 8.0.1" | ||
os: osx | ||
# Build only on macOS | ||
- env: BUILD=stack | ||
compiler: ": #stack default osx" | ||
os: osx | ||
|
||
# Build only master and release tags | ||
branches: | ||
only: | ||
- master | ||
- /^\d+\.\d+\.\d+(\.\d+)?$/ | ||
|
||
|
||
before_install: | ||
- unset CC | ||
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH | ||
# Work around travis issue by updating Homebrew: https://github.com/travis-ci/travis-ci/issues/8552 | ||
- if [ "$TRAVIS_OS_NAME" = osx ]; | ||
then | ||
brew update; | ||
brew install cabal-install; | ||
brew install gnu-sed --with-default-names; | ||
fi | ||
# Using compiler above sets CC to an invalid value, so unset it | ||
- unset CC | ||
- CABALARGS="" | ||
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:/opt/alex/$ALEXVER/bin:/opt/happy/$HAPPYVER/bin:$HOME/.cabal/bin:$PATH | ||
- | # Install stack | ||
mkdir -p ~/.local/bin | ||
travis_retry curl -L https://get.haskellstack.org/stable/osx-x86_64.tar.gz | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin | ||
# Use the more reliable S3 mirror of Hackage | ||
mkdir -p $HOME/.cabal | ||
echo 'remote-repo: hackage.haskell.org:http://hackage.fpcomplete.com/' > $HOME/.cabal/config | ||
echo 'remote-repo-cache: $HOME/.cabal/packages' >> $HOME/.cabal/config | ||
|
||
install: | ||
- cabal --version | ||
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" | ||
- if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ]; | ||
then | ||
zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz > | ||
$HOME/.cabal/packages/hackage.haskell.org/00-index.tar; | ||
fi | ||
- travis_retry cabal update -v | ||
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config | ||
- cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt | ||
- sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt | ||
|
||
# check whether current requested install-plan matches cached package-db snapshot | ||
- if diff -u $HOME/.cabsnap/installplan.txt installplan.txt; | ||
then | ||
echo "cabal build-cache HIT"; | ||
rm -rfv .ghc; | ||
cp -a $HOME/.cabsnap/ghc $HOME/.ghc; | ||
cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/; | ||
else | ||
echo "cabal build-cache MISS"; | ||
rm -rf $HOME/.cabsnap; | ||
mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin; | ||
cabal install --only-dependencies --enable-tests --enable-benchmarks; | ||
fi | ||
install: | ||
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" | ||
- set -ex | ||
- stack --no-terminal --install-ghc build --only-dependencies | ||
- set +ex | ||
|
||
# snapshot package-db on cache miss | ||
- if [ ! -d $HOME/.cabsnap ]; | ||
then | ||
echo "snapshotting package-db to build-cache"; | ||
mkdir $HOME/.cabsnap; | ||
cp -a $HOME/.ghc $HOME/.cabsnap/ghc; | ||
cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/; | ||
fi | ||
|
||
# Here starts the actual work to be performed for the package under test; | ||
# any command which exits with a non-zero exit code causes the build to fail. | ||
script: | ||
- if [ -f configure.ac ]; then autoreconf -i; fi | ||
- cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging | ||
- cabal build # this builds all libraries and executables (including tests/benchmarks) | ||
- cabal test | ||
- cabal check | ||
- cabal sdist # tests that a source-distribution can be generated | ||
|
||
# Check that the resulting source distribution can be built & installed. | ||
# If there are no other `.tar.gz` files in `dist`, this can be even simpler: | ||
# `cabal install --force-reinstalls dist/*-*.tar.gz` | ||
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz && | ||
(cd dist && cabal install --force-reinstalls "$SRC_TGZ") | ||
- export PATH="${PATH}:$(pwd)/artifacts" | ||
- stack build --copy-bins --local-bin-path ./bin | ||
- source .travis-functions.sh | ||
- tar -jcvf $(mk_release_name dhall) bin/dhall | ||
- tar -jcvf $(mk_release_name dhall-json) bin/dhall-to-json bin/dhall-to-yaml bin/json-to-dhall bin/yaml-to-dhall | ||
- tar -jcvf $(mk_release_name dhall-bash) bin/dhall-to-bash | ||
- tar -jcvf $(mk_release_name dhall-lsp-server) bin/dhall-lsp-server | ||
|
||
before_deploy: | ||
- tar --create --file "$TRAVIS_OS_NAME.tar" --files-from /dev/null | ||
- tar --append --file "$TRAVIS_OS_NAME.tar" --directory dist/build/dhall dhall | ||
- gzip "$TRAVIS_OS_NAME.tar" | ||
- stack build --copy-bins --local-bin-path ./bin | ||
# TODO: move the tar operations here | ||
f-f marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- mkdir -p uploads | ||
- mv *.tar.bz2 uploads/ | ||
|
||
deploy: | ||
provider: releases | ||
api_key: "$GITHUB_OAUTH_TOKEN" | ||
file: "$TRAVIS_OS_NAME.tar.gz" | ||
on: | ||
condition: $DEPLOY_GITHUB_RELEASE = true | ||
tags: true | ||
skip_cleanup: true | ||
|
||
# EOF | ||
- provider: releases | ||
api_key: $GITHUB_OAUTH_TOKEN | ||
file_glob: true | ||
file: uploads/* | ||
skip_cleanup: true | ||
on: | ||
tags: true | ||
script: | ||
- echo 'done' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.