-
Notifications
You must be signed in to change notification settings - Fork 23
158 lines (141 loc) · 6.6 KB
/
sourcehold.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
name: Sourcehold
on: [push, pull_request]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
target-platform: ["host"]
include:
- os: ubuntu-latest
install-dependencies: "sh ./ubuntu/install-dependencies.sh"
#TODO: (seidl, @github: skrax)
# enable warnings as errors later
cmake-configure-options: "-DWARNINGS_AS_ERRORS=OFF
-DENABLE_COVERAGE=ON
-DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON
-DENABLE_CLANG_TIDY=ON
-DENABLE_SANITIZER_ADDRESS=ON
-DENABLE_SANITIZER_LEAK=ON"
cmake-build-options: ""
uploaded-artifact-name: "sourcehold-linux-amd64"
- os: macos-latest
install-dependencies: "sh ./apple/install-dependencies-macos.sh"
cmake-configure-options: ""
cmake-build-options: ""
uploaded-artifact-name: "sourcehold-mac-os"
# Use different target platform here just to force new job spawning
- target-platform: "ios-simulator"
os: macos-latest
install-dependencies: "sh ./apple/install-dependencies-ios.sh -s -d 11.0 ./thirdparty/ios"
#TODO: add gtest install script for ios
cmake-configure-options: '-GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DCMAKE_OSX_ARCHITECTURES="x86_64" -DSOURCEHOLD_BUILD_TESTS=OFF'
cmake-build-options: "-- -sdk iphonesimulator"
uploaded-artifact-name: "sourcehold-ios"
- os: windows-latest
install-dependencies: "sh ./windows/install-dependencies.sh"
# this assumes cmake is run from the project root
cmake-configure-options: "-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake"
cmake-build-options: ""
uploaded-artifact-name: "sourcehold-windows64"
name: ${{ matrix.os }} - ${{ matrix.target-platform }}
steps:
- name: Set up environment variables
# Unfortunately workflow level env variables can not be accessed at job level
# (see https://github.community/t/how-to-set-and-access-a-workflow-variable/17335)
# in our case this is BUILD_TYPE. Thus we have to define it here in such weird way.
shell: bash
run: |
if [[ ${{ matrix.target-platform }} == 'ios-simulator' ]]; then
echo "BUILD_ARTIFACT_PARENT_DIR_PATH=${{ github.workspace }}/build/${{ env.BUILD_TYPE }}-iphonesimulator" >> $GITHUB_ENV
echo "BUILD_ARTIFACT_NAME=Stronghold.app" >> $GITHUB_ENV
elif [[ ${{ matrix.os }} == 'windows-latest' ]]; then
echo "BUILD_ARTIFACT_PARENT_DIR_PATH=${{ github.workspace }}\build" >> $GITHUB_ENV
echo "BUILD_ARTIFACT_NAME=Stronghold.exe" >> $GITHUB_ENV
echo "VCPKG_BINARY_SOURCES=clear;nuget,GitHub,readwrite" >> $GITHUB_ENV
else
echo "BUILD_ARTIFACT_PARENT_DIR_PATH=${{ github.workspace }}/build" >> $GITHUB_ENV
echo "BUILD_ARTIFACT_NAME=Stronghold" >> $GITHUB_ENV
fi
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: 'true'
- name: Cache dependencies
if: ${{ matrix.target-platform == 'ios-simulator' }}
uses: actions/cache@v2
env:
cache-name: cache-${{ matrix.target-platform }}-dependencies
with:
path: ${{ github.workspace }}/thirdparty/ios
key: ${{ env.cache-name }}
- name: Setup vcpkg for Windows
if: ${{ matrix.os == 'windows-latest' }}
shell: bash
run: |
git clone https://github.com/microsoft/vcpkg
rm -rf "$VCPKG_INSTALLATION_ROOT"
./vcpkg/bootstrap-vcpkg.sh
- name: Setup NuGet Credentials
if: ${{ matrix.os == 'windows-latest' }}
shell: bash
run: |
`./vcpkg/vcpkg fetch nuget | tail -n 1` \
sources Add -Source "https://nuget.pkg.github.com/${{ github.actor }}/index.json" \
-StorePasswordInClearText \
-Name "GitHub" \
-UserName "${{ github.actor }}" \
-Password "${{ secrets.GITHUB_TOKEN }}"
- name: Install dependencies
shell: bash
env:
INSTALL_DEPENDENCIES: ${{ matrix.install-dependencies }}
# Install all the required dependencies to build Sourcehold
run: $INSTALL_DEPENDENCIES
- name: Create build environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{ github.workspace }}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
env:
CMAKE_CONFIGURE_OPTIONS: ${{ matrix.cmake-configure-options }}
run: cmake -B build -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CMAKE_CONFIGURE_OPTIONS
- name: Build
shell: bash
env:
CMAKE_BUILD_OPTIONS: ${{ matrix.cmake-build-options }}
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build build --config $BUILD_TYPE $CMAKE_BUILD_OPTIONS
- name: Make artifacts
shell: bash
run: |
cd "$BUILD_ARTIFACT_PARENT_DIR_PATH"
if [[ ${{ matrix.os }} == 'windows-latest' ]]; then
7z a "${{ github.workspace }}\${{ matrix.uploaded-artifact-name }}.zip" -tzip "$BUILD_ARTIFACT_NAME"
else
zip -r ${{ github.workspace }}/${{ matrix.uploaded-artifact-name }}.zip "$BUILD_ARTIFACT_NAME"
fi
- name: Run tests
shell: bash
run: |
if [[ ${{ matrix.target-platform }} != 'ios-simulator' ]]; then
pushd build/test
ctest --output-on-failure
popd
fi
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.uploaded-artifact-name }}
path: ${{ github.workspace }}/${{ matrix.uploaded-artifact-name }}.zip