mirror of
https://github.com/cxong/cdogs-sdl.git
synced 2025-07-23 07:23:01 +02:00
197 lines
6.5 KiB
YAML
197 lines
6.5 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
tags:
|
|
- '*'
|
|
pull_request:
|
|
branches: [ master ]
|
|
|
|
env:
|
|
VERSION: 2.3.0
|
|
CTEST_EXT_COLOR_OUTPUT: TRUE
|
|
CTEST_OUTPUT_ON_FAILURE: 1
|
|
CTEST_BUILD_FLAGS: -j4
|
|
BUILD_TYPE: Release
|
|
SDL_AUDIODRIVER: dummy
|
|
SDL_VIDEODRIVER: dummy
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
cc: gcc
|
|
cc_version: latest
|
|
- os: ubuntu-latest
|
|
cc: clang
|
|
cc_version: latest
|
|
- os: macos-latest
|
|
- os: windows-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Protoc
|
|
uses: arduino/setup-protoc@v3
|
|
with:
|
|
version: "23.x"
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Check stuff
|
|
run: |
|
|
protoc --version
|
|
echo "${{ github.workspace }}"
|
|
|
|
- name: Set up Homebrew (Linux)
|
|
id: set-up-homebrew
|
|
if: matrix.os == 'ubuntu-latest'
|
|
uses: Homebrew/actions/setup-homebrew@master
|
|
|
|
- name: Install packages (Linux)
|
|
if: startsWith(matrix.os, 'ubuntu')
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt install python3-pip libgl1-mesa-dev
|
|
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev
|
|
python3 -m pip install protobuf --break-system-packages
|
|
pip3 install --upgrade protobuf --break-system-packages
|
|
|
|
- name: Set up GCC (Linux)
|
|
if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc'
|
|
uses: egor-tensin/setup-gcc@v1
|
|
with:
|
|
version: ${{ matrix.cc_version }}
|
|
|
|
- name: Set up Clang (Linux)
|
|
if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'clang'
|
|
uses: egor-tensin/setup-clang@v1
|
|
with:
|
|
version: ${{ matrix.cc_version }}
|
|
|
|
- name: Install packages (macOS)
|
|
if: matrix.os == 'macos-latest'
|
|
run: |
|
|
python3 -m pip install protobuf --break-system-packages
|
|
pip3 install --upgrade protobuf --break-system-packages
|
|
build/macosx/install-sdl2.sh
|
|
|
|
- name: Install dependencies (Windows)
|
|
if: matrix.os == 'windows-latest'
|
|
run: C:\vcpkg\vcpkg.exe install --triplet x64-windows sdl2 sdl2-image sdl2-mixer[core,mpg123] protobuf --recurse
|
|
|
|
- name: Configure CMake
|
|
env:
|
|
CC: ${{ matrix.cc }}
|
|
if: matrix.os != 'windows-latest'
|
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
|
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
|
run: cmake -B . -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=. -DDATA_INSTALL_DIR=. -Wno-dev
|
|
|
|
- name: Configure CMake (Windows)
|
|
if: matrix.os == 'windows-latest'
|
|
run: cmake -B . -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows
|
|
|
|
- name: Build
|
|
# Build your program with the given configuration
|
|
run: cmake --build . --config ${{env.BUILD_TYPE}}
|
|
|
|
- name: Test
|
|
working-directory: ${{github.workspace}}
|
|
# Execute tests defined by the CMake configuration.
|
|
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
|
run: ctest -C ${{env.BUILD_TYPE}} -VV
|
|
|
|
- name: Download SDL2 DLLs on tags (Windows)
|
|
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest'
|
|
uses: carlosperate/download-file-action@v2
|
|
with:
|
|
file-url: 'https://www.libsdl.org/release/SDL2-2.26.4-win32-x64.zip'
|
|
file-name: 'sdl2.zip'
|
|
location: './dll'
|
|
|
|
- name: Download SDL2_image DLLs on tags (Windows)
|
|
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest'
|
|
uses: carlosperate/download-file-action@v2
|
|
with:
|
|
file-url: 'https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.8.1-win32-x64.zip'
|
|
file-name: 'sdl2_image.zip'
|
|
location: './dll'
|
|
|
|
- name: Download SDL2_mixer DLLs on tags (Windows)
|
|
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest'
|
|
uses: carlosperate/download-file-action@v2
|
|
with:
|
|
file-url: 'https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.6.3-win32-x64.zip'
|
|
file-name: 'sdl2_mixer.zip'
|
|
location: './dll'
|
|
|
|
- name: Extract SDL2 DLLs on tags (Windows)
|
|
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest'
|
|
run: |
|
|
cd dll
|
|
7z x -y sdl2.zip
|
|
7z x -y sdl2_image.zip
|
|
7z x -y sdl2_mixer.zip
|
|
copy .\optional\*.dll .
|
|
|
|
- name: Make package on tags
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
cpack -B . -C ${{env.BUILD_TYPE}}
|
|
echo "${{ github.workspace }}"
|
|
ls "${{ github.workspace }}"
|
|
ls ${{ github.workspace }}/C-Dogs*SDL-*-*.*
|
|
|
|
- name: Upload a Build Artifact
|
|
uses: softprops/action-gh-release@v1
|
|
if: >
|
|
startsWith(github.ref, 'refs/tags/') &&
|
|
(!startsWith(matrix.os, 'ubuntu') || (matrix.cc == 'gcc' && matrix.cc_version == 'latest'))
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
files: C-Dogs*SDL-*-*.*
|
|
fail_on_unmatched_files: true
|
|
|
|
- name: Publish to itch.io (Linux)
|
|
if: >
|
|
startsWith(github.ref, 'refs/tags/') &&
|
|
startsWith(matrix.os, 'ubuntu') &&
|
|
matrix.cc == 'gcc' &&
|
|
matrix.cc_version == 'latest'
|
|
env:
|
|
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
|
|
run: |
|
|
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
|
|
unzip butler.zip
|
|
chmod +x butler
|
|
./butler -V
|
|
./butler push C-Dogs*SDL-*-Linux.tar.gz congusbongus/cdogs-sdl:linux --userversion $VERSION
|
|
|
|
- name: Publish to itch.io (macOS)
|
|
if: >
|
|
startsWith(github.ref, 'refs/tags/') &&
|
|
matrix.os == 'macos-latest'
|
|
env:
|
|
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
|
|
run: |
|
|
curl -L -o butler.zip https://broth.itch.ovh/butler/darwin-amd64/LATEST/archive/default
|
|
unzip butler.zip
|
|
chmod +x butler
|
|
./butler -V
|
|
./butler push C-Dogs*SDL-*-OSX.dmg congusbongus/cdogs-sdl:mac --userversion $VERSION
|
|
|
|
- name: Publish to itch.io (Windows)
|
|
if: >
|
|
startsWith(github.ref, 'refs/tags/') &&
|
|
matrix.os == 'windows-latest'
|
|
env:
|
|
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
|
|
run: |
|
|
.\build\windows\butler.bat
|