-
Notifications
You must be signed in to change notification settings - Fork 16
/
action.yml
284 lines (255 loc) · 11.1 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
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 'given' to use the version specified in mod.json, 'nightly' for latest commit, 'latest' for latest release
required: false
default: given
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 "Win64", "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
export-pdb:
description: Whether to export PDB files for Windows builds. Defaults to false
required: false
default: false
use-lto:
description: Whether to use LTO (Link Time Optimization) via the CMAKE_INTERPROCEDURAL_OPTIMIZATION flag, improving build size. 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=Win64
if [ "$RUNNER_OS" = "Linux" ]; then
ID=linux
DEFAULT_TARGET=Android64
elif [ "$RUNNER_OS" = "Windows" ]; then
ID=win
DEFAULT_TARGET=Win64
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" = "Win64" ]; 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"
echo "SCCACHE_CACHE_MULTIARCH=1" >> $GITHUB_ENV
# 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 == 'true' }}
- 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: Fix Ubuntu weirdness
shell: bash
run: |
sudo apt install ninja-build &&
sudo add-apt-repository ppa:ubuntu-toolchain-r/test &&
sudo apt-get update &&
sudo apt-get install --only-upgrade libstdc++6
if: steps.platform.outputs.id == 'linux' && (steps.platform.outputs.target_id == 'android32' || steps.platform.outputs.target_id == 'android64')
- name: Update LLVM (Windows)
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: Install LLVM (MacOS)
# shell: bash
# run: |
# brew install llvm
# echo "/opt/homebrew/opt/llvm/bin" >> $GITHUB_PATH
# if: steps.platform.outputs.id == 'mac'
- 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: Setup CLI
uses: geode-sdk/cli/.github/actions/setup@main
with:
version: ${{ inputs.cli }}
- 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/GeometryDash.exe" win
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 }}" == "nightly" ]; then
geode sdk update nightly
geode sdk install-binaries --platform ${{ steps.platform.outputs.target_id }}
elif [ "${{ inputs.sdk }}" == "latest" ]; then
geode sdk update stable
geode sdk install-binaries --platform ${{ steps.platform.outputs.target_id }}
elif [ "${{ inputs.sdk }}" == "given" ]; then
export MOD_JSON_PATH=$(find . -name "mod.json" -not -path "./geode-sdk-clone/*" -print | sort -r | head -n 1)
export TARGET_GEODE_VERSION=$(jq -r '.geode' $MOD_JSON_PATH)
echo "Updating to version $TARGET_GEODE_VERSION from $MOD_JSON_PATH"
geode sdk update "$TARGET_GEODE_VERSION"
geode sdk install-binaries --platform ${{ steps.platform.outputs.target_id }} --version "$TARGET_GEODE_VERSION"
else
geode sdk update ${{ inputs.sdk }}
geode sdk install-binaries --platform ${{ steps.platform.outputs.target_id }}
fi
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 -DCMAKE_AR='/usr/bin/ar' -DCMAKE_RANLIB='/usr/bin/ranlib'"
elif [ ${{ steps.platform.outputs.target_id }} = "android32" ]; then
CMAKE_EXTRA_ARGS="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake -DANDROID_STL=c++_shared -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_STL=c++_shared -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-${{ inputs.android-min-sdk }}"
fi
if [ "${{ inputs.use-lto }}" = "true" ]; then
CMAKE_EXTRA_ARGS="$CMAKE_EXTRA_ARGS -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON"
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
if [ ${{ steps.platform.outputs.id }} = "win" ]; then
if [ "${{ inputs.export-pdb }}" = "true" ]; then
for file in $(find ./build -name *.pdb); do
cp $file "${{ github.workspace }}/output"
done
fi
fi
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 == 'true' }}
uses: actions/upload-artifact@v4
with:
name: "geode-build-${{ steps.platform.outputs.target_id }}"
path: |
${{ steps.build.outputs.output }}/*.geode
${{ steps.build.outputs.output }}/*.pdb