-
Notifications
You must be signed in to change notification settings - Fork 0
371 lines (313 loc) · 13.8 KB
/
build-master.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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
name: BuildGame
on:
push:
branches: [ "master", "main" ]
permissions:
contents: write
jobs:
# ---------------------------------------------------------------------------------------
set_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore tools
run: dotnet tool restore
- name: Get version
run: dotnet tool run ezpipeline git-height-version -- -b 0.0.1 -v BUILD_VERSION
- name: Get android version
run: dotnet tool run ezpipeline git-height-version -- -v ANDROID_VERSION
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: v${{ env.BUILD_VERSION }}
tag_name: v${{ env.BUILD_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check for Secret PLAY_KEYSTORE
id: play-keystore-check
run: |
if [ "${{ secrets.PLAY_KEYSTORE }}" != '' ]; then
echo "HAS_PLAY_KEYSTORE=true" >> "$GITHUB_OUTPUT"
else
echo "HAS_PLAY_KEYSTORE=false" >> "$GITHUB_OUTPUT"
fi
- name: Check for STEAM_USERNAME
id: steam-check
run: |
if [ "${{ secrets.STEAM_USERNAME }}" != '' ]; then
echo "HAS_STEAM_USERNAME=true" >> "$GITHUB_OUTPUT"
else
echo "HAS_STEAM_USERNAME=false" >> "$GITHUB_OUTPUT"
fi
outputs:
BUILD_VERSION: ${{ env.BUILD_VERSION }}
ANDROID_VERSION: ${{ env.ANDROID_VERSION }}
HAS_PLAY_KEYSTORE: ${{ steps.play-keystore-check.outputs.HAS_PLAY_KEYSTORE }}
HAS_STEAM_USERNAME: ${{ steps.steam-check.outputs.HAS_STEAM_USERNAME }}
# ---------------------------------------------------------------------------------------
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore tools
run: dotnet tool restore
- name: Test in Debug configuration
working-directory: ./RbfxTemplate.Tests
run: dotnet test --configuration Debug --verbosity normal
- name: Test in Release configuration
working-directory: ./RbfxTemplate.Tests
run: dotnet test --configuration Release --verbosity normal
# ---------------------------------------------------------------------------------------
build_desktop:
needs: [set_version, tests]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13, windows-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 1
- name: Evaluate target runtime
shell: bash
run: |
echo "OS: $OSTYPE"
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "RUNTIME_ID: osx-x64"
echo "RUNTIME_ID=osx-x64" >> $GITHUB_ENV
elif [[ "$OSTYPE" == "linux"* ]]; then
echo "RUNTIME_ID: linux-x64"
echo "RUNTIME_ID=linux-x64" >> $GITHUB_ENV
elif [[ "$OSTYPE" == "msys"* ]]; then
echo "RUNTIME_ID: win-x64"
echo "RUNTIME_ID=win-x64" >> $GITHUB_ENV
else
echo "Unrecognized OS type $OSTYPE"
exit 1
fi
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore tools
run: dotnet tool restore
- name: Restore dependencies
working-directory: ./RbfxTemplate.Desktop
run: dotnet restore
- name: Dotnet Publish
working-directory: ./RbfxTemplate.Desktop
run: dotnet publish -f net8.0 -c Release --runtime ${{ env.RUNTIME_ID }} --self-contained true -p:Version=${{ needs.set_version.outputs.BUILD_VERSION }}
- name: Copy runtime dlls
if: ${{ env.RUNTIME_ID == 'win-x64' }}
run: |
copy "C:/Windows/System32/MSVCP140.dll" "RbfxTemplate.Desktop/bin/Release/net8.0/${{ env.RUNTIME_ID }}/publish/"
copy "C:/Windows/System32/VCRUNTIME140.dll" "RbfxTemplate.Desktop/bin/Release/net8.0/${{ env.RUNTIME_ID }}/publish/"
copy "C:/Windows/System32/VCRUNTIME140_1.dll" "RbfxTemplate.Desktop/bin/Release/net8.0/${{ env.RUNTIME_ID }}/publish/"
copy "C:/Windows/System32/D3DCOMPILER_47.dll" "RbfxTemplate.Desktop/bin/Release/net8.0/${{ env.RUNTIME_ID }}/publish/"
- name: Zip Package
run: dotnet tool run ezpipeline -- zip -i RbfxTemplate.Desktop/bin/Release/net8.0/${{ env.RUNTIME_ID }}/publish/ -o RbfxTemplate.${{ env.RUNTIME_ID }}.zip
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
./RbfxTemplate.${{ env.RUNTIME_ID }}.zip
name: v${{ needs.set_version.outputs.BUILD_VERSION }}
tag_name: v${{ needs.set_version.outputs.BUILD_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
# ------------ itch.io ------------
- name: Release to itch.io ${{ vars.ITCH_PROJECT }}
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
if: ${{ env.BUTLER_API_KEY != '' && vars.ITCH_PROJECT != '' }}
run: |
dotnet tool run ezpipeline -- fetch-tool --name Butler -o tools/itch
tools/itch/butler push RbfxTemplate.Desktop/bin/Release/net8.0/${{ env.RUNTIME_ID }}/publish/ ${{ vars.ITCH_PROJECT }}:${{ env.RUNTIME_ID }}
shell: bash
# ---------------------------------------------------------------------------------------
build_android:
needs: [set_version, tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 1
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore tools
run: dotnet tool restore
- name: Install Workloads
run: dotnet workload install android
- name: Restore dependencies
working-directory: ./RbfxTemplate.Android
run: dotnet restore
- name: Install android-sdk
shell: bash
run: |
sudo apt-get install -y wget tar android-sdk unzip tree
echo $ANDROID_HOME
sudo chmod -R a+rw $ANDROID_HOME
- name: Fetch AndroidSDKManager
run: |
dotnet tool run ezpipeline fetch-tool -n AndroidSDKManager --output $ANDROID_HOME --path --version 9123335
yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --licenses --sdk_root=$ANDROID_HOME
- name: 'Print Java version'
run: javac -version
- name: Install Android SDK and Platforms
run: $ANDROID_HOME/cmdline-tools/bin/sdkmanager "platform-tools" "platforms;android-33" --sdk_root=$ANDROID_HOME
- name: Decode Keystore
id: decode_keystore
if: ${{ needs.set_version.outputs.HAS_PLAY_KEYSTORE == 'true' }}
uses: timheuer/base64-to-file@v1
with:
fileDir: '${{ github.workspace }}/RbfxTemplate.Android'
fileName: 'googleplay.jks'
encodedString: ${{ secrets.PLAY_KEYSTORE }}
- name: Extract ApplicationId from RbfxTemplate.Android.csproj
working-directory: ./RbfxTemplate.Android
run: |
dotnet tool run ezpipeline get-msbuild-property -i RbfxTemplate.Android.csproj -p ApplicationId -v ANDROID_PACKAGENAME
- name: Dotnet Publish
working-directory: ./RbfxTemplate.Android
run: |
if [ -n "${{ secrets.PLAY_KEYSTORE }}" ]; then
echo "Secret PLAY_KEYSTORE is defined. Building and signing the aab file."
dotnet publish -f net8.0-android -c Release --no-restore -p:ApplicationId=${{ env.ANDROID_PACKAGENAME }} -p:ApplicationDisplayVersion=${{ needs.set_version.outputs.BUILD_VERSION }} -p:ApplicationVersion=${{ needs.set_version.outputs.ANDROID_VERSION }} -p:AndroidSdkDirectory=$ANDROID_HOME -p:Version=${{ needs.set_version.outputs.BUILD_VERSION }} /p:AndroidKeyStore=true /p:AndroidSigningKeyStore=googleplay.jks /p:AndroidSigningKeyAlias=${{secrets.PLAY_KEYSTORE_ALIAS}} /p:AndroidSigningKeyPass="${{ secrets.PLAY_KEYSTORE_PASS }}" /p:AndroidSigningStorePass="${{ secrets.PLAY_KEYSTORE_PASS }}"
else
echo "Secret PLAY_KEYSTORE is not defined. Building with no signature."
dotnet publish -f net8.0-android -c Release --no-restore -p:ApplicationId=${{ env.ANDROID_PACKAGENAME }} -p:ApplicationDisplayVersion=${{ needs.set_version.outputs.BUILD_VERSION }} -p:ApplicationVersion=${{ needs.set_version.outputs.ANDROID_VERSION }} -p:AndroidSdkDirectory=$ANDROID_HOME -p:Version=${{ needs.set_version.outputs.BUILD_VERSION }}
fi
- name: Find APK
run: |
dotnet tool run ezpipeline resolve-path -i ./RbfxTemplate.Android/bin/Release/**/*-Signed.apk -v APK_PATH
dotnet tool run ezpipeline resolve-path -i ./RbfxTemplate.Android/bin/Release/**/*-Signed.aab -v AAB_PATH
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.APK_PATH }}
${{ env.AAB_PATH }}
name: v${{ needs.set_version.outputs.BUILD_VERSION }}
tag_name: v${{ needs.set_version.outputs.BUILD_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Release to itch.io ${{ vars.ITCH_PROJECT }}
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
if: ${{ env.BUTLER_API_KEY != '' && vars.ITCH_PROJECT != '' }}
run: |
dotnet tool run ezpipeline -- fetch-tool --name Butler -o tools/itch
tools/itch/butler push ${{ env.APK_PATH }} ${{ vars.ITCH_PROJECT }}:android
shell: bash
- uses: r0adkll/[email protected]
name: Upload Android Artifact to Play Console
env:
PLAYSTORE_SERVICE_ACC: ${{ secrets.PLAYSTORE_SERVICE_ACC }}
if: ${{ env.PLAYSTORE_SERVICE_ACC != '' }}
with:
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_SERVICE_ACC }}
packageName: ${{ env.ANDROID_PACKAGENAME }}
releaseFiles: ${{ env.AAB_PATH }}
track: internal
# ---------------------------------------------------------------------------------------
build_uwp:
needs: [set_version, tests]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 1
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Restore tools
run: dotnet tool restore
- name: Restore application
working-directory: ./RbfxTemplate.UWP
run: msbuild RbfxTemplate.UWP.csproj /t:Restore /p:Configuration=Release
- name: Patch manifest version
working-directory: ./RbfxTemplate.UWP
run: dotnet tool run ezpipeline -- set-xml -i Package.appxmanifest -p default:Package/default:Identity -a Version -v ${{ needs.set_version.outputs.BUILD_VERSION }}.0
- name: Dotnet Publish
working-directory: ./RbfxTemplate.UWP
run: msbuild RbfxTemplate.UWP.csproj /p:AppxPackageDir=appxupload /p:AppxBundle=Always /p:AppxBundlePlatforms="x64" /p:Platform=x64 /p:AppxPackageSigningEnabled=false /p:UapAppxPackageBuildMode=StoreUpload /p:Configuration=Release /p:Version=${{ needs.set_version.outputs.BUILD_VERSION }}
- name: Zip Package
run: dotnet tool run ezpipeline -- zip -i RbfxTemplate.UWP/appxupload/RbfxTemplate.UWP_${{ needs.set_version.outputs.BUILD_VERSION }}.0_Test -o RbfxTemplate.UWP/appxupload/RbfxTemplate.UWP.x64.zip
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
RbfxTemplate.UWP/appxupload/RbfxTemplate.UWP_${{ needs.set_version.outputs.BUILD_VERSION }}.0_x64_bundle.appxupload
RbfxTemplate.UWP/appxupload/RbfxTemplate.UWP.x64.zip
name: v${{ needs.set_version.outputs.BUILD_VERSION }}
tag_name: v${{ needs.set_version.outputs.BUILD_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
# ------------ Steam ------------
publish_to_steam:
needs: [set_version, build_desktop]
runs-on: ubuntu-latest
if: needs.set_version.outputs.HAS_STEAM_USERNAME == 'true'
steps:
- name: Download Windows Build
uses: robinraju/release-downloader@v1
with:
repository: ${{ github.repository }}
tag: v${{ needs.set_version.outputs.BUILD_VERSION }}
fileName: 'RbfxTemplate.win-x64.zip'
token: ${{ secrets.GITHUB_TOKEN }}
out-file-path: ./StandaloneWindows64
extract: true
- name: Download Linux Build
uses: robinraju/release-downloader@v1
with:
repository: ${{ github.repository }}
tag: v${{ needs.set_version.outputs.BUILD_VERSION }}
fileName: 'RbfxTemplate.linux-x64.zip'
token: ${{ secrets.GITHUB_TOKEN }}
out-file-path: ./StandaloneLinux64
extract: true
- name: Download Mac Build
uses: robinraju/release-downloader@v1
with:
repository: ${{ github.repository }}
tag: v${{ needs.set_version.outputs.BUILD_VERSION }}
fileName: 'RbfxTemplate.osx-x64.zip'
token: ${{ secrets.GITHUB_TOKEN }}
out-file-path: ./StandaloneMac64
extract: true
- name: Delete RbfxTemplate.*-x64.zip
run: |
ROOT_FOLDER="./"
PATTERN="*RbfxTemplate.*-x64.zip"
find "$ROOT_FOLDER" -type f -name "$PATTERN" -exec rm -f {} +
- uses: game-ci/steam-deploy@v3
env:
STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }}
name: Steam - Publish
with:
username: ${{ secrets.STEAM_USERNAME }}
configVdf: ${{ secrets.STEAM_CONFIG_VDF }}
appId: ${{ secrets.STEAM_APPID }}
buildDescription: v${{ needs.set_version.outputs.BUILD_VERSION }}
rootPath: ./
depot1Path: StandaloneWindows64
depot2Path: StandaloneLinux64
depot3Path: StandaloneMac64
releaseBranch: prerelease