forked from PostgREST/postgrest
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis.yml
125 lines (122 loc) · 4.83 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
language: generic
sudo: false
jobs:
include:
- name: Build OSX Binary
os: osx
cache:
timeout: 1000
directories:
- $HOME/.stack
- $HOME/.local/bin
before_install:
- mkdir -p "$HOME/.local/bin"
- export PATH="$PATH:$HOME/.local/bin"
install:
- |
if test -f "$HOME/.local/bin/stack"
then
echo 'Stack is already installed.'
else
echo "Installing Stack..."
travis_retry curl -L https://www.stackage.org/stack/osx-x86_64 > stack.tar.gz
gunzip stack.tar.gz
tar -x -f stack.tar --strip-components 1
mv stack "$HOME/.local/bin/"
rm stack.tar
fi
- |
if test -f "$HOME/.local/bin/ghr"
then
echo 'ghr is already installed.'
else
echo "Installing ghr..."
travis_retry curl -L https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_darwin_386.zip > ghr.zip
unzip ghr.zip -d "$HOME/.local/bin"
rm ghr.zip
fi
script:
- |
if test "$TRAVIS_TAG" = "nightly"
then
cabal_nightly_version=$(git show -s --format='%cd' --date='format:%Y%m%d')
sed -i '' "s/^version:.*/version:$cabal_nightly_version/" postgrest.cabal
fi
## Building the whole project can take longer than 50 minutes. Since Travis has a global timeout of 50 minutes
## we compile for 30 minutes tops(`gtimeout 1800`) and quit compiling with no error.
## Since we CACHE the compile results we can continue compiling from where we left off
## on the next commit.
- gtimeout 1800 stack build --no-terminal --only-snapshot --install-ghc || (($?==124))
- |
if test ! "$TRAVIS_TAG"
then
echo 'No tag pushed. Skip building binary.'
else
stack build --no-terminal --copy-bins --local-bin-path .
fi
- |
if test ! "$TRAVIS_TAG"
then
echo 'No tag pushed. Skipping release.'
else
owner="$(echo "$TRAVIS_REPO_SLUG" | cut -f1 -d/)"
repo="$(echo "$TRAVIS_REPO_SLUG" | cut -f2 -d/)"
if test $TRAVIS_TAG = "nightly"
then
suffix=$(git show -s --format="%cd-%h" --date="format:%Y-%m-%d-%H-%M")
strip postgrest
tar cJf postgrest-nightly-$suffix-osx.tar.xz postgrest
ghr -t $GITHUB_TOKEN -u $owner -r $repo --replace nightly postgrest-nightly-$suffix-osx.tar.xz
else
start=$TRAVIS_TAG
end='## \['
body=$(sed -n "1,/$start/d;/$end/q;p" CHANGELOG.md)
strip postgrest
tar cJf postgrest-$TRAVIS_TAG-osx.tar.xz postgrest
ghr -t $GITHUB_TOKEN -u $owner -r $repo -b "$body"--replace $TRAVIS_TAG postgrest-$TRAVIS_TAG-osx.tar.xz
fi
fi
- name: Build ARM Binary
os: linux
dist: focal
arch: arm64
cache:
timeout: 1000
directories:
- $HOME/.cabal
install:
- sudo apt -y update
- sudo apt -y install ghc
- curl -L https://nixos.org/nix/install | sh
- . /home/travis/.nix-profile/etc/profile.d/nix.sh
- nix-env -i cabal-install # don't use apt -y install cabal-install, ubuntu cabal uses an outdated version that has a bug https://github.com/haskell/cabal/issues/6222
- sudo apt -y install zlib1g-dev
- sudo apt -y install libpq-dev
- sudo apt -y install pkg-config
- sudo apt -y install jq ## only used for the release
script:
- cabal v2-update
- travis_wait 30 timeout 1800 cabal v2-build || (($?==124))
- |
if test ! "$TRAVIS_TAG"
then
echo 'No tag pushed. Skipping release.'
else
cabal v2-install exe:postgrest
bin_name=""
if test $TRAVIS_TAG = "nightly"
then
suffix=$(git show -s --format="%cd-%h" --date="format:%Y-%m-%d-%H-%M")
bin_name=postgrest-nightly-$suffix-aarch64-ubuntu.tar.xz
else
bin_name=postgrest-$TRAVIS_TAG-aarch64-ubuntu.tar.xz
fi
release_id=$(curl -s https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$TRAVIS_TAG | jq .id)
echo "Uploading $bin_name to gh release: $release_id"
strip postgrest
tar cvJf $bin_name --dereference -C $HOME/.cabal/bin postgrest
curl -X POST --data-binary @$bin_name \
-H "Authorization:token $TOKEN" \
-H "Content-Type:application/octet-stream" \
"https://uploads.github.com/repos/$TRAVIS_REPO_SLUG/releases/$release_id/assets?name=$bin_name"
fi