OpenLoco/.github/workflows/ci.yml

129 lines
5.0 KiB
YAML

name: CI
on: [push, pull_request, workflow_dispatch]
env:
OPENLOCO_BUILD_SERVER: GitHub
OPENLOCO_VERSION: 21.08
jobs:
check-code-formatting:
name: Check code formatting
runs-on: ubuntu-latest
container:
image: openrct2/openrct2-build:0.2.4-format
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run clang-format
run: scripts/check-code-formatting.sh
windows:
name: Windows
runs-on: windows-latest
needs: check-code-formatting
env:
CONFIGURATION: Release
POWERSHELL_TELEMETRY_OPTOUT: 1
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build OpenLoco
run: |
$installPath = vswhere -latest -property installationpath
$instanceId = vswhere -latest -property instanceid
Import-Module "$installPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell $instanceId
if (-not $env:GITHUB_REF.StartsWith("refs/tags/"))
{
$env:OPENLOCO_BRANCH=($env:GITHUB_REF -replace "refs/heads/")
}
$env:OPENLOCO_SHA1=$env:GITHUB_SHA
$env:OPENLOCO_SHA1_SHORT=$env:GITHUB_SHA.Substring(0, 7)
$env:GIT_DESCRIBE = (git describe HEAD | sed -E "s/-g.+$//")
Write-Host "%GIT_DESCRIBE% = $env:GIT_DESCRIBE"
msbuild openloco.sln -m -t:restore
msbuild openloco.sln -m
- name: Build artifacts
run: |
mkdir artifacts | Out-Null
Copy-Item CHANGELOG.md,CONTRIBUTORS.md,LICENSE,loco.exe,bin\*.dll,bin\*.pdb artifacts
Copy-Item data\language artifacts\data\language -Recurse
Rename-Item artifacts\loco.exe openloco.exe
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: OpenLoco-${{ runner.os }}-Win32
path: artifacts
if-no-files-found: error
ubuntu:
name: Ubuntu i686
runs-on: ubuntu-latest
needs: check-code-formatting
container: openloco/openloco:ubuntu-i686
strategy:
fail-fast: false
matrix:
compiler: [g++, clang++]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build OpenLoco
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=release -DOPENLOCO_USE_CCACHE=OFF -DSDL2_DIR=/usr/lib/i386-linux-gnu/cmake/SDL2 -DSDL2_MIXER_PATH=/usr/lib/i386-linux-gnu -Dyaml-cpp_DIR=/usr/lib/i386-linux-gnu/cmake/yaml-cpp -DPNG_LIBRARY=/usr/lib/i386-linux-gnu/libpng16.so -DPNG_PNG_INCLUDE_DIR=/usr/include -DZLIB_LIBRARY=/usr/lib/i386-linux-gnu/libz.so
ninja -k0
fedora:
name: Fedora i686 MinGW32
runs-on: ubuntu-latest
needs: check-code-formatting
container: openloco/openloco:fedora-mingw32
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build OpenLoco
run: |
cmake -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=release -DOPENLOCO_USE_CCACHE=OFF -DSDL2_DIR=/usr/i686-w64-mingw32/sys-root/mingw/lib/cmake/SDL2/ -DSDL2_MIXER_PATH=/usr/i686-w64-mingw32/sys-root/mingw/ -Dyaml-cpp_DIR=/usr/i686-w64-mingw32/sys-root/mingw/CMake/ -DPNG_LIBRARY=/usr/i686-w64-mingw32/sys-root/mingw/bin/libpng16-16.dll -DPNG_PNG_INCLUDE_DIR=/usr/i686-w64-mingw32/sys-root/mingw/include
cd build
ninja -k0
mac:
name: macOS i686 osxcross
runs-on: ubuntu-latest
needs: check-code-formatting
container: openloco/osxcross:latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install dependencies
env:
dependency_ver: 1.3.0
run: |
ln -s /usr/osxcross/SDK/MacOSX10.13.sdk/System /System
curl -LfO "https://github.com/OpenLoco/Dependencies/releases/download/v${dependency_ver}/openloco.dependencies.macos.${dependency_ver}.zip"
unzip openloco.dependencies.macos.${dependency_ver}.zip -d vcpkg
- name: Build
env:
OSXCROSS_HOST: i386-apple-darwin17
TOOLCHAIN1: ${{ github.workspace }}/osxcross/tools/toolchain.cmake
TOOLCHAIN2: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
MACOSX_DEPLOYMENT_TARGET: 10.13
run: |
/usr/osxcross/bin/i386-apple-darwin17-osxcross-conf
eval $(/usr/osxcross/bin/i386-apple-darwin17-osxcross-conf)
mkdir build
cd build
export LD_LIBRARY_PATH=/usr/osxcross/lib:$LD_LIBRARY_PATH
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/osxcross_toolchain.cmake -DVCPKG_TARGET_TRIPLET=x86-osx
make -j$(getconf _NPROCESSORS_ONLN)
tar -cvzf ../openloco.tar.gz openloco.app
- name: Archive production artifacts
uses: actions/upload-artifact@v2
with:
name: OpenLoco-macOS
path: openloco.tar.gz
if-no-files-found: error