SDL_ttf: workflows: Add basic CI using Github Actions

From 443c41eb75768ffb3cbb1d043cc8645342769100 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Thu, 5 May 2022 19:24:04 +0100
Subject: [PATCH] workflows: Add basic CI using Github Actions

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 .github/workflows/main.yml | 105 +++++++++++++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)
 create mode 100644 .github/workflows/main.yml

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..0d7cd4e
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,105 @@
+name: Build
+
+on: [push, pull_request]
+
+jobs:
+  Build:
+    name: ${{ matrix.platform.name }}
+    runs-on: ${{ matrix.platform.os }}
+
+    defaults:
+      run:
+        shell: ${{ matrix.platform.shell }}
+
+    strategy:
+      fail-fast: false
+      matrix:
+        platform:
+        - { name: Windows (mingw32),      os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686 }
+        - { name: Windows (mingw64),      os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64 }
+        - { name: Linux (CMake),          os: ubuntu-20.04,   shell: sh,   cmake: '-GNinja' }
+        - { name: Linux (autotools),      os: ubuntu-20.04,   shell: sh }
+
+    steps:
+    - name: Set up MSYS2
+      if: matrix.platform.shell == 'msys2 {0}'
+      uses: msys2/setup-msys2@v2
+      with:
+        msystem: ${{ matrix.platform.msystem }}
+        install: >-
+          ${{ matrix.platform.msys-env }}-SDL2
+          ${{ matrix.platform.msys-env }}-autotools
+          ${{ matrix.platform.msys-env }}-cmake
+          ${{ matrix.platform.msys-env }}-gcc
+          ${{ matrix.platform.msys-env }}-freetype
+          ${{ matrix.platform.msys-env }}-harfbuzz
+          ${{ matrix.platform.msys-env }}-ninja
+          ${{ matrix.platform.msys-env }}-pkg-config
+          ${{ matrix.platform.msys-env }}-zlib
+
+    - name: Setup Linux dependencies
+      if: runner.os == 'Linux'
+      run: |
+        sudo apt-get update
+        sudo apt-get -y install \
+          autoconf \
+          automake \
+          cmake \
+          libfreetype-dev \
+          libharfbuzz-dev \
+          libsdl2-dev \
+          libtool \
+          ninja-build \
+          pkg-config \
+          ${NULL+}
+    - uses: actions/checkout@v2
+
+    - name: Configure CMake
+      if: "matrix.platform.cmake"
+      run: |
+        cmake -B build \
+          -DBUILD_SHARED_LIBS=ON \
+          -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
+          -DCMAKE_VERBOSE_MAKEFILE=ON \
+          ${{ matrix.platform.cmake }}
+    - name: Build
+      if: "matrix.platform.cmake"
+      run: cmake --build build/ --config Release
+    - name: Install
+      if: "matrix.platform.shell == 'sh' && matrix.platform.cmake"
+      run: |
+        set -eu
+        rm -fr DESTDIR-cmake
+        DESTDIR=$(pwd)/DESTDIR-cmake cmake --install build/ --config Release
+        ( cd DESTDIR-cmake; find ) | LC_ALL=C sort -u
+
+    - name: Configure Autotools
+      if: "! matrix.platform.cmake"
+      run: |
+        set -eu
+        rm -fr build-autotools
+        mkdir build-autotools
+        ./autogen.sh
+        ( cd build-autotools && ../configure )
+    - name: Build with Autotools
+      if: "! matrix.platform.cmake"
+      run: |
+        set -eu
+        parallel="$(getconf _NPROCESSORS_ONLN)"
+        make -j"${parallel}" -C build-autotools V=1
+    - name: Install with Autotools
+      if: "! matrix.platform.cmake"
+      run: |
+        set -eu
+        curdir="$(pwd)"
+        parallel="$(getconf _NPROCESSORS_ONLN)"
+        rm -fr DESTDIR-autotools
+        mkdir DESTDIR-autotools
+        make -j"${parallel}" -C build-autotools install DESTDIR="${curdir}/DESTDIR-autotools" V=1
+        ( cd DESTDIR-autotools; find ) | LC_ALL=C sort -u
+    - name: Distcheck with Autotools
+      if: "runner.os == 'Linux' && ! matrix.platform.cmake"
+      run: |
+        set -eu
+        parallel="$(getconf _NPROCESSORS_ONLN)"
+        make -j"${parallel}" -C build-autotools distcheck V=1