Skip to content

Update gh-actions workflow #218

Update gh-actions workflow

Update gh-actions workflow #218

Workflow file for this run

name: Build
on: [push, pull_request]
jobs:
build-cmake:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest, ubuntu-20.04]
include:
- os: ubuntu-latest
cmake-args: -G Ninja
package-file: "*-linux_x86_64.tar.xz"
env:
CFLAGS: -Wdeclaration-after-statement -Werror
CXXFLAGS: -Werror
- os: ubuntu-20.04
cmake-path: /usr/bin/
cmake-args: -G Ninja
package-file: "*-linux_x86_64.tar.xz"
env:
CFLAGS: -Wdeclaration-after-statement -Werror
CXXFLAGS: -Werror
- os: macOS-latest
cmake-args: -G Ninja
package-file: "*-macos.dmg"
env:
CFLAGS: -Wdeclaration-after-statement -Werror
CXXFLAGS: -Werror
- os: windows-latest
cmake-args: -A x64
package-file: "*-win64.zip"
env:
CFLAGS: /WX
CXXFLAGS: /WX
LDFLAGS: /WX
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Prepare Linux
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update -y
sudo apt-get install pkg-config cmake ninja-build libfreetype6-dev libsdl2-dev -y
- name: Prepare MacOS
if: contains(matrix.os, 'macOS')
run: |
brew update || true
brew install pkg-config sdl2 python3 ninja || true
# --overwrite for: Target /usr/local/bin/2to3 already exists.
brew link --overwrite python@3.12
brew upgrade freetype
sudo rm -rf /Library/Developer/CommandLineTools
- name: Build in debug mode
env: ${{ matrix.env }}
run: |
mkdir debug
cd debug
${{ matrix.cmake-path }}cmake --version
${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=Debug -Werror=dev -DDOWNLOAD_GTEST=ON -DDEV=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=. ..
${{ matrix.cmake-path }}cmake --build . --config Debug ${{ matrix.build-args }} --target everything
- name: Test debug
run: |
cd debug
${{ matrix.cmake-path }}cmake --build . --config Debug ${{ matrix.build-args }} --target run_tests
- name: Run debug server
env: ${{ matrix.env }}
run: |
cd debug
./teeworlds_srv shutdown
- name: Build in release mode
env: ${{ matrix.env }}
run: |
mkdir release
cd release
${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=Release -Werror=dev -DDOWNLOAD_GTEST=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. ..
${{ matrix.cmake-path }}cmake --build . --config Release ${{ matrix.build-args }} --target everything
- name: Test release
run: |
cd release
${{ matrix.cmake-path }}cmake --build . --config Release ${{ matrix.build-args }} --target run_tests
- name: Run release server
env: ${{ matrix.env }}
run: |
cd release
./teeworlds_srv shutdown
- name: Package
run: |
cd release
${{ matrix.cmake-path }}cmake --build . --config Release ${{ matrix.build-args }} --target package_default
mkdir artifacts
mv ${{ matrix.package-file }} artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: teeworlds-${{ matrix.os }}
path: release/artifacts