|
| 1 | +stages: |
| 2 | + - prepare |
| 3 | + - build_and_test |
| 4 | + - deploy |
| 5 | + |
| 6 | +# If you are looking for a place where to add 'UNITY_LICENSE_FILE' and other secrets, please visit your project's gitlab page: |
| 7 | +# settings > CI/CD > Variables instead |
| 8 | +variables: |
| 9 | + BUILD_NAME: web3-game-kit |
| 10 | + UNITY_ACTIVATION_FILE: ./unity3d.alf |
| 11 | + IMAGE: unityci/editor # https://hub.docker.com/r/unityci/editor |
| 12 | + IMAGE_VERSION: 1 # This will automatically use latest v1.x.x, see https://github.com/game-ci/docker/releases |
| 13 | + UNITY_DIR: $CI_PROJECT_DIR # this needs to be an absolute path. Defaults to the root of your tree. |
| 14 | + # You can expose this in Unity via Application.version |
| 15 | + VERSION_NUMBER_VAR: $CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID-$CI_JOB_ID |
| 16 | + VERSION_BUILD_VAR: $CI_PIPELINE_IID |
| 17 | + |
| 18 | +image: $IMAGE:$UNITY_VERSION-base-$IMAGE_VERSION |
| 19 | + |
| 20 | +get-unity-version: |
| 21 | + image: alpine |
| 22 | + stage: prepare |
| 23 | + variables: |
| 24 | + GIT_DEPTH: 1 |
| 25 | + script: |
| 26 | + - echo UNITY_VERSION=$(cat $UNITY_DIR/ProjectSettings/ProjectVersion.txt | grep "m_EditorVersion:.*" | awk '{ print $2}') | tee prepare.env |
| 27 | + artifacts: |
| 28 | + reports: |
| 29 | + dotenv: prepare.env |
| 30 | + |
| 31 | +.unity_before_script: &unity_before_script |
| 32 | + before_script: |
| 33 | + - chmod +x ./ci/before_script.sh && ./ci/before_script.sh |
| 34 | + - sed -i 's,DappUrl'":"' ,DappUrl'":"' '"${DAPP_URL}"',' ./Assets/Moralis\ Web3\ Unity\ SDK/Resources/MoralisServerSettings.asset |
| 35 | + - sed -i 's,DappId'":"' ,DappId'":"' '"${DAPP_ID}"',' ./Assets/Moralis\ Web3\ Unity\ SDK/Resources/MoralisServerSettings.asset |
| 36 | + needs: |
| 37 | + - job: get-unity-version |
| 38 | + artifacts: true |
| 39 | + |
| 40 | +.cache: &cache |
| 41 | + cache: |
| 42 | + key: "$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG-$TEST_PLATFORM" |
| 43 | + paths: |
| 44 | + - $UNITY_DIR/Library/ |
| 45 | + |
| 46 | +.license: &license |
| 47 | + rules: |
| 48 | + - if: '$UNITY_LICENSE != null' |
| 49 | + when: always |
| 50 | + |
| 51 | +.unity_defaults: &unity_defaults |
| 52 | + <<: |
| 53 | + - *unity_before_script |
| 54 | + - *cache |
| 55 | + - *license |
| 56 | + |
| 57 | +# run this job when you need to request a license |
| 58 | +# you may need to follow activation steps from documentation |
| 59 | +get-activation-file: |
| 60 | + <<: *unity_before_script |
| 61 | + rules: |
| 62 | + - if: '$UNITY_LICENSE == null' |
| 63 | + when: manual |
| 64 | + stage: prepare |
| 65 | + script: |
| 66 | + - chmod +x ./ci/get_activation_file.sh && ./ci/get_activation_file.sh |
| 67 | + artifacts: |
| 68 | + paths: |
| 69 | + - $UNITY_ACTIVATION_FILE |
| 70 | + expire_in: 10 min # Expiring this as artifacts may contain sensitive data and should not be kept public |
| 71 | + |
| 72 | +.test: &test |
| 73 | + stage: build_and_test |
| 74 | + <<: *unity_defaults |
| 75 | + script: |
| 76 | + - chmod +x ./ci/test.sh && ./ci/test.sh |
| 77 | + artifacts: |
| 78 | + when: always |
| 79 | + expire_in: 2 weeks |
| 80 | + coverage: /<Linecoverage>(.*?)</Linecoverage>/ |
| 81 | + |
| 82 | +# Tests without junit reporting results in GitLab |
| 83 | +# test-playmode: |
| 84 | +# <<: *test |
| 85 | +# variables: |
| 86 | +# TEST_PLATFORM: playmode |
| 87 | +# TESTING_TYPE: NUNIT |
| 88 | + |
| 89 | +# test-editmode: |
| 90 | +# <<: *test |
| 91 | +# variables: |
| 92 | +# TEST_PLATFORM: editmode |
| 93 | +# TESTING_TYPE: NUNIT |
| 94 | + |
| 95 | +# uncomment the following blocks if you'd like to have junit reporting unity test results in gitlab |
| 96 | +# We currently have the following issue which prevents it from working right now, but you can give |
| 97 | +# a hand if you're interested in this feature: |
| 98 | +# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/151 |
| 99 | + |
| 100 | +.test-with-junit-reports: &test-with-junit-reports |
| 101 | + stage: build_and_test |
| 102 | + <<: *unity_defaults |
| 103 | + script: |
| 104 | + # This could be made faster by adding these packages to base image or running in a separate job (and step) |
| 105 | + # We could use an image with these two depencencies only and only do the saxonb-xslt command on |
| 106 | + # previous job's artifacts |
| 107 | + - apt-get update && apt-get install -y default-jre libsaxonb-java |
| 108 | + - chmod +x ./ci/test.sh && ./ci/test.sh |
| 109 | + - 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 |
| 110 | + artifacts: |
| 111 | + when: always |
| 112 | + paths: |
| 113 | + # This is exported to allow viewing the Coverage Report in detail if needed |
| 114 | + - $UNITY_DIR/$TEST_PLATFORM-coverage/ |
| 115 | + reports: |
| 116 | + junit: |
| 117 | + - $UNITY_DIR/$TEST_PLATFORM-junit-results.xml |
| 118 | + - "$UNITY_DIR/$TEST_PLATFORM-coverage/coverage.xml" |
| 119 | + expire_in: 2 weeks |
| 120 | + coverage: /<Linecoverage>(.*?)</Linecoverage>/ |
| 121 | + |
| 122 | +test-playmode-with-junit-reports: |
| 123 | + <<: *test-with-junit-reports |
| 124 | + variables: |
| 125 | + TEST_PLATFORM: playmode |
| 126 | + TESTING_TYPE: JUNIT |
| 127 | + |
| 128 | +test-editmode-with-junit-reports: |
| 129 | + <<: *test-with-junit-reports |
| 130 | + variables: |
| 131 | + TEST_PLATFORM: editmode |
| 132 | + TESTING_TYPE: JUNIT |
| 133 | + |
| 134 | +.build: &build |
| 135 | + stage: build_and_test |
| 136 | + <<: *unity_defaults |
| 137 | + script: |
| 138 | + - chmod +x ./ci/build.sh && ./ci/build.sh |
| 139 | + artifacts: |
| 140 | + paths: |
| 141 | + - $UNITY_DIR/Builds/ |
| 142 | + |
| 143 | +build-StandaloneLinux64: |
| 144 | + <<: *build |
| 145 | + variables: |
| 146 | + BUILD_TARGET: StandaloneLinux64 |
| 147 | + |
| 148 | +build-StandaloneLinux64-il2cpp: |
| 149 | + <<: *build |
| 150 | + image: $IMAGE:$UNITY_VERSION-linux-il2cpp-$IMAGE_VERSION |
| 151 | + variables: |
| 152 | + BUILD_TARGET: StandaloneLinux64 |
| 153 | + SCRIPTING_BACKEND: IL2CPP |
| 154 | + |
| 155 | +build-StandaloneOSX: |
| 156 | + <<: *build |
| 157 | + image: $IMAGE:$UNITY_VERSION-mac-mono-$IMAGE_VERSION |
| 158 | + variables: |
| 159 | + BUILD_TARGET: StandaloneOSX |
| 160 | + |
| 161 | +#Note: build target names changed in recent versions, use this for versions < 2017.2: |
| 162 | +# build-StandaloneOSXUniversal: |
| 163 | +# <<: *build |
| 164 | +# variables: |
| 165 | +# BUILD_TARGET: StandaloneOSXUniversal |
| 166 | + |
| 167 | +build-StandaloneWindows64: |
| 168 | + <<: *build |
| 169 | + image: $IMAGE:$UNITY_VERSION-windows-mono-$IMAGE_VERSION |
| 170 | + variables: |
| 171 | + BUILD_TARGET: StandaloneWindows64 |
| 172 | + |
| 173 | +# For webgl support, you need to set Compression Format to Disabled for v0.9. See https://github.com/game-ci/docker/issues/75 |
| 174 | +build-WebGL: |
| 175 | + <<: *build |
| 176 | + image: $IMAGE:$UNITY_VERSION-webgl-$IMAGE_VERSION |
| 177 | + # 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 |
| 178 | + before_script: |
| 179 | + - chmod +x ./ci/before_script.sh && ./ci/before_script.sh |
| 180 | + - apt-get update && apt-get install ffmpeg -y |
| 181 | + variables: |
| 182 | + BUILD_TARGET: WebGL |
| 183 | + |
| 184 | +build-android: |
| 185 | + <<: *build |
| 186 | + image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION |
| 187 | + variables: |
| 188 | + BUILD_TARGET: Android |
| 189 | + BUILD_APP_BUNDLE: "false" |
| 190 | + |
| 191 | +build-android-il2cpp: |
| 192 | + <<: *build |
| 193 | + image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION |
| 194 | + variables: |
| 195 | + BUILD_TARGET: Android |
| 196 | + BUILD_APP_BUNDLE: "false" |
| 197 | + SCRIPTING_BACKEND: IL2CPP |
| 198 | + |
| 199 | +#deploy-android: |
| 200 | +# stage: deploy |
| 201 | +# image: ruby |
| 202 | +# script: |
| 203 | +# - cd $UNITY_DIR/Builds/Android |
| 204 | +# - echo $GPC_TOKEN > gpc_token.json |
| 205 | +# - gem install bundler |
| 206 | +# - bundle install |
| 207 | +# - fastlane supply --aab "${BUILD_NAME}.aab" --track internal --package_name com.youcompany.yourgame --json_key ./gpc_token.json |
| 208 | +# needs: ["build-android"] |
| 209 | + |
| 210 | +build-ios-xcode: |
| 211 | + <<: *build |
| 212 | + image: $IMAGE:$UNITY_VERSION-ios-$IMAGE_VERSION |
| 213 | + variables: |
| 214 | + BUILD_TARGET: iOS |
| 215 | + |
| 216 | +#build-and-deploy-ios: |
| 217 | +# stage: deploy |
| 218 | +# script: |
| 219 | +# - cd $UNITY_DIR/Builds/iOS/$BUILD_NAME |
| 220 | +# - pod install |
| 221 | +# - fastlane ios beta |
| 222 | +# tags: |
| 223 | +# - ios |
| 224 | +# - mac |
| 225 | +# needs: ["build-ios-xcode"] |
| 226 | + |
| 227 | +pages: |
| 228 | + image: alpine:latest |
| 229 | + stage: deploy |
| 230 | + script: |
| 231 | + - mv "$UNITY_DIR/Builds/WebGL/${BUILD_NAME}" public |
| 232 | + artifacts: |
| 233 | + paths: |
| 234 | + - public |
| 235 | + only: |
| 236 | + - $CI_DEFAULT_BRANCH |
| 237 | + |
| 238 | +workflow: |
| 239 | + rules: |
| 240 | + - if: $CI_MERGE_REQUEST_ID |
| 241 | + when: never |
| 242 | + - if: $CI_COMMIT_TAG |
| 243 | + when: never |
| 244 | + - when: always |
0 commit comments