-
Notifications
You must be signed in to change notification settings - Fork 18
328 lines (301 loc) · 11.7 KB
/
pipeline.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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
name: impacto
on:
push:
branches:
- "master"
tags:
- "*"
pull_request_target:
branches:
- "master"
workflow_dispatch:
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
lint:
name: Run linters
permissions:
checks: write
contents: write
runs-on: ubuntu-latest
outputs:
commitid: ${{ steps.commit.outputs.commitid }}
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Install ClangFormat
run: sudo apt-get install -y clang-format
- name: Run linters
uses: wearerequired/lint-action@v2
with:
auto_fix: true
clang_format: true
clang_format_auto_fix: true
continue_on_error: false
- name: Get latest commit
id: commit
run: |
SHA=$(git rev-parse HEAD)
echo "::set-output name=commitid::$SHA"
job-matrix:
name: ${{ matrix.os_name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 120
needs: lint
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
os_name: windows
triplet: x64-windows-release
host_triplet: x64-windows-release
- os: ubuntu-latest
os_name: linux
triplet: x64-linux-ci
host_triplet: x64-linux-ci
- os: macos-latest
os_name: macos-arm64
triplet: arm64-osx-ci
host_triplet: arm64-osx-ci
- os: macos-13
os_name: macos-x64
triplet: x64-osx-ci
host_triplet: x64-osx-ci
- os: ubuntu-latest
os_name: switch
triplet: none
host_triplet: none
- os: ubuntu-latest
os_name: android
triplet: arm64-android-ci
host_triplet: x64-linux-ci
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
vcpkgCommitId: '0f88ecb8528605f91980b90a2c5bad88e3cb565f'
PresetName: ${{ (matrix.os_name == 'android') && 'ci-release-android' || 'ci-release' }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.lint.outputs.commitid }}
- name: Setup Android Environment
if: matrix.os_name == 'android'
run: |
export ABI=arm64-v8a
export MINSDKVERSION=28
echo "MINSDKVERSION=$MINSDKVERSION" >> $GITHUB_ENV
echo "ABI=$ABI" >> $GITHUB_ENV
echo "CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-linux-android$MINSDKVERSION -fPIC" >> $GITHUB_ENV
echo "VULKAN_SDK=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr" >> $GITHUB_ENV
shell: bash
- name: Set up Java
uses: actions/setup-java@v4
if: matrix.os_name == 'android'
with:
java-version: 17
distribution: "temurin"
cache: 'gradle'
- name: Download Switch deps
if: matrix.os_name == 'switch'
uses: blauqs/actions-download-asset@master
with:
repo: MrRevo3D/impacto
version: buildtag
file: devkitpro.tgz
out: /opt
token: ${{ secrets.SWITCH_BUILD_TOKEN }}
- name: Cache LibAtrac9
if: matrix.os_name != 'switch'
uses: actions/cache@v3
with:
key: libatrac9 | ${{ matrix.os_name }}
path: vendor/LibAtrac9
- uses: lukka/get-cmake@latest
- name: Setup vcpkg
if: matrix.os_name != 'switch'
uses: lukka/run-vcpkg@v11
id: runvcpkg
with:
vcpkgDirectory: '${{ runner.workspace }}/build/vcpkg'
vcpkgGitCommitId: '${{ env.vcpkgCommitId }}'
vcpkgJsonGlob: '**/vcpkg.json'
- name: Build Atrac9 Windows
if: matrix.os_name == 'windows'
run: |
./build-deps.ps1 -Arg1 x64
shell: pwsh
- name: Setup Dependencies Linux/MacOS/Android
if: contains(matrix.os_name, 'macos') || contains(matrix.os_name, 'linux') || contains(matrix.os_name, 'android')
run: |-
pushd vendor
if [ ! -d "LibAtrac9" ]; then
git clone https://github.com/Thealexbarney/LibAtrac9.git --depth 1
fi
cd LibAtrac9/C
if [[ "${{ matrix.os_name }}" == "macos"* ]]; then
sed -i '' -e 's/,--version-script=libatrac9.version//g' Makefile
fi
make CC="$CC"
mkdir -p ../include/libatrac9
mkdir -p ../libs
cp bin/libatrac9.a ../libs/
cp src/libatrac9.h ../include/libatrac9/
popd
echo "LIBATRAC9DIR=${{ github.workspace }}/vendor/LibAtrac9" >> $GITHUB_ENV
find "${{ github.workspace }}/vendor/LibAtrac9"
- name: Install Dependencies Linux
run: sudo apt-get install nasm libx11-dev libxft-dev libxext-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev libxrandr-dev
if: matrix.os_name == 'linux' || matrix.os_name == 'android'
- name: Install Dependencies Mac
run: brew install nasm
if: contains(matrix.os_name, 'macos')
- name: Run CMake with vcpkg.json manifest
if: matrix.os_name != 'switch'
uses: lukka/run-cmake@v10
with:
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
configurePreset: ${{ env.PresetName }}
configurePresetAdditionalArgs: >-
[
'-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}',
'-DVCPKG_HOST_TRIPLET=${{ matrix.host_triplet }}',
]
buildPreset: ${{ env.PresetName }}
- name: Run Switch build
if: matrix.os_name == 'switch'
run: |-
tar -xzf /opt/devkitpro.tgz -C /opt
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=/opt/devkitpro/devkitARM
export PATH="/opt/devkitpro/tools/bin:$PATH"
cmake . -DCMAKE_TOOLCHAIN_FILE=HorizonNX.toolchain
make -j2
elf2nro impacto impacto.nro
mkdir -p "${{ github.workspace }}/release/${{ env.PresetName }}"
cp impacto.nro "${{ github.workspace }}/release/${{ env.PresetName }}"
cp -r profiles "${{ github.workspace }}/release/${{ env.PresetName }}"
cp -r games "${{ github.workspace }}/release/${{ env.PresetName }}"
- name: Copy Shaders
run: cp -r src/shaders "${{ github.workspace }}/release/${{ env.PresetName }}"
shell: bash
- name: Copy docs
run: |
cp THIRDPARTY.md README.md LICENSE "${{ github.workspace }}/release/${{ env.PresetName }}"
shell: bash
- name: Build Android
if: matrix.os_name == 'android'
run: |
pushd "${{ github.workspace }}/release/${{ env.PresetName }}"
ls
mkdir -p "${{ github.workspace }}/android/app/src/main/assets/"
mv profiles "${{ github.workspace }}/android/app/src/main/assets/"
mv games "${{ github.workspace }}/android/app/src/main/assets/"
mv shaders "${{ github.workspace }}/android/app/src/main/assets/"
mkdir -p "${{ github.workspace }}/android/app/src/main/jniLibs/$ABI/"
popd
pushd "${{ github.workspace }}/android/"
./gradlew assemble
find "${{ github.workspace }}/android" -name "*.apk"
cp "${{ github.workspace }}/android/distribution/android/app/outputs/apk/debug/app-debug.apk" "${{ github.workspace }}/release/${{ env.PresetName }}/impacto-debug.apk"
cp "${{ github.workspace }}/android/distribution/android/app/outputs/apk/release/app-release-unsigned.apk" "${{ github.workspace }}/release/${{ env.PresetName }}/impacto-unsigned.apk"
shell: bash
- name: Archive Artifacts
run: |
7z u impacto-${{ matrix.os_name }}-${{ vars.VERSION }}${{ github.run_number }}-${{ github.sha }}.zip release/${{ env.PresetName }}/*
- name: Upload Artifact
uses: actions/[email protected]
with:
path: impacto-${{ matrix.os_name }}-${{ vars.VERSION }}${{ github.run_number }}-${{ github.sha }}.zip
name: release-${{ matrix.os_name }}
publish_artifacts:
name: Publish Artifacts
runs-on: ubuntu-22.04
permissions:
contents: write
needs:
- job-matrix
if: needs.job-matrix.result == 'success' && github.event_name != 'pull_request_target' && ((startsWith(github.ref, 'refs/tags') || github.ref_name == 'master'))
steps:
- uses: actions/download-artifact@v4
with:
pattern: release-*
path: "${{ github.workspace }}/release"
merge-multiple: true
- name: Upload Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags') || (github.ref_name == 'master')
with:
Name: Latest ${{ env.BRANCH_NAME }} build
tag_name: ${{ vars.VERSION }}${{ github.run_number }}
files:
${{ github.workspace }}/release/*.zip
prerelease: true
fail_on_unmatched_files: true
target_commitish: ${{ github.sha }}
- name: Get current date
id: date
run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
- uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
username: IMPACTO
avatar-url: https://cdn.discordapp.com/emojis/766988033127481344.png
embed-title : "${{ github.event.commits[0].author.name }}"
embed-color: 3659647
embed-timestamp: ${{ env.NOW }}
embed-description: |
Commit
`${{ github.event.head_commit.message }} (${{ github.sha }})`
from branch `${{ env.BRANCH_NAME }}` has been successfully built.
Release URL:
https://github.com/CommitteeOfZero/impacto/releases/tag/${{ vars.VERSION }}${{ github.run_number }}
Details:
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
notify_fail:
name: Notify failure
runs-on: ubuntu-22.04
needs:
- job-matrix
if: always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled'))
steps:
- uses: actions/checkout@v2
- name: 'Get Jobs Status'
id: get_jobs_status
run: |
echo "Fetch workflow run jobs"
json_data=$(curl -s -H "Authorization: Bearer ${{ github.token }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs")
name_conclusion_array=($(echo "$json_data" | jq -r '
.jobs[] |
select(.name | IN("macos-arm64", "linux", "windows", "switch", "macos-x64", "android")) |
"\(.name).\(.conclusion)"'))
for item in "${name_conclusion_array[@]}"; do
IFS='.' read -r name conclusion <<< "$item"
echo "$name=$conclusion" >> $GITHUB_OUTPUT
done
- name: Get current date
id: date
run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT
- uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
username: IMPACTO
avatar-url: https://cdn.discordapp.com/emojis/766988033127481344.png
embed-title : "${{ github.event.commits[0].author.name }}"
embed-color: 16711680
embed-timestamp: ${{ steps.date.outputs.NOW }}
embed-description: |
Commit
`${{ github.event.head_commit.message }} (${{ github.sha }})`
from branch `${{ env.BRANCH_NAME }}` has failed build.
Job status:
windows: ${{steps.get_jobs_status.outputs.windows}}
linux: ${{steps.get_jobs_status.outputs.linux}}
macos-arm64: ${{steps.get_jobs_status.outputs.macos-arm64}}
macos-x64: ${{steps.get_jobs_status.outputs.macos-x64}}
switch: ${{steps.get_jobs_status.outputs.switch}}
android: ${{steps.get_jobs_status.outputs.android}}
Details:
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}