-
-
Notifications
You must be signed in to change notification settings - Fork 1
237 lines (208 loc) · 7.08 KB
/
build-ndk.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
name: NDK build
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: false
push:
tags:
- "v*"
branches:
- 'master'
- 'main'
- 'dev/*'
- 'feat/*'
- 'fix/*'
paths-ignore:
- '**.yml'
- '!.github/workflows/build-ndk.yml'
- '**.json'
- '!qpm.json'
- '!qpm.shared.json'
- '!mod.template.json'
- '**.txt'
- '!CMakeLists.txt'
- '**.ps1'
- '!build.ps1'
- '!createqmod.ps1'
- '**.md'
- '.gitignore'
pull_request:
branches:
- 'master'
- 'main'
- 'dev/*'
- 'feat/*'
- 'fix/*'
jobs:
qpm_info:
runs-on: ubuntu-latest
outputs:
name: ${{ steps.read_qpm_info.outputs.name }}
id: ${{ steps.read_qpm_info.outputs.id }}
override_so_name: ${{ steps.read_qpm_info.outputs.override_so_name }}
qmod_output_path: ${{ steps.read_qpm_info.outputs.qmod_output_path }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install jq
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Read info from qpm.json
id: read_qpm_info
run: |
if [ -f "qpm.shared.json" ]; then
NAME="$(jq -r '.config.info.name' qpm.shared.json)"
ID="$(jq -r '.config.info.id' qpm.shared.json)"
OVERRIDE_SO_NAME="$(jq -r '.config.info.additionalData.overrideSoName' qpm.shared.json)"
QMOD_OUTPUT_PATH="$(jq -r '.config.workspace.qmodOutput' qpm.shared.json)"
else
NAME="$(jq -r '.info.name' qpm.json)"
ID="$(jq -r '.info.id' qpm.json)"
OVERRIDE_SO_NAME="$(jq -r '.info.additionalData.overrideSoName' qpm.json)"
QMOD_OUTPUT_PATH="$(jq -r '.workspace.qmodOutput' qpm.json)"
fi
echo "name=${NAME}" | tee -a "$GITHUB_OUTPUT"
echo "id=${ID}" | tee -a "$GITHUB_OUTPUT"
echo "override_so_name=${OVERRIDE_SO_NAME}" | tee -a "$GITHUB_OUTPUT"
echo "qmod_output_path=${QMOD_OUTPUT_PATH}" | tee -a "$GITHUB_OUTPUT"
build:
runs-on: ubuntu-latest
needs: qpm_info
steps:
- uses: actions/checkout@v4
name: Checkout
with:
submodules: true
lfs: true
- uses: seanmiddleditch/gha-setup-ninja@v3
- name: Setup NDK
uses: DanTheMan827-BeatSaber/setup-ndk@main
id: setup-ndk
- name: Create ndkpath.txt
run: |
echo "${{ steps.setup-ndk.outputs.ndk-path }}" > "${GITHUB_WORKSPACE}/ndkpath.txt"
cat "${GITHUB_WORKSPACE}/ndkpath.txt"
- name: Extract version
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.version != ''
id: version
run: |
if [ "${{ github.event.inputs.version }}" != "" ]; then
FULL_VERSION="${{ github.event.inputs.version }}"
VERSION="${FULL_VERSION%%[-+]*}"
else
TAG="${GITHUB_REF#refs/tags/}"
FULL_VERSION="${GITHUB_REF#refs/tags/v}"
VERSION="${FULL_VERSION%%[-+]*}"
fi
echo "TAG=$TAG" | tee -a "$GITHUB_OUTPUT"
echo "VERSION=$VERSION" | tee -a "$GITHUB_OUTPUT"
echo "FULL_VERSION=$FULL_VERSION" | tee -a "$GITHUB_OUTPUT"
- name: Update version in qpm.json, qpm.shared.json, and mod.template.json
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.version != ''
run: |
# Update qpm.json
if [ -f qpm.json ]; then
MODIFIED_JSON="$(jq --arg version "$VERSION" '.info.version = $version' qpm.json)"
echo "$MODIFIED_JSON" > qpm.json
fi
# Update qpm.shared.json if it exists
if [ -f qpm.shared.json ]; then
MODIFIED_JSON="$(jq --arg version "$VERSION" '.config.info.version = $version' qpm.shared.json)"
echo "$MODIFIED_JSON" > qpm.shared.json
fi
# Update mod.template.json if it exists
if [ -f mod.template.json ]; then
MODIFIED_JSON="$(jq --arg version "$FULL_VERSION" '.version = $version' mod.template.json)"
echo "$MODIFIED_JSON" > mod.template.json
fi
env:
VERSION: ${{ steps.version.outputs.VERSION }}
FULL_VERSION: ${{ steps.version.outputs.FULL_VERSION }}
- name: Setup qpm
uses: Fernthedev/qpm-action@main
with:
workflow_token: ${{ secrets.GITHUB_TOKEN }}
restore: true
cache: true
publish: false
- name: Build & Create Qmod
run: |
cd ${GITHUB_WORKSPACE}
qpm s qmod
- name: Rename build artifacts
run: |
mv "./build/debug/${{ needs.qpm_info.outputs.override_so_name }}" "./debug_${{ needs.qpm_info.outputs.override_so_name }}"
mv "./build/${{ needs.qpm_info.outputs.override_so_name }}" "./${{ needs.qpm_info.outputs.override_so_name }}"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
if-no-files-found: error
path: |
./${{ needs.qpm_info.outputs.override_so_name }}
./debug_${{ needs.qpm_info.outputs.override_so_name }}
${{ needs.qpm_info.outputs.qmod_output_path }}
release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: output/
- name: Upload .qmod
id: upload_file_qmod
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.version }}
draft: false
generate_release_notes: true
files: |
./output/*.qmod
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload .so artifacts
id: upload_file_so
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.version }}
files: |
./output/*.so
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Check if needed secrets are set
- name: Check if APP_ID and APP_PRIVATE_KEY are set
id: check-app
run: |
if [ -z "${{ secrets.APP_ID }}" ] || [ -z "${{ secrets.APP_PRIVATE_KEY }}" ]; then
echo "SECRETS_SET=false" | tee -a "$GITHUB_OUTPUT"
else
echo "SECRETS_SET=true" | tee -a "$GITHUB_OUTPUT"
fi
- uses: actions/create-github-app-token@v1
if: steps.check-app.outputs.SECRETS_SET == 'true'
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: bsqmods
- name: Make PR to mod repository
if: steps.check-app.outputs.SECRETS_SET == 'true'
id: qmod-release
uses: QuestPackageManager/qmod-repo-publish-action@main
with:
token: ${{ steps.generate-token.outputs.token }}
qmod_url:
${{
fromJSON(steps.upload_file_qmod.outputs.assets)[0].browser_download_url
}}
qmod_repo_owner: 'QuestPackageManager'
qmod_repo_name: 'bsqmods'