geode/.github/workflows/build.yml
2023-12-23 09:00:07 -03:00

210 lines
6.7 KiB
YAML

name: Build Binaries
on:
workflow_dispatch:
pull_request:
push:
branches:
- '**' # every branch
- '!no-build-**' # unless marked as no-build
env:
GEODE_CI: ''
CCACHE_ACTION_CI: true
jobs:
build:
strategy:
fail-fast: false
matrix:
config:
- name: Windows
os: windows-latest
id: win
cli_id: win
extra_flags: -T host=x64 -A win32 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGEODE_DEBUG=On
# uncomment to use vs clang-cl and ninja
#extra_flags: >
# --no-warn-unused-cli
# "-DCMAKE_C_COMPILER:FILEPATH=$env:VCINSTALLDIR\Tools\Llvm\bin\clang-cl.exe"
# "-DCMAKE_CXX_COMPILER:FILEPATH=$env:VCINSTALLDIR\Tools\Llvm\bin\clang-cl.exe"
# -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGEODE_DEBUG=On
cli_cmd: ''
package_cmd: 'makensis -WX -V3 ./installer/windows/installer.nsi'
installer_path: './installer/windows/geode-installer-win.exe'
# - name: macOS
# os: macos-latest
# id: mac
# cli_id: mac
# extra_flags: >
# -DCMAKE_C_COMPILER=clang
# -DCMAKE_CXX_COMPILER=clang++
# -DCMAKE_C_COMPILER_LAUNCHER=ccache
# -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
# -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGEODE_DEBUG=On -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13
# cli_cmd: 'chmod +x $GITHUB_WORKSPACE/cli/geode'
# package_cmd: './installer/mac/package.sh ./bin/nightly ./installer/mac/geode-installer-mac.pkg'
# installer_path: './installer/mac/geode-installer-mac.pkg'
- name: Android
os: ubuntu-latest
id: android
cli_id: linux
extra_flags: >
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake
-DANDROID_ABI=armeabi-v7a
-DANDROID_PLATFORM=android-23
-DGEODE_DONT_BUILD_TEST_MODS=1
-G Ninja
cli_cmd: 'chmod +x $GITHUB_WORKSPACE/cli/geode'
package_cmd: ''
installer_path: ''
name: Build ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.config.os }}
if: matrix.config.id != 'win'
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1.12.1
with:
arch: amd64_x86
if: matrix.config.id == 'win'
- name: Setup NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26b
add-to-path: false
if: matrix.config.id == 'android'
- name: Download CLI
uses: robinraju/release-downloader@v1.8
with:
repository: geode-sdk/cli
latest: true
fileName: '*-${{ matrix.config.cli_id }}.zip'
tarBall: false
zipBall: false
out-file-path: "cli"
- name: Setup CLI
run: |
7z x "${{ github.workspace }}/cli/*-${{ matrix.config.cli_id }}.zip" -o"${{ github.workspace }}/cli"
${{ matrix.config.cli_cmd }}
echo "${{ github.workspace }}/cli" >> $GITHUB_PATH
- name: Setup Android Env
run: |
echo "NDK_HOME=${{ steps.setup-ndk.outputs.ndk-path }}" >> "$GITHUB_ENV"
sudo apt install ninja-build
if: matrix.config.id == 'android'
- name: Configure
run: >
cmake -B ${{ github.workspace }}/build
-DCLI_PATH="${{ github.workspace }}/cli"
${{ matrix.config.extra_flags }}
- name: Build
run: |
cd ${{ github.workspace }}/build
cmake --build . --config RelWithDebInfo --parallel
rm ${{ github.workspace }}/bin/nightly/resources/.geode_cache
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: geode-${{ matrix.config.id }}
path: ./bin/nightly
- name: Package Installer
run: ${{ matrix.config.package_cmd }}
if: matrix.config.id != 'android'
- name: Upload Installer
uses: actions/upload-artifact@v3
with:
name: geode-installer-${{ matrix.config.id }}
path: ${{ matrix.config.installer_path }}
if: matrix.config.id != 'android'
publish:
name: Publish
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Declare Version Variables
id: ref
shell: bash
run: |
echo "version=$(cat ${{ github.workspace }}/VERSION | xargs)" >> $GITHUB_OUTPUT
echo "hash=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: ${{ github.workspace }}
- name: Move Installers
run: |
mv geode-installer-mac/geode-installer-mac.pkg geode-installer-${{ steps.ref.outputs.hash }}-mac.pkg
mv geode-installer-win/geode-installer-win.exe geode-installer-${{ steps.ref.outputs.hash }}-win.exe
- name: Zip MacOS Artifacts
uses: vimtor/action-zip@v1.1
with:
files: geode-mac/Geode.dylib geode-mac/GeodeBootstrapper.dylib
dest: geode-${{ steps.ref.outputs.hash }}-mac.zip
- name: Zip Windows Artifacts
uses: vimtor/action-zip@v1.1
with:
files: geode-win/XInput9_1_0.dll geode-win/Geode.dll geode-win/GeodeUpdater.exe geode-win/Geode.lib geode-win/Geode.pdb
dest: geode-${{ steps.ref.outputs.hash }}-win.zip
- name: Zip Android Artifacts
uses: vimtor/action-zip@v1.1
with:
files: geode-android/Geode.so
dest: geode-${{ steps.ref.outputs.hash }}-android.zip
- name: Zip Resources
uses: vimtor/action-zip@v1.1
with:
files: geode-mac/resources
dest: resources.zip
- name: Update Development Release
uses: andelf/nightly-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
name: 'Development Release'
body: |
Geode development release for commit ${{ github.sha }}. Since this is not a regular release, Geode will not install the resources automatically, so you should use the installer if you want them.
files: |
./geode-installer-${{ steps.ref.outputs.hash }}-mac.pkg
./geode-installer-${{ steps.ref.outputs.hash }}-win.exe
./geode-${{ steps.ref.outputs.hash }}-mac.zip
./geode-${{ steps.ref.outputs.hash }}-win.zip
./geode-${{ steps.ref.outputs.hash }}-android.zip
./resources.zip