This repository has been archived by the owner on Dec 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.travis.yml
131 lines (131 loc) · 4.67 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# This .travis.yml is modified from pandoc's at https://github.com/jgm/pandoc/blob/master/.travis.yml
language: generic
cache:
directories:
- $HOME/.ghc
- $HOME/.stack
jobs:
include:
- dist: bionic
addons:
apt:
packages:
- ghc-8.10.1
sources:
- hvr-ghc
- os: linux
arch: arm64
dist: bionic
addons:
apt:
packages:
- ghc
- cabal-install
- os: osx
allow_failures:
- arch: arm64
before_install:
# pandoc-nightly version
- |
printf "%s: %s\n" "pandoc-nightly version" "0.3"
install:
# Download and unpack the stack executable
- mkdir -p ~/.local/bin && export PATH="$HOME/.local/bin:$PATH"
- mkdir -p ~/temp && cd ~/temp
- |
if [[ "$TRAVIS_OS_NAME" == osx || "$TRAVIS_CPU_ARCH" == amd64 ]]; then
wget -q "https://www.stackage.org/stack/${TRAVIS_OS_NAME}-x86_64"
tar -xf "${TRAVIS_OS_NAME}-x86_64"
mv stack-*-${TRAVIS_OS_NAME}-x86_64/stack ~/.local/bin
else
echo skip installing stack for arm64
fi
- |
if [[ "$TRAVIS_OS_NAME" == osx ]]; then
wget -q 'https://downloads.haskell.org/~ghc/8.10.1/ghc-8.10.1-x86_64-apple-darwin.tar.xz'
tar -xf ghc-8.10.1-x86_64-apple-darwin.tar.xz
cd ghc-8.10.1
./configure --prefix="$HOME/.local"
make install
else
echo skip installing cabal if not osx
fi
before_script:
# clone from git
- mkdir ~/git
- cd ~/git
- git clone --depth 1 https://github.com/jgm/pandoc --branch master --single-branch
- cd pandoc
- git submodule update --init --recommend-shallow
# get the current commit hash of pandoc
- HASH=$(git rev-parse --short HEAD)
# filename
- |
case "$TRAVIS_OS_NAME" in
osx) filename=pandoc-osx-$HASH ;;
linux) filename="pandoc-${TRAVIS_CPU_ARCH}-$HASH" ;;
*) exit 1 ;;
esac
script:
# build
- |
if [[ "$TRAVIS_OS_NAME" == osx || "$TRAVIS_CPU_ARCH" == amd64 ]]; then
stack setup
stack build --flag 'pandoc:embed_data_files'
cd ..
# path to the pandoc executable
path2pandoc="$(find pandoc/.stack-work/install -type f -name pandoc)"
else
cabal update
cabal --version
cabal install cabal-install
cabal install --only-dependencies
cabal configure --flags="embed_data_files https"
cabal build
cabal install
path2pandoc="$CABALDIR/bin/pandoc"
fi
# debug
- ls -aglh "$path2pandoc"
- |
"$path2pandoc" -v
after_success:
# if it's a cron job, create git tag for GitHub Releases, only on Linux build
- |
if [[ "$TRAVIS_EVENT_TYPE" == cron && "$TRAVIS_OS_NAME" == linux ]]; then
git config --global user.email "[email protected]"
git config --global user.name "Travis CI"
export GIT_TAG="hash-$HASH"
git tag "$GIT_TAG" -a -m "Generated tag from TravisCI build $TRAVIS_BUILD_NUMBER"
git push --quiet https://[email protected]/pandoc-extras/pandoc-nightly "$GIT_TAG" > /dev/null 2>&1
fi
# if it's a cron job, remove Draft releases on GitHub, only on macOS build
# These Draft releases exists when there's a broken release from Travis
- |
if [[ $TRAVIS_EVENT_TYPE == 'cron' && "$TRAVIS_OS_NAME" == osx ]]; then
brew update
brew outdated hub || brew upgrade hub
# hub expect the env var GITHUB_TOKEN and I'm too lazy to rename the one I added on Travis
GITHUB_TOKEN="$GH_TOKEN_SECURE" hub release -f "%T (%S) %n" --include-drafts | grep " (draft)" | awk '{print $1}' | xargs -t -n1 hub release delete || :
fi
# zip pandoc binary and move to dist/ if it is the git-tag build (GitHub Releases)
- |
if [[ ! -z "$TRAVIS_TAG" ]]; then
mkdir -p $filename
mv $path2pandoc $filename
zip $filename.zip $filename/pandoc
mkdir -p dist
mv $filename.zip dist/
fi
# debug
- ls -l dist/
deploy:
provider: releases
token: "$GH_TOKEN_SECURE"
file_glob: true
file: "dist/*"
on:
tags: true
env:
global:
secure: PDNr60bZ/drP2nEkW+8mP9DNPONjElxMrxLSsVtXcDLJbDZPmyFahgiHmYERYiUGXQmzuyQbqQNBydFnHUbeRdZ+owLGzTIv8RzZ1SX+7OKZTwc38cJV3nWq3/F57DXsI32IW21RU1JN0HjCi33X4pDlrz597D78LKS3wRAREgxYMcq1FO+GtQ8B7NdLgFni0g94GiIUOyDoAut1yh43V7LoMtt6izQFJFyENUsaHl6xhhdxBoE6qnNhwP+CxscsCf+keezwCFgjuV+cwmxDhspY5Kx/bPfN0c2/Dwgv/nq+JjsbvVYJUjg/gHvg2dlwkGZKXIn8YmI492UwYxSOJ3TgLktdEgrkjRDPGwRvGpkqkZcZg65BEaTNzb/mj+kqd1sGo3NAfuDP8ArqJrYM2G4qfD2yIDKsFSMnIOH+6g6jmTEVPQt9yA2a3ZyUrXzdgs2i/AtsmUB4YYWHcIjcsjmdGZm6CgG3BMIMUmNuWZk9Ad3YEibd6raZ52RuTkICm0UQjCckg4QG10gS1ZYTTLyJle8f2HWxZZixBGfJQMmJsfn8jFoGsl9SKIseQ3VtEnmsHXSqW9tADFQ9+3n7wiCe+3mUaBVbKhKs6LCEf+oHi/nnkOSbPePdd43gBx3u85dww7jwoE5zDU22zWEBTa3wLztZfHAut8BQ5bYIeXw=