forked from planetarium/libplanet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
239 lines (215 loc) · 7.04 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
matrix:
include:
- os: linux
dist: xenial
language: csharp
addons:
apt:
packages:
- libxml2-utils
- powershell
sources:
- sourceline: deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/prod xenial main
key_url: https://packages.microsoft.com/keys/microsoft.asc
cache:
directories:
- $HOME/.nuget/packages
- $HOME/.local/share/NuGet/v3-cache
- os: osx
osx_image: xcode10.1
language: csharp
cache:
directories:
- $HOME/Library/Caches/Homebrew
- $HOME/.nuget/packages
- $HOME/.local/share/NuGet/v3-cache
- os: windows
language: shell
cache:
directories:
- $HOME/.nuget/packages
- $HOME/AppData/Local/NuGet/v3-cache
filter_secrets: false # https://travis-ci.community/t/current-known-issues-please-read-this-before-posting-a-new-topic/264/10
solution: Libplanet.sln
install:
- |
set -ev
if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then
mkdir -p "$HOME/.local/bin"
export PATH="$PATH:$HOME/.local/bin"
# submark
curl -L -o "$HOME/.local/bin/submark" \
https://github.com/dahlia/submark/releases/download/0.2.0/submark-linux-x86_64
chmod +x $HOME/.local/bin/submark
# github-release
pushd /tmp
curl -LO \
https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2
tar xvfj linux-amd64-github-release.tar.bz2
mv bin/linux/amd64/github-release $HOME/.local/bin/
popd
elif [[ "$TRAVIS_OS_NAME" = "osx" ]]; then
brew update
brew cask install powershell
elif [[ "$TRAVIS_OS_NAME" = "windows" ]]; then
# MSBuild
{
echo "#!/bin/bash"
echo "'/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe' $@"
} > /usr/bin/msbuild
chmod +x /usr/bin/msbuild
# NuGet
curl -o /usr/bin/nuget.exe \
https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
chmod +x /usr/bin/nuget.exe
# xmllint
mkdir /tmp/libxml2
pushd /tmp/libxml2
wget \
https://www.zlatkovic.com/pub/libxml/64bit/iconv-1.14-win32-x86_64.7z \
https://www.zlatkovic.com/pub/libxml/64bit/libtool-2.4.6-win32-x86_64.7z \
https://www.zlatkovic.com/pub/libxml/64bit/libxml2-2.9.3-win32-x86_64.7z \
https://www.zlatkovic.com/pub/libxml/64bit/libxslt-1.1.28-win32-x86_64.7z \
https://www.zlatkovic.com/pub/libxml/64bit/mingwrt-5.2.0-win32-x86_64.7z \
https://www.zlatkovic.com/pub/libxml/64bit/openssl-1.0.2e-win32-x86_64.7z \
https://www.zlatkovic.com/pub/libxml/64bit/xmlsec1-1.2.20-win32-x86_64.7z \
https://www.zlatkovic.com/pub/libxml/64bit/zlib-1.2.8-win32-x86_64.7z
for z in *.7z; do
7z x "$z"
done
mv */*.exe */*.dll /c/Windows/
popd
# Tools for test coverage (dotcover-clt, codecov-exe, xunit)
if [[ "$CODECOV_TOKEN" != "" ]]; then
mkdir /tmp/dotcover
pushd /tmp
wget \
https://download.jetbrains.com/resharper/ReSharperUltimate.2018.3.3/JetBrains.dotCover.CommandLineTools.2018.3.3.zip
pushd dotcover
7z x ../JetBrains.dotCover.CommandLineTools.*.zip
popd
mv dotcover/* /c/Windows/
rm JetBrains.dotCover.CommandLineTools.*.zip
popd
choco install codecov xunit
fi
fi
set +ev
- nuget restore Libplanet.sln
script:
# Fail fast if anything in below commands fails
- set -e
# If a tag is pushed, the NuGet package version has to be the same to
# the tag name.
- |
version="$(xmllint \
--xpath './Project/PropertyGroup/Version/text()' \
Libplanet/Libplanet.csproj)"
- 'echo "NuGet package version: $version"'
- '[[ "$TRAVIS_TAG" = "" || "$version" = "$TRAVIS_TAG" ]]'
# If a tag is pushed, there has to be an entry in CHANGES.md for the version.
- |
if [[ "$TRAVIS_OS_NAME" = "linux" && "$TRAVIS_TAG" != "" ]]; then
changes="$(submark -i --h2 "Version $TRAVIS_TAG" CHANGES.md | egrep '\S')"
[[ "$changes" != "" ]]
! grep -i "to be released" CHANGES.md
fi
# Check coding styles
- hooks/check-bom
# Build the whole solution
- msbuild /p:Configuration=Release /r
# Run unit tests
- msbuild /p:Configuration=Release /t:XunitTest Libplanet.Tests
# Run unit tests with coverage report
- cat codecov.yml | curl --data-binary @- https://codecov.io/validate
- |
if [[ "$TRAVIS_OS_NAME" = "windows" && "$CODECOV_TOKEN" != "" ]]; then
msbuild /p:Configuration=Debug /p:DebugType=full /p:DebugSymbols:true /r
for assembly in Libplanet.Tests/bin/Debug/*/Libplanet.Tests.dll; do
echo "$assembly:"
dotCover_config="$(cat .travis.dotCover.xml)"
assembly_abspath="$(cygpath -w "$(pwd)/$assembly")"
echo "${dotCover_config//\$ASSEMBLY/$assembly_abspath}" \
> "$assembly.dotCover.xml"
dotCover.exe cover "$assembly.dotCover.xml"
# Upload report to Codecov.io
codecov.exe -f "$assembly.cov.xml" -t "$CODECOV_TOKEN"
done
fi
# Build Libplanet.*.nupkg
- |
rm -f "Libplanet/bin/Release/Libplanet.$version.nupkg"
if [[ "$TRAVIS_TAG" = "" && "$version" = *-dev ]]; then
# Append "+buildno" to the package version (e.g., 0.1.2-dev+34)
# if it's not a tag push.
if [[ "$TRAVIS_EVENT_TYPE" = "cron" ]]; then
appended_version="${version/-dev/-nightly}.$(date +%Y%m%d)"
else
appended_version="$version.$TRAVIS_BUILD_NUMBER+$(date +%Y%m%d)"
fi
msbuild \
/p:Configuration=Release \
/p:NoPackageAnalysis=true \
/p:PackageVersion="$appended_version" \
/t:pack \
Libplanet
else
msbuild /p:Configuration=Release /t:pack Libplanet
fi
# Build docs using DocFX
- |
if [[ "$TRAVIS_OS_NAME" = "windows" ]]; then
powershell -Command "Set-ExecutionPolicy Unrestricted"
pwsh=powershell
else
pwsh=pwsh
fi
$pwsh \
-File Docs/build.ps1 \
-WorkingDirectory Docs/ \
-ExecutionPolicy Bypass
- '[[ -f Docs/_site/index.html ]]'
# Turn off "set -e" option
- set +e
before_cache:
- |
if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then
brew cleanup
fi
deploy:
# Upload a .nupkg file to GitHub releases
- provider: releases
on:
tags: true
skip_cleanup: true
api_key: "$GITHUB_TOKEN"
file_glob: yes
file: Libplanet/bin/Release/Libplanet.*.nupkg
name: "Libplanet $TRAVIS_TAG"
# Upload a .nupkg file to NuGet
- provider: script
on:
all_branches: true
skip_cleanup: true
script: bash publish.sh
# Publish docs to GitHub Pages
- provider: script
on:
all_branches: true
skip_cleanup: true
script: bash Docs/publish.sh
# Adjust the release note on GitHub releases
after_deploy: |
[[ "$TRAVIS_TAG" != "" && "$TRAVIS_OS_NAME" = "linux" ]] || exit 0
# Extract a release note from the full changelog
submark -o /tmp/release-note -i --h2 "Version $TRAVIS_TAG" -O CHANGES.md
# Fill the description on GitHub releases with the release note
export \
GITHUB_USER="${TRAVIS_REPO_SLUG%%/[^/]*}" \
GITHUB_REPO="${TRAVIS_REPO_SLUG#[^/]*/}"
github-release edit \
--user "$GITHUB_USER" \
--repo "$GITHUB_REPO" \
--tag "$TRAVIS_TAG" \
--name "Libplanet $TRAVIS_TAG" \
--description "$(cat /tmp/release-note)"