CI: Cross-build Windows Arm64, various cleanups #1593
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | ||
Check failure on line 1 in .github/workflows/compilation.yml GitHub Actions / CIInvalid workflow file
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
repository_dispatch: | ||
types: [run_build] | ||
env: | ||
OPENOMF_VERSION: '0.6.6' | ||
OPENOMF_ASSETS_URL: 'https://www.omf2097.com/pub/files/omf/omf2097-assets.zip' | ||
jobs: | ||
# Check code formatting correctness | ||
# ----------------------------------------------------------------------------------------------- | ||
formatting-check: | ||
name: Formatting Check | ||
runs-on: ubuntu-24.04 | ||
env: | ||
clang-format-version: '16' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install clang-format and fd-find | ||
uses: Eeems-Org/[email protected] | ||
with: | ||
packages: clang-format-${{ env.clang-format-version }} fd-find | ||
- name: Run clang-format style check | ||
run: | | ||
fdfind . -e .c -e .h -X clang-format-${{ env.clang-format-version }} --dry-run --Werror | ||
# Run unittests on modern-ish versions of gcc and clang. | ||
# ----------------------------------------------------------------------------------------------- | ||
unittest: | ||
name: Run unit-tests on ${{ matrix.config.name }} | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- name: GCC 14 | ||
apt_deps: >- | ||
libargtable2-dev libcunit1-dev libsdl2-mixer-dev libconfuse-dev | ||
libenet-dev libsdl2-dev libxmp-dev libpng-dev libepoxy-dev gcc-14 | ||
configure_flags: '-DCMAKE_C_COMPILER=gcc-14' | ||
- name: Clang 18 | ||
apt_deps: >- | ||
libargtable2-dev libcunit1-dev libsdl2-mixer-dev libconfuse-dev | ||
libenet-dev libsdl2-dev libxmp-dev libpng-dev libepoxy-dev clang-18 | ||
clang-tidy-18 | ||
configure_flags: '-DCMAKE_C_COMPILER=clang-18 -DUSE_TIDY=ON' | ||
- name: MinGW-w64 | ||
is_mingw: true | ||
apt_deps: mingw-w64 wine wine64 | ||
configure_flags: >- | ||
--toolchain cmake-scripts/mingw-w64-toolchain.cmake | ||
-DCMAKE_PREFIX_PATH=openomf-win-build-main/ | ||
-DCMAKE_INCLUDE_PATH=openomf-win-build-main/include/ | ||
-DCMAKE_LIBRARY_PATH=openomf-win-build-main/lib/ | ||
-DCMAKE_FIND_ROOT_PATH=openomf-win-build-main/ | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Ubuntu Dependencies | ||
uses: Eeems-Org/[email protected] | ||
with: | ||
packages: cmake cmake-data ninja-build ${{ matrix.config.apt_deps }} | ||
- if: ${{ matrix.config.is_mingw }} | ||
name: Download prebuilt MinGW-W64 dependencies | ||
run: | | ||
wget -q https://github.com/omf2097/openomf-win-build/archive/refs/heads/main.zip | ||
unzip -q main.zip && rm main.zip | ||
- name: Build tests | ||
run: | | ||
cmake -DCMAKE_BUILD_TYPE=Debug \ | ||
-DUSE_TESTS=On \ | ||
-DUSE_SANITIZERS=On \ | ||
-DUSE_FATAL_SANITIZERS=On \ | ||
-DUSE_TOOLS=On \ | ||
${{ matrix.config.configure_flags }} \ | ||
-G Ninja \ | ||
-S. -B build-test | ||
cmake --build build-test | ||
- if: ! ${{ matrix.config.is_mingw }} | ||
name: Run tests (natively) | ||
run: | | ||
cd build-test | ||
./openomf_test_main -V | ||
- if: ${{ matrix.config.is_mingw }} | ||
name: Run tests (MinGW, so run via wine) | ||
run: | | ||
cd build-test | ||
# TODO: use wine in mingw build | ||
wine openomf_test_main.exe -V | ||
# Build windows package, release artifact (MSVC) | ||
# ----------------------------------------------------------------------------------------------- | ||
build_msvc: | ||
needs: [unittest, formatting-check] | ||
strategy: | ||
matrix: | ||
config: | ||
- { arch: "x64", build_languages: "ON" } | ||
- { arch: "arm64", build_languages: "OFF" } | ||
name: Build Windows (MSVC, ${{ matrix.config.arch }}) | ||
runs-on: windows-latest | ||
env: | ||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | ||
steps: | ||
- name: Export Github Actions cache environment variables | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | ||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | ||
- uses: actions/checkout@v4 | ||
- name: Check out VCPKG | ||
# must be checked out *after* openomf.git | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: 'microsoft/vcpkg' | ||
path: 'vcpkg' | ||
- uses: lukka/get-cmake@latest | ||
- uses: ilammy/msvc-dev-cmd@v1 | ||
- name: Install VCPKG Dependencies, Configure CMake (${{ matrix.config.arch }}) | ||
run: > | ||
cmake -S . -B build-msvc | ||
--toolchain vcpkg/scripts/buildsystems/vcpkg.cmake | ||
-DVCPKG_TARGET_TRIPLET="${{ matrix.config.arch }}-windows-static" | ||
-A ${{ matrix.config.arch }} | ||
-DBUILD_LANGUAGES=${{ matrix.config.build_languages }} | ||
-DUSE_NATPMP=ON | ||
-DUSE_MINIUPNPC=ON | ||
- name: Build openomf | ||
run: cmake --build build-msvc --config Release --target openomf | ||
- name: Restore omf2097-assets.zip | ||
id: cache-assets | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: omf2097-assets.zip | ||
key: omf2097-assets.zip | ||
- name: Download omf 2097 assets | ||
if: steps.cache-assets.outputs.cache-hit != 'true' | ||
run: Invoke-WebRequest -URI "${{ env.OPENOMF_ASSETS_URL }}" -OutFile omf2097-assets.zip | ||
- name: Cache omf2097-assets.zip | ||
if: steps.cache-assets.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: omf2097-assets.zip | ||
key: omf2097-assets.zip | ||
- name: Extract omf 2097 assets | ||
run: | | ||
Expand-Archive omf2097-assets.zip -PassThru | ||
mkdir install/openomf/resources | ||
Move-Item -Path omf2097-assets/OMF2097/* -Destination install/openomf/resources/ -Force -PassThru | ||
- name: Install openomf | ||
run: cmake --install build-msvc --config Release --prefix install | ||
- name: Get short SHA | ||
shell: bash | ||
id: slug | ||
run: echo "sha8=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT | ||
- name: Generate ZIP package | ||
run: | | ||
cd install | ||
Compress-Archive -Path openomf -DestinationPath openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_windows_msvc_${{ matrix.config.arch }}.zip -PassThru | ||
- name: Upload ZIP artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_windows_msvc_${{ matrix.config.arch }} | ||
path: install/openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_windows_msvc_${{ matrix.config.arch }}.zip | ||
if-no-files-found: error | ||
# Build ubuntu package, release artifact | ||
# ----------------------------------------------------------------------------------------------- | ||
build_ubuntu: | ||
needs: [unittest, formatting-check] | ||
name: Build ubuntu-latest | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Ubuntu Dependencies | ||
uses: Eeems-Org/[email protected] | ||
with: | ||
packages: cmake libargtable2-dev libcunit1-dev libsdl2-mixer-dev | ||
libconfuse-dev libenet-dev libsdl2-dev libxmp-dev libpng-dev libepoxy-dev | ||
libminiupnpc-dev libnatpmp-dev | ||
- name: Generate Release | ||
run: | | ||
mkdir build-release && cd build-release | ||
cmake -DUSE_NATPMP=ON -DUSE_MINIUPNPC=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release/usr .. | ||
make -j $(getconf _NPROCESSORS_ONLN) | ||
make -j $(getconf _NPROCESSORS_ONLN) install | ||
- name: Get short SHA | ||
id: slug | ||
run: echo "sha8=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT | ||
- name: Restore omf2097-assets.zip | ||
id: cache-assets | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: omf2097-assets.zip | ||
key: omf2097-assets.zip | ||
- name: Download omf 2097 assets | ||
if: steps.cache-assets.outputs.cache-hit != 'true' | ||
run: wget -q "${{ env.OPENOMF_ASSETS_URL }}" | ||
- name: Cache omf2097-assets.zip | ||
if: steps.cache-assets.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: omf2097-assets.zip | ||
key: omf2097-assets.zip | ||
- name: Extract omf 2097 assets | ||
run: unzip -j omf2097-assets.zip -d build-release/release/usr/share/games/openomf | ||
- name: Generate TGZ package | ||
run: tar cvfz ${GITHUB_WORKSPACE}/openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_linux_amd64.tar.gz -C build-release/release/ . | ||
- name: Upload TGZ artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_linux_amd64 | ||
path: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_linux_amd64.tar.gz | ||
if-no-files-found: error | ||
- name: Generate DEB package | ||
uses: jiro4989/build-deb-action@v3 | ||
with: | ||
package: openomf | ||
package_root: build-release/release | ||
maintainer: ${{ github.repository_owner }} | ||
version: ${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }} | ||
arch: 'amd64' | ||
depends: 'libargtable2-0, libsdl2-mixer-2.0-0, libconfuse2, libenet7, libsdl2-2.0-0, libxmp4, libpng16-16, libepoxy0, libminiupnpc17, libnatpmp1' | ||
desc: 'One Must Fall 2097 Remake' | ||
- name: Install the DEB package | ||
run: sudo apt install ./openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_amd64.deb | ||
- name: Upload DEB artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_deb_amd64 | ||
path: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_amd64.deb | ||
if-no-files-found: error | ||
# Build macos package, release artifact | ||
# ----------------------------------------------------------------------------------------------- | ||
build_macos-arm: | ||
needs: [unittest, formatting-check] | ||
name: Build macos-14 | ||
runs-on: macos-14 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Mac Dependencies | ||
run: | | ||
brew update | ||
brew install cmake argtable cunit sdl2_mixer confuse enet sdl2 libxmp libpng libepoxy miniupnpc libnatpmp | ||
- name: Generate Release | ||
run: | | ||
mkdir build-release && cd build-release | ||
cmake -DUSE_NATPMP=ON -DUSE_MINIUPNPC=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release/usr .. | ||
make -j $(getconf _NPROCESSORS_ONLN) | ||
make -j $(getconf _NPROCESSORS_ONLN) install | ||
- name: Restore omf2097-assets.zip | ||
id: cache-assets | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: omf2097-assets.zip | ||
key: omf2097-assets.zip | ||
- name: Download omf 2097 assets | ||
if: steps.cache-assets.outputs.cache-hit != 'true' | ||
run: wget -q "${{ env.OPENOMF_ASSETS_URL }}" | ||
- name: Cache omf2097-assets.zip | ||
if: steps.cache-assets.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: omf2097-assets.zip | ||
key: omf2097-assets.zip | ||
- name: Extract omf 2097 assets | ||
run: unzip -j omf2097-assets.zip -d build-release/release/usr/share/games/openomf | ||
- name: Get short SHA | ||
id: slug | ||
run: echo "sha8=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT | ||
- name: Generate ZIP package | ||
run: | | ||
cd build-release/release | ||
zip -r ${GITHUB_WORKSPACE}/openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_macos14_arm.zip . | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_macos14_arm | ||
path: openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_macos14_arm.zip | ||
if-no-files-found: error | ||
# Create a "latest" release | ||
# ----------------------------------------------------------------------------------------------- | ||
make_release: | ||
needs: [build_macos-arm, build_ubuntu, build_msvc] | ||
if: github.ref == 'refs/heads/master' | ||
name: Make "latest" release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: '0' | ||
- name: Get short SHA | ||
id: slug | ||
run: echo "sha8=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
path: artifacts/ | ||
- name: Advance tag | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
try { | ||
await github.rest.git.deleteRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: "tags/latest" | ||
}) | ||
} catch (e) { | ||
console.log("The 'latest' tag doesn't exist yet", e) | ||
} | ||
try { | ||
await github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: "refs/tags/latest", | ||
sha: context.sha | ||
}) | ||
} catch (e) { | ||
console.log("Unable to create 'latest' tag", e) | ||
} | ||
- name: Extract release artifacts | ||
run: | | ||
mkdir upload | ||
mkdir windows_all | ||
combine_windows() { | ||
if [ "$#" -ne 2 ]; then | ||
echo "wrong argc to combine_windows" | ||
exit 1 | ||
fi | ||
unzip -d windows_all -o -u "$1" | ||
rm "$1" | ||
if [ "$2" != "openomf.exe" ]; then | ||
mv "windows_all/openomf/openomf.exe" "windows_all/openomf/$2" | ||
fi | ||
} | ||
combine_windows artifacts/openomf_*_windows_msvc_arm64/*.zip openomf_arm64.exe | ||
combine_windows artifacts/openomf_*_windows_msvc_x64/*.zip openomf.exe | ||
pushd windows_all/ | ||
zip -r ${GITHUB_WORKSPACE}/upload/openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_windows.zip * | ||
popd | ||
shopt -s globstar | ||
for file in artifacts/**; do | ||
if [ -f "$file" ]; then | ||
cp "$file" "${GITHUB_WORKSPACE}/upload/" | ||
fi | ||
done | ||
- uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: "upload/*" | ||
body: "Latest release from master. Note that this is autogenerated release, and should only be used for testing purposes." | ||
name: Latest | ||
tag: latest | ||
allowUpdates: true | ||
prerelease: true | ||
removeArtifacts: true | ||
token: ${{ secrets.GITHUB_TOKEN }} |