-
Notifications
You must be signed in to change notification settings - Fork 17
227 lines (190 loc) · 7.67 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
name: Build, Test & Deploy
on:
# run workflow on push events on any branch
# one can tell Actions to not run the pipeline
# by including certain strings in the commit message
# e.g.: "[ci skip]", "[no ci]"
# https://docs.github.com/en/enterprise-cloud@latest/actions/managing-workflow-runs/skipping-workflow-runs
push:
# allow to run the workflow manually
workflow_dispatch:
# run daily at 5:50 AM UTC
# to quickly spot issues with workflow/runner
# scheduled runs do not trigger deployment to steam
# (runs at 5:50 AM to avoid congestion at the start of the hour )
schedule:
- cron: 50 5 * * *
jobs:
# test job matrix
test:
name: Run ${{ matrix.testMode }} tests
runs-on: ubuntu-latest
# needed to create status check
permissions:
checks: write
strategy:
fail-fast: false
matrix:
projectPath: [unity]
testMode: [playmode, editmode]
steps:
# Checkout
- name: Checkout repository
uses: actions/checkout@v4
# Cache
- uses: actions/cache@v4
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ hashFiles(format('{0}/Assets/**', matrix.projectPath), format('{0}/Packages/**', matrix.projectPath), format('{0}/ProjectSettings/**', matrix.projectPath)) }}
restore-keys: |
Library-
# Run tests
- name: Run ${{ matrix.testMode }} tests
id: tests
uses: game-ci/[email protected]
env:
UNITY_LICENSE: ${{ secrets.UNITY_PERSONAL_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_PERSONAL_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PERSONAL_PASSWORD }}
with:
projectPath: ${{ matrix.projectPath }}
testMode: ${{ matrix.testMode }}
artifactsPath: test-${{ matrix.testMode }}-results
githubToken: ${{ secrets.GITHUB_TOKEN }}
checkName: "Test Results: ${{ matrix.testMode }}"
# Upload results
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ steps.tests.outputs.artifactsPath }}
path: ${{ steps.tests.outputs.artifactsPath }}
# if no files match the supplied path, fail job with error
if-no-files-found: error
# build job matrix
build:
name: Build for ${{ matrix.maroonBuildTarget }}
runs-on: ubuntu-latest
# create job matrix
# runs job once for each build target
strategy:
# if fail-fast is set to true, the job will abort if one of the builds fail
fail-fast: false
matrix:
include:
- targetPlatform: StandaloneWindows64
maroonBuildTarget: PC
projectPath: unity
- targetPlatform: StandaloneWindows64
maroonBuildTarget: VR
projectPath: unity
- targetPlatform: WebGL
maroonBuildTarget: WebGL
projectPath: unity
# this step is needed because the free GitHub runners come with limited disk space
# the action deletes unused files, packages and dependencies that the GitHub runner provides
# more info:
# https://game.ci/docs/troubleshooting/common-issues#no-space-left-on-device
# https://github.com/marketplace/actions/free-disk-space-ubuntu
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# excluded because they might be needed
docker-images: false
swap-storage: false
# excluded since it takes a very long time to run
large-packages: false
# Checkout
- name: Checkout repository
uses: actions/checkout@v4
# Cache
- uses: actions/cache@v4
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ hashFiles(format('{0}/Assets/**', matrix.projectPath), format('{0}/Packages/**', matrix.projectPath), format('{0}/ProjectSettings/**', matrix.projectPath)) }}
restore-keys: |
Library-
# Build
- name: Build
uses: game-ci/[email protected]
# environment vars needed by unity-builder to activate the unity license
# defined in the Actions Secrets in the repo settings
env:
UNITY_LICENSE: ${{ secrets.UNITY_PERSONAL_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_PERSONAL_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PERSONAL_PASSWORD }}
with:
# run the custom build script
buildMethod: Maroon.Build.BuildPlayer.ActionsBuild
# with these params:
customParameters: -maroonBuildPath ../build -maroonBuildTarget ${{ matrix.maroonBuildTarget }}
# we must specify a target platform, build path, build name and project path for unity-builder
targetPlatform: ${{ matrix.targetPlatform }}
projectPath: ${{ matrix.projectPath }}
buildName: ${{ matrix.maroonBuildTarget }}
buildsPath: build
# Upload build
- name: Upload build for ${{ matrix.maroonBuildTarget }}
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.maroonBuildTarget }}
path: build
# if no files match the supplied path, fail job with error
if-no-files-found: error
# deploy build
deploy:
name: Deploy to Steam
# only deploy if :
# the event happened on the development branch
# the event was not triggered by a schedule
# the builds were successful
# the tests were successful
if: |
github.ref_name == 'develop' &&
github.event_name != 'schedule' &&
needs.build.result == 'success' &&
needs.test.result == 'success'
# prevent that more than one deploy job runs at any given time
# https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idconcurrency
concurrency:
group: active-deployment
cancel-in-progress: false
runs-on: ubuntu-latest
needs: [test, build]
steps:
# download the build artifacts generated during the build job
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: build-*
# create release/ dir and move the PC and the VR build inside
- name: Preparing deployment
run: |
mkdir release
echo "Commit hash: ${{ github.sha }}"
mv build-PC/PC release/PC
mv build-VR/VR release/VR
# deploy via SteamPipe
- name: Deploy to Steam
uses: game-ci/steam-deploy@v3
with:
# username of the steam account used to upload
username: ${{ secrets.STEAM_USERNAME }}
# needed so we do not have to complete 2FA every time we deploy
# if the login fails, even though username and password have not changed
# it may be necessary to regenerate the config.vdf,
# base64 encode it and update the STEAM_CONFIG_VDF github secret
# https://game.ci/docs/github/deployment/steam#3-add-github-secrets
configVdf: ${{ secrets.STEAM_CONFIG_VDF}}
# appId of the application we are uploading to build for
appId: ${{ secrets.STEAM_APP_ID }}
# set build description to commit hash
buildDescription: CI/CD build ${{ github.sha }}
# path where SteamPipe looks for the build
rootPath: release
# path for depot1, relative form rootPath
# we only have 1 depot, so . is sufficient
depot1Path: .
# deploy to the development branch of the app
releaseBranch: development