-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcloudbuild.yaml
125 lines (114 loc) · 4.21 KB
/
cloudbuild.yaml
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
# Copyright 2023 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
serviceAccount: projects/${PROJECT_ID}/serviceAccounts/cloudbuild-cicd@${PROJECT_ID}.iam.gserviceaccount.com
steps:
#
# Build the unreal editor build image if it does not exist.
#
- name: gcr.io/cloud-builders/gcloud
id: build-unreal-editor-container
dir: /workspace/unreal-engine
script: |
gcloud container images describe $_BUILD_IMAGE || gcloud builds submit --substitutions _UNREAL_VERSION=$_UNREAL_VERSION --config=cloudbuild.yaml .
automapSubstitutions: true
waitFor: ['-']
#
# Game Launcher building
#
- name: gcr.io/cloud-builders/gcloud
id: get-front-end
dir: /workspace/GameLauncher
script: |
echo "export IP_ADDRESS=$(gcloud compute addresses list --filter=name=frontend-service --format='value(address)')" > .env && \
cat .env
waitFor: ['-']
- name: golang:1.21.4
id: linux-game-launcher
dir: /workspace/GameLauncher
script: |
apt update && \
apt install -y golang gcc libgl1-mesa-dev xorg-dev zip gettext-base && \
go build . && \
. ./.env && \
envsubst < app.ini.sample > app.ini && \
cat app.ini && \
zip -ur /workspace/Client-$BUILD_ID.zip launcher app.ini assets
automapSubstitutions: true
waitFor:
- get-front-end
#
# Game Client Building
#
- name: ${_BUILD_IMAGE}
id: linux-unreal-client
dir: /home/ue4
script: |
df -h && \
echo "who: $(whoami)" && \
sudo mkdir -pv "/builder/home/Library/Logs/Unreal Engine/LocalBuildLogs" && sudo chown -R ue4:ue4 /builder && \
touch "/builder/home/Library/Logs/Unreal Engine/LocalBuildLogs/empty.log" && \
sudo cp -r /workspace /tmp/project && sudo chown -R ue4:ue4 /tmp/project && ls -l /tmp/project && \
/home/ue4/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \
-project=/tmp/project/Droidshooter.uproject -noP4 -clientconfig=Development \
-utf8output -NoDebugInfo -AllMaps -platform=Linux -client -build -cook -pak -stage -prereqs -package \
-archive -archivedirectory=/tmp/project/Packaged && \
cd /tmp/project/Packaged/LinuxClient && sudo zip -ur /workspace/Client-$BUILD_ID.zip .
automapSubstitutions: true
waitFor:
- build-unreal-editor-container
- linux-game-launcher
#
# Building of the dedicate game server images
#
- name: gcr.io/cloud-builders/docker
id: dedicated-server
args: [ "build", "--build-arg", "BASE_IMAGE=${_BUILD_IMAGE}", ".", "-t", "${_UNREAL_SERVER_IMAGE}" ]
waitFor:
- linux-unreal-client
#
# Deployment
#
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
id: cloud-deploy-release
script: |
gcloud deploy releases create deploy-$(date +'%Y%m%d%H%M%S') \
--annotations=cloud_build=https://console.cloud.google.com/cloud-build/builds/${BUILD_ID} \
--delivery-pipeline global-game-agones-gameservers \
--skaffold-file skaffold.yaml \
--images droidshooter-server=$_UNREAL_SERVER_IMAGE \
--region us-central1
automapSubstitutions: true
waitFor:
- dedicated-server
artifacts:
images:
- ${_REGISTRY}/droidshooter-server
objects:
location: gs://${PROJECT_ID}-release-artifacts
paths:
- Client-${BUILD_ID}.zip
substitutions:
_UNREAL_VERSION: 5.2.0
_BUILD_IMAGE: us-docker.pkg.dev/${PROJECT_ID}/global-game-images/unreal-engine:${_UNREAL_VERSION}
_UNREAL_SERVER_IMAGE: ${_REGISTRY}/droidshooter-server:${BUILD_ID}
_REGISTRY: us-docker.pkg.dev/${PROJECT_ID}/global-game-images
options:
dynamic_substitutions: true
machineType: E2_HIGHCPU_32
logging: CLOUD_LOGGING_ONLY
diskSizeGb: '500'
timeout: 36000s
tags:
- global-game-demo
- game