Files
Descent3/.github/workflows/build.yml

167 lines
6.4 KiB
YAML

name: Descent 3 Build
on:
workflow_call:
secrets:
MACOS_SIGNING_IDENTITY:
required: false
MACOS_SIGNING_CERTIFICATE_P12:
required: false
MACOS_SIGNING_CERTIFICATE_P12_PASSWORD:
required: false
MACOS_APP_STORE_CONNECT_KEY:
required: false
MACOS_APP_STORE_CONNECT_KEY_ID:
required: false
MACOS_APP_STORE_CONNECT_ISSUER_ID:
required: false
jobs:
build:
name: ${{ matrix.os.name }}, ${{ matrix.build_type }}
strategy:
fail-fast: false
matrix:
os:
- runner: windows-latest
preset: win
cc: cl
cxx: cl
name: Windows-x64
- runner: macos-14 # Apple Silicon, but we make a universal binary
preset: mac
cc: cc
cxx: c++
name: macOS
- runner: ubuntu-20.04 # Using an old version on purpose to get wider glibc compatibility
preset: linux
cc: gcc
cxx: g++
name: Linux-x64
- runner: ubuntu-20.04
preset: linux-cross-arm64
cc: gcc
cxx: g++
name: Linux-cross-arm64
build_type:
- Debug
- Release
runs-on: ${{ matrix.os.runner }}
env:
MACOS_AND_CODE_SIGNING: ${{ matrix.os.preset == 'mac' && secrets.MACOS_SIGNING_IDENTITY != '' }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install macOS Rosetta 2
if: ${{ matrix.os.preset == 'mac' }}
run: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
- name: Install macOS dependencies
if: ${{ matrix.os.preset == 'mac' }}
run: brew bundle install
- name: Install Linux dependencies
if: ${{ matrix.os.runner == 'ubuntu-20.04' }}
run: |
sudo apt update
sudo apt install -y --no-install-recommends \
ninja-build g++ curl pkg-config autoconf automake libtool libltdl-dev make python3-jinja2 libx11-dev libxft-dev libxext-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev libxcursor-dev libxfixes-dev libxi-dev libxrandr-dev libxss-dev
- name: Setup cmake
if: ${{ matrix.os.runner == 'ubuntu-20.04' }}
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.30.x'
- name: Install Linux Cross-compilation dependencies
if: ${{ matrix.os.preset == 'linux-cross-arm64' }}
run: |
sudo apt install -y --no-install-recommends \
gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Install Windows dependencies
if: ${{ matrix.os.runner == 'windows-latest' }}
run: choco install ninja
- uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.os.runner == 'windows-latest' }}
with:
arch: win64
- uses: lukka/run-vcpkg@v11
with:
vcpkgJsonGlob: vcpkg.json
- name: Configure cross-compiled build
if: ${{ matrix.os.preset == 'linux-cross-arm64' }}
run: |
cmake --preset linux
ninja -f build-${{ matrix.build_type }}.ninja -C builds/linux/ HogMaker
cmake --preset linux-cross-arm64 -DHogMaker_DIR=$PWD/builds/linux/ -DBUILD_TESTING=OFF -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON -DBUILD_EDITOR=OFF -DUSE_EXTERNAL_PLOG=ON
- name: Customize vcpkg to create macOS universal binary
if: ${{ matrix.os.preset == 'mac' }}
working-directory: ${{ env.VCPKG_ROOT }}/triplets
run: |
cp ./arm64-osx.cmake ./community/universal-osx.cmake
sed -i '' 's/^set(VCPKG_OSX_ARCHITECTURES.*$/set(VCPKG_OSX_ARCHITECTURES "arm64;x86_64")/' ./community/universal-osx.cmake
- name: Import macOS code signing certificate
if: ${{ env.MACOS_AND_CODE_SIGNING == 'true' }}
uses: DescentDevelopers/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.MACOS_SIGNING_CERTIFICATE_P12 }}
p12-password: ${{ secrets.MACOS_SIGNING_CERTIFICATE_P12_PASSWORD }}
- name: Configure CMake
if: ${{ matrix.os.preset != 'linux-cross-arm64' }}
env:
CC: ${{ matrix.os.cc }}
CXX: ${{ matrix.os.cxx }}
run: cmake --preset ${{ matrix.os.preset }} -DCODESIGN_IDENTITY=${{ secrets.MACOS_SIGNING_IDENTITY }} -DBUILD_TESTING=ON -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON -DBUILD_EDITOR=ON -DUSE_EXTERNAL_PLOG=ON
- name: Build ${{ matrix.build_type }}
run: cmake --build --preset ${{ matrix.os.preset }} --config ${{ matrix.build_type }} --verbose
- name: Run ${{ matrix.build_type }} Unittests
if: ${{ matrix.os.preset != 'linux-cross-arm64' }}
run: ctest --preset ${{ matrix.os.preset }} -C ${{ matrix.build_type }}
- name: Local install
# There no cmake install presets so install in traditional way
run: cmake --install builds/${{ matrix.os.preset }}/ --config ${{ matrix.build_type }}
- name: Sign, package, and notarize for macOS
if: ${{ env.MACOS_AND_CODE_SIGNING == 'true' }}
uses: DescentDevelopers/macos-sign-package-notarize@v1
with:
path-to-binaries: builds/${{ matrix.os.preset }}/installed/Descent3.app builds/${{ matrix.os.preset }}/installed/netgames/*
signing-identity: ${{ secrets.MACOS_SIGNING_IDENTITY }}
app-store-connect-key: ${{ secrets.MACOS_APP_STORE_CONNECT_KEY }}
app-store-connect-key-id: ${{ secrets.MACOS_APP_STORE_CONNECT_KEY_ID }}
app-store-connect-issuer-id: ${{ secrets.MACOS_APP_STORE_CONNECT_ISSUER_ID }}
archive-files: builds/${{ matrix.os.preset }}/installed/*
archive-disk-name: Descent 3
archive-file-path: builds/${{ matrix.os.preset }}/Descent3-${{ matrix.build_type }}-${{ matrix.os.name }}.dmg
- name: Swap macOS DMG disk image into installed folder
if: ${{ env.MACOS_AND_CODE_SIGNING == 'true' }}
run: |
rm -rf builds/${{ matrix.os.preset }}/installed/*
mv builds/${{ matrix.os.preset }}/Descent3-${{ matrix.build_type }}-${{ matrix.os.name }}.dmg builds/${{ matrix.os.preset }}/installed/
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Descent3_${{ matrix.build_type }}_${{ matrix.os.name }}
path: ${{ github.workspace }}/builds/${{ matrix.os.preset }}/installed/