-
Notifications
You must be signed in to change notification settings - Fork 10
/
.travis.yml
147 lines (137 loc) · 4.57 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
language: c
cache:
directories:
- nim
- upx
- pcre
- openssl
- libressl
env:
global:
- REPONAME="$(basename ${TRAVIS_BUILD_DIR})" # /travis/build/kaushalmodi/hello_musl -> hello_musl
#
- PROG1="hello_musl"
- NIMFILE1="src/${PROG1}.nim"
- BINFILE1="src/${PROG1}"
#
- PROG2="hello_musl_pcre"
- NIMFILE2="src/${PROG2}.nim"
- BINFILE2="src/${PROG2}"
#
- PROG3="hello_musl_ssl"
- NIMFILE3="src/${PROG3}.nim"
- BINFILE3="src/${PROG3}"
- BINFILE3libre="src/${PROG3}_libre"
- BINFILE3open="src/${PROG3}_open"
#
- DIST_DIR="${TRAVIS_BUILD_DIR}/dist"
- ASSETFILE="${REPONAME}-${TRAVIS_TAG}.Linux_64bit_musl.tar.xz"
- NIMREPO="https://github.com/nim-lang/Nim"
- NIMVER="$(git ls-remote ${NIMREPO} devel | cut -f 1)"
- NIMDIR="${TRAVIS_BUILD_DIR}/nim/${NIMVER}"
- UPXVER="3.95" # Change this value when upgrading upx
- PCREVER="8.42" # Change this value when upgrading pcre
- LIBRESSLVER="2.8.1" # Change this value when upgrading libressl
- OPENSSLVER="1.1.1" # Change this value when upgrading openssl
addons:
apt:
packages:
# For building MUSL static builds on Linux.
- musl-tools
install:
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
- set -e
- echo "NIMDIR = ${NIMDIR}"
- |
if [[ ! -f "${NIMDIR}/bin/nim" ]]
then
rm -rf nim
mkdir -p nim
git clone --single-branch --branch devel --depth=1 "${NIMREPO}" "${NIMDIR}"
cd "${NIMDIR}" || exit
# Don't build 'koch tools'; remove that line from build_all.sh.
sed -i '/koch tools/d' build_all.sh
sh build_all.sh # https://github.com/nim-lang/Nim/issues/17907#issuecomment-831654235
fi
# - |
# if [[ ! -f "${NIMDIR}/bin/nimble" ]]
# then
# cd "${NIMDIR}" || exit
# ./koch nimble --skipUserCfg --skipParentCfg
# fi
- export PATH="${NIMDIR}/bin:${PATH}"
- nim -v
- |
if [[ ! -f "${TRAVIS_BUILD_DIR}/upx/${UPXVER}/upx" ]]
then
echo "Installing upx .."
cd "${TRAVIS_BUILD_DIR}"
curl -OL "https://github.com/upx/upx/releases/download/v${UPXVER}/upx-${UPXVER}-amd64_linux.tar.xz"
tar xvf "upx-${UPXVER}-amd64_linux.tar.xz"
mkdir -p "${TRAVIS_BUILD_DIR}/upx"
mv "upx-${UPXVER}-amd64_linux" "${TRAVIS_BUILD_DIR}/upx/${UPXVER}"
fi
- export PATH="${TRAVIS_BUILD_DIR}/upx/${UPXVER}/:${PATH}"
- upx --version | grep -E '^upx'
script:
# Ensure that you are in repo/build root now.
- cd "${TRAVIS_BUILD_DIR}"
- echo "NIMFILE1 = ${NIMFILE1}"
- echo "BINFILE1 = ${BINFILE1}"
- echo "NIMFILE2 = ${NIMFILE2}"
- echo "BINFILE2 = ${BINFILE2}"
# Compile the static binary using musl.
# --accept to say Yes to prompts like "Prompt: No local packages.json found, download it from internet? [y/N]"
# - nimble install --depsOnly --accept
# PROG1
- nim musl "${NIMFILE1}"
# See that the binary is not dynamic.
- file "${BINFILE1}"
# Run the binary.
- "${BINFILE1}"
# PROG2
- nim musl -d:pcre "${NIMFILE2}"
# See that the binary is not dynamic.
- file "${BINFILE2}"
# Run the binary.
- "${BINFILE2}"
# PROG3
- nim musl -d:libressl "${NIMFILE3}" && mv "${BINFILE3}" "${BINFILE3libre}"
# See that the binary is not dynamic.
- file "${BINFILE3libre}"
# Run the binary.
- "${BINFILE3libre}"
- nim musl -d:openssl "${NIMFILE3}" && mv "${BINFILE3}" "${BINFILE3open}"
# See that the binary is not dynamic.
- file "${BINFILE3open}"
# Run the binary.
- "${BINFILE3open}"
before_deploy:
- cd "${TRAVIS_BUILD_DIR}"
- mkdir dist
- cp "${BINFILE1}" "${DIST_DIR}"
- cp "${BINFILE2}" "${DIST_DIR}"
- cp "${BINFILE3libre}" "${DIST_DIR}"
- cp "${BINFILE3open}" "${DIST_DIR}"
# -C <DIR> tells tar to change the current directory to <DIR>, and
# then the "." means "add the entire current directory" (including
# hidden files and sub-directories).
- tar caf "${ASSETFILE}" -C "${DIST_DIR}" .
deploy:
provider: releases
api_key: "${GITHUB_OAUTH_TOKEN}"
file: "${ASSETFILE}"
skip_cleanup: true
on:
tags: true
notifications:
email:
on_success: never # default: change
on_failure: always # default: always
# References:
# choosenim: https://github.com/mratsim/Arraymancer/blob/master/.travis.yml
# musl: https://github.com/BurntSushi/ripgrep/blob/master/.travis.yml
# nim build caching: https://github.com/status-im/nimbus/blob/master/.travis.yml
# https://docs.travis-ci.com/user/deployment/releases/
# https://github.com/nim-lang/Nim/wiki/TravisCI
# https://docs.travis-ci.com/user/environment-variables/#default-environment-variables