-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
254 lines (225 loc) · 7.28 KB
/
.gitlab-ci.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
stages:
- prepare
- build_and_test
- deploy
# If you are looking for a place where to add 'UNITY_LICENSE_FILE' and other secrets, please visit your project's gitlab page:
# settings > CI/CD > Variables instead
variables:
BUILD_NAME: ExampleProjectName
UNITY_ACTIVATION_FILE: ./unity3d.alf
IMAGE: unityci/editor # https://hub.docker.com/r/unityci/editor
IMAGE_VERSION: "0" # This will automatically use latest v0.x.x, see https://github.com/game-ci/docker/releases
UNITY_DIR: $CI_PROJECT_DIR # this needs to be an absolute path. Defaults to the root of your tree.
# You can expose this in Unity via Application.version
VERSION_NUMBER_VAR: $CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID-$CI_JOB_ID
VERSION_BUILD_VAR: $CI_PIPELINE_IID
image: $IMAGE:$UNITY_VERSION-base-$IMAGE_VERSION
get-unity-version:
image: alpine
stage: prepare
variables:
GIT_DEPTH: 1
script:
- echo UNITY_VERSION=$(cat $UNITY_DIR/ProjectSettings/ProjectVersion.txt | grep "m_EditorVersion:.*" | awk '{ print $2}') | tee prepare.env
artifacts:
reports:
dotenv: prepare.env
.unity_before_script: &unity_before_script
before_script:
- chmod +x ./ci/before_script.sh && ./ci/before_script.sh
needs:
- job: get-unity-version
artifacts: true
.cache: &cache
cache:
key: "$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG-$TEST_PLATFORM"
paths:
- $UNITY_DIR/Library/
.license: &license
rules:
- if: '$UNITY_LICENSE != null'
when: always
.unity_defaults: &unity_defaults
<<:
- *unity_before_script
- *cache
- *license
# run this job when you need to request a license
# you may need to follow activation steps from documentation
get-activation-file:
<<: *unity_before_script
rules:
- if: '$UNITY_LICENSE == null'
when: manual
stage: prepare
script:
- chmod +x ./ci/get_activation_file.sh && ./ci/get_activation_file.sh
artifacts:
paths:
- $UNITY_ACTIVATION_FILE
expire_in: 10 min # Expiring this as artifacts may contain sensitive data and should not be kept public
.test: &test
stage: build_and_test
<<: *unity_defaults
script:
- chmod +x ./ci/test.sh && ./ci/test.sh
artifacts:
when: always
expire_in: 2 weeks
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
# you may need to remove or replace these to fit your need if you are using your own runners
tags:
- gitlab-org
coverage: /<Linecoverage>(.*?)</Linecoverage>/
# Tests without junit reporting results in GitLab
# test-playmode:
# <<: *test
# variables:
# TEST_PLATFORM: playmode
# TESTING_TYPE: NUNIT
# test-editmode:
# <<: *test
# variables:
# TEST_PLATFORM: editmode
# TESTING_TYPE: NUNIT
# uncomment the following blocks if you'd like to have junit reporting unity test results in gitlab
# We currently have the following issue which prevents it from working right now, but you can give
# a hand if you're interested in this feature:
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/151
.test-with-junit-reports: &test-with-junit-reports
stage: build_and_test
<<: *unity_defaults
script:
# This could be made faster by adding these packages to base image or running in a separate job (and step)
# We could use an image with these two depencencies only and only do the saxonb-xslt command on
# previous job's artifacts
- apt-get update && apt-get install -y default-jre libsaxonb-java
- chmod +x ./ci/test.sh && ./ci/test.sh
- saxonb-xslt -s $UNITY_DIR/$TEST_PLATFORM-results.xml -xsl $CI_PROJECT_DIR/ci/nunit-transforms/nunit3-junit.xslt >$UNITY_DIR/$TEST_PLATFORM-junit-results.xml
artifacts:
when: always
paths:
# This is exported to allow viewing the Coverage Report in detail if needed
- $UNITY_DIR/$TEST_PLATFORM-coverage/
reports:
junit:
- $UNITY_DIR/$TEST_PLATFORM-junit-results.xml
- "$UNITY_DIR/$TEST_PLATFORM-coverage/coverage.xml"
expire_in: 2 weeks
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
# you may need to remove or replace these to fit your need if you are using your own runners
tags:
- gitlab-org
coverage: /<Linecoverage>(.*?)</Linecoverage>/
test-playmode-with-junit-reports:
<<: *test-with-junit-reports
variables:
TEST_PLATFORM: playmode
TESTING_TYPE: JUNIT
test-editmode-with-junit-reports:
<<: *test-with-junit-reports
variables:
TEST_PLATFORM: editmode
TESTING_TYPE: JUNIT
.build: &build
stage: build_and_test
<<: *unity_defaults
script:
- chmod +x ./ci/build.sh && ./ci/build.sh
artifacts:
paths:
- $UNITY_DIR/Builds/
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
# you may need to remove or replace these to fit your need if you are using your own runners
tags:
- gitlab-org
build-StandaloneLinux64:
<<: *build
variables:
BUILD_TARGET: StandaloneLinux64
build-StandaloneLinux64-il2cpp:
<<: *build
image: $IMAGE:$UNITY_VERSION-linux-il2cpp-$IMAGE_VERSION
variables:
BUILD_TARGET: StandaloneLinux64
SCRIPTING_BACKEND: IL2CPP
build-StandaloneOSX:
<<: *build
image: $IMAGE:$UNITY_VERSION-mac-mono-$IMAGE_VERSION
variables:
BUILD_TARGET: StandaloneOSX
#Note: build target names changed in recent versions, use this for versions < 2017.2:
# build-StandaloneOSXUniversal:
# <<: *build
# variables:
# BUILD_TARGET: StandaloneOSXUniversal
build-StandaloneWindows64:
<<: *build
image: $IMAGE:$UNITY_VERSION-windows-mono-$IMAGE_VERSION
variables:
BUILD_TARGET: StandaloneWindows64
# For webgl support, you need to set Compression Format to Disabled for v0.9. See https://github.com/game-ci/docker/issues/75
build-WebGL:
<<: *build
image: $IMAGE:$UNITY_VERSION-webgl-$IMAGE_VERSION
# Temporary workaround for https://github.com/game-ci/docker/releases/tag/v0.9 and webgl support in current project to prevent errors with missing ffmpeg
before_script:
- chmod +x ./ci/before_script.sh && ./ci/before_script.sh
- apt-get update && apt-get install ffmpeg -y
variables:
BUILD_TARGET: WebGL
build-android:
<<: *build
image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION
variables:
BUILD_TARGET: Android
BUILD_APP_BUNDLE: "false"
build-android-il2cpp:
<<: *build
image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION
variables:
BUILD_TARGET: Android
BUILD_APP_BUNDLE: "false"
SCRIPTING_BACKEND: IL2CPP
#deploy-android:
# stage: deploy
# image: ruby
# script:
# - cd $UNITY_DIR/Builds/Android
# - echo $GPC_TOKEN > gpc_token.json
# - gem install bundler
# - bundle install
# - fastlane supply --aab "${BUILD_NAME}.aab" --track internal --package_name com.youcompany.yourgame --json_key ./gpc_token.json
# needs: ["build-android"]
build-ios-xcode:
<<: *build
image: $IMAGE:$UNITY_VERSION-ios-$IMAGE_VERSION
variables:
BUILD_TARGET: iOS
#build-and-deploy-ios:
# stage: deploy
# script:
# - cd $UNITY_DIR/Builds/iOS/$BUILD_NAME
# - pod install
# - fastlane ios beta
# tags:
# - ios
# - mac
# needs: ["build-ios-xcode"]
pages:
image: alpine:latest
stage: deploy
script:
- mv "$UNITY_DIR/Builds/WebGL/${BUILD_NAME}" public
artifacts:
paths:
- public
only:
- main
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: $CI_COMMIT_TAG
when: never
- when: always