-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from adam11111111111111111111121/adam1111111111…
…1111111111121-patch-3 Create action.yml
- Loading branch information
Showing
1 changed file
with
258 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
name: Build Geode mod | ||
description: Builds a Geode mod | ||
|
||
inputs: | ||
sdk: | ||
description: Which version of the SDK to use, defaults to latest release. Set to 'nightly' for latest commit, 'latest' for latest release | ||
required: false | ||
default: latest | ||
cli: | ||
description: Which CLI version to use, defaults to latest release. | ||
required: false | ||
default: latest | ||
configure-args: | ||
description: Extra arguments passed to CMake when configuring. | ||
required: false | ||
default: "" | ||
build-args: | ||
description: Extra arguments passed to CMake when building. | ||
required: false | ||
default: "" | ||
build-config: | ||
description: Which build configuration to use. Defaults to Release | ||
required: false | ||
default: Release | ||
path: | ||
description: Path to the project which to build. Defaults to current directory. | ||
required: false | ||
default: ./ | ||
combine: | ||
description: Set this to true if you plan on merging .geode files later. See the README for more info. | ||
required: false | ||
default: false | ||
target: | ||
description: Geode target to build for. Can be either "Win32", "MacOS", "Android32" or "Android64". | ||
required: false | ||
default: "" | ||
bindings: | ||
description: What repository to use for bindings. Must be in the format "user/repo" | ||
required: false | ||
default: "geode-sdk/bindings" | ||
bindings-ref: | ||
description: Which commit/branch to use for bindings. Defaults to latest commit in main branch | ||
required: false | ||
default: "" | ||
android-min-sdk: | ||
description: The android min SDK version to target. Defaults to 23 | ||
required: false | ||
default: 23 | ||
ccache-variant: | ||
description: The ccache variant to use (empty, ccache or sccache). Defaults to sccache | ||
required: false | ||
default: sccache | ||
use-cpm-cache: | ||
description: Whether to cache CPM sources. Defaults to true | ||
required: false | ||
default: true | ||
|
||
outputs: | ||
build-output: | ||
description: A folder containing the built .geode file(s) | ||
value: ${{ steps.build.outputs.output }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Detect platform | ||
id: platform | ||
shell: bash | ||
run: | | ||
DEFAULT_TARGET=Win32 | ||
if [ "$RUNNER_OS" = "Linux" ]; then | ||
ID=linux | ||
DEFAULT_TARGET=Android32 | ||
elif [ "$RUNNER_OS" = "Windows" ]; then | ||
ID=win | ||
DEFAULT_TARGET=Win32 | ||
elif [ "$RUNNER_OS" = "macOS" ]; then | ||
ID=mac | ||
DEFAULT_TARGET=MacOS | ||
fi | ||
TARGET=${{ inputs.target }} | ||
if [ "$TARGET" = "" ]; then | ||
TARGET=$DEFAULT_TARGET | ||
fi | ||
if [ "$TARGET" = "Android32" ]; then | ||
OUTPUT_ID=android32 | ||
elif [ "$TARGET" = "Android64" ]; then | ||
OUTPUT_ID=android64 | ||
elif [ "$TARGET" = "Win32" ]; then | ||
OUTPUT_ID=win | ||
elif [ "$TARGET" = "MacOS" ]; then | ||
OUTPUT_ID=mac | ||
fi | ||
echo "id=$ID" >> $GITHUB_OUTPUT | ||
echo "target=$TARGET" >> $GITHUB_OUTPUT | ||
echo "target_id=$OUTPUT_ID" >> $GITHUB_OUTPUT | ||
# https://github.com/mozilla/sccache/issues/2090 | ||
- name: Download custom sccache | ||
uses: robinraju/[email protected] | ||
with: | ||
repository: cgytrus/sccache | ||
latest: true | ||
fileName: 'sccache-*-x86_64-apple-darwin.zip' | ||
tarBall: false | ||
zipBall: false | ||
out-file-path: "epic-sccache" | ||
if: steps.platform.outputs.id == 'mac' && inputs.ccache-variant != '' | ||
|
||
- name: Setup custom sccache | ||
if: steps.platform.outputs.id == 'mac' && inputs.ccache-variant != '' | ||
shell: bash | ||
run: | | ||
7z x "epic-sccache/sccache-*-x86_64-apple-darwin.zip" -o"epic-sccache" | ||
echo "$GITHUB_WORKSPACE/epic-sccache" >> $GITHUB_PATH | ||
chmod +x "epic-sccache/sccache" | ||
# https://github.com/hendrikmuhs/ccache-action/pull/182 | ||
- name: Setup sccache | ||
uses: chirag-droid/ccache-action@main | ||
with: | ||
variant: ${{ inputs.ccache-variant }} | ||
key: ${{ steps.platform.outputs.target_id }}-v1 | ||
if: inputs.ccache-variant != '' | ||
|
||
- name: Setup CPM Cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ github.workspace }}/cpm-cache | ||
key: cpm-${{ steps.platform.outputs.target_id }}-v1-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }} | ||
restore-keys: | | ||
cpm-${{ steps.platform.outputs.target_id }}-v1- | ||
if: inputs.use-cpm-cache | ||
|
||
- name: Install Ninja | ||
shell: bash | ||
run: | | ||
curl -L https://github.com/ninja-build/ninja/releases/latest/download/ninja-${{ steps.platform.outputs.id }}.zip -o ninja.zip | ||
7z x ninja.zip -o"$GITHUB_WORKSPACE/ninja" | ||
echo "$GITHUB_WORKSPACE/ninja" >> $GITHUB_PATH | ||
- name: Update LLVM | ||
if: steps.platform.outputs.id == 'win' | ||
shell: bash | ||
run: | | ||
curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/LLVM-17.0.6-win64.exe -o llvm-inst.exe | ||
7z x llvm-inst.exe -ollvm bin/clang.exe bin/clang++.exe bin/lld-link.exe bin/llvm-rc.exe bin/*.dll lib/clang/*/include/* | ||
echo "$GITHUB_WORKSPACE/llvm/bin" >> $GITHUB_PATH | ||
- name: Download bindings repo | ||
if: inputs.bindings != 'geode-sdk/bindings' || inputs.bindings-ref != '' | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ inputs.bindings }} | ||
ref: ${{ inputs.bindings-ref }} | ||
path: bindings-repo | ||
|
||
- name: Setup bindings enviroment | ||
if: inputs.bindings != 'geode-sdk/bindings' || inputs.bindings-ref != '' | ||
shell: bash | ||
run: echo "GEODE_BINDINGS_REPO_PATH=$GITHUB_WORKSPACE/bindings-repo" >> $GITHUB_ENV | ||
|
||
- name: Download CLI | ||
uses: robinraju/[email protected] | ||
with: | ||
repository: geode-sdk/cli | ||
latest: ${{ inputs.cli == 'latest' }} | ||
tag: ${{ inputs.cli != 'latest' && inputs.cli || '' }} | ||
fileName: "*-${{ steps.platform.outputs.id }}.zip" | ||
tarBall: false | ||
zipBall: false | ||
out-file-path: "cli" | ||
|
||
- name: Setup CLI | ||
shell: bash | ||
run: | | ||
7z x "cli/*-${{ steps.platform.outputs.id }}.zip" -ocli | ||
echo "${{ github.workspace }}/cli" >> $GITHUB_PATH | ||
if [ ${{ steps.platform.outputs.id }} != "win" ]; then | ||
chmod +x "cli/geode" | ||
fi | ||
- name: Setup Geode SDK | ||
shell: bash | ||
run: | | ||
export CLI_PROFILE="${{ github.workspace }}/cli-profile" | ||
# for windows | ||
mkdir -p "$CLI_PROFILE/geode/mods" | ||
# for mac | ||
mkdir -p "$CLI_PROFILE/Contents/geode/mods" | ||
geode profile add --name GithubActions "$CLI_PROFILE" | ||
geode sdk install "${{ github.workspace }}/geode-sdk-clone" | ||
# silly github actions wont refresh the env | ||
export GEODE_SDK="${{ github.workspace }}/geode-sdk-clone" | ||
echo "GEODE_SDK=$GEODE_SDK" >> $GITHUB_ENV | ||
if [ "${{ inputs.sdk }}" == "latest" ]; then | ||
SDK_VERSION=stable | ||
else | ||
SDK_VERSION=${{ inputs.sdk }} | ||
fi | ||
geode sdk update $SDK_VERSION | ||
geode sdk install-binaries --platform ${{ steps.platform.outputs.target_id }} | ||
export CPM_CACHE="${{ github.workspace }}/cpm-cache" | ||
echo "CPM_SOURCE_CACHE=$CPM_CACHE" >> $GITHUB_ENV | ||
- name: Run CMake and build | ||
id: build | ||
shell: bash | ||
run: | | ||
mkdir -p $HOME/.cache | ||
cd "${{ inputs.path }}" | ||
CMAKE_EXTRA_ARGS="" | ||
if [ ${{ steps.platform.outputs.target_id }} = "mac" ]; then | ||
CMAKE_EXTRA_ARGS="-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DGEODE_DISABLE_PRECOMPILED_HEADERS=OFF" | ||
elif [ ${{ steps.platform.outputs.target_id }} = "android32" ]; then | ||
CMAKE_EXTRA_ARGS="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-${{ inputs.android-min-sdk }}" | ||
elif [ ${{ steps.platform.outputs.target_id }} = "android64" ]; then | ||
CMAKE_EXTRA_ARGS="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-${{ inputs.android-min-sdk }}" | ||
elif [ ${{ steps.platform.outputs.target_id }} = "win" ]; then | ||
# geode itself sets these, but only since beta.20 | ||
export CFLAGS="--target=i686-windows-msvc" | ||
export CXXFLAGS="--target=i686-windows-msvc" | ||
export LDFLAGS="--target=i686-windows-msvc" | ||
fi | ||
cmake -B build -DCMAKE_BUILD_TYPE=${{ inputs.build-config }} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DGEODE_CODEGEN_CMAKE_ARGS="-DCMAKE_C_COMPILER=clang;-DCMAKE_CXX_COMPILER=clang++;-G Ninja" -G Ninja $CMAKE_EXTRA_ARGS -DGEODE_DONT_INSTALL_MODS=ON -DGEODE_TARGET_PLATFORM=${{ steps.platform.outputs.target }} ${{ inputs.configure-args }} | ||
cmake --build build --config ${{ inputs.build-config }} ${{ inputs.build-args }} | ||
mkdir "${{ github.workspace }}/output" | ||
for file in $(find ./build -name *.geode); do | ||
cp $file "${{ github.workspace }}/output" | ||
done | ||
OUTPUT_DIR="${{ github.workspace }}/output" | ||
if [ ${{ steps.platform.outputs.id }} = "mac" ]; then | ||
OUTPUT_DIR=$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$OUTPUT_DIR") | ||
elif [ ${{ steps.platform.outputs.id }} = "win" ]; then | ||
OUTPUT_DIR=$(cygpath -wa "$OUTPUT_DIR") | ||
else | ||
OUTPUT_DIR=$(realpath "$OUTPUT_DIR") | ||
fi | ||
echo "output=$OUTPUT_DIR" >> $GITHUB_OUTPUT | ||
- name: Upload artifacts | ||
if: ${{ inputs.combine }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: "geode-build-${{ steps.platform.outputs.target_id }}" | ||
path: "${{ steps.build.outputs.output }}/*.geode" |