forked from immutable/ts-immutable-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
252 lines (216 loc) · 9.34 KB
/
build-game-bridge.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
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
# Workflow to manually trigger a build of the game bridge with the selected SDK tag
# and create a PR with the changes to the game SDK repository.
name: Build Game Bridge
on:
workflow_dispatch:
inputs:
ts_sdk_tag:
type: string
description: TS SDK version tag
required: true
game_engine:
type: choice
description: Game SDK to update
options:
- Unity
- Unreal
- Both
required: true
default: Unity
dry_run:
type: boolean
description: "(Optional) Dry run"
required: false
default: false
env:
TS_SDK_TAG: ${{ github.event.inputs.ts_sdk_tag }}
GAME_ENGINE: ${{ github.event.inputs.game_engine }}
DRY_RUN: ${{ github.event.inputs.dry_run }}
GH_TOKEN: ${{ secrets.TS_IMMUTABLE_SDK_GITHUB_TOKEN }}
SDK_TEAM_MEMBERS: ${{ secrets.SDK_TEAM_MEMBERS }}
CI: true
jobs:
build-game-bridge:
name: Build Game Bridge
runs-on: ubuntu-latest-4-cores
env:
NODE_OPTIONS: --max-old-space-size=14366
steps:
- name: Checkout SDK Repository
id: checkout-sdk
uses: actions/checkout@v4
with:
ref: "${{ env.TS_SDK_TAG }}"
fetch-depth: 0
- name: Check SDK Team Membership
id: allowed_actors_check
# only allow SDK team members to run this workflow
# ["ckailash", "CodeSchwert", "wdinau", "shineli1984", "nattb8", "YermekG", "zaidarain1"]
if: ${{ contains(fromJson(env.SDK_TEAM_MEMBERS), github.triggering_actor) }}
run: echo "ALLOWED_ACTOR=true" >> $GITHUB_OUTPUT
- name: Allowed Actors Filter
if: ${{ steps.allowed_actors_check.outputs.ALLOWED_ACTOR != 'true' }}
run: exit 1
- name: setup
uses: ./.github/actions/setup
- name: Set TS SDK hash
run: echo "TS_SDK_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Build Game Bridge
run: yarn nx run @imtbl/game-bridge:build --skip-nx-cache
- name: Update Version Strings
run: cd packages/game-bridge && ./scripts/updateSdkVersion.sh
# - name: Check Unity Version String Updated
# if: ${{ github.event.inputs.game_engine == 'Unity' || github.event.inputs.game_engine == 'Both' }}
# run: |
# UNITY_ARTIFACT_PATH="./packages/game-bridge/dist/unity/index.html"
# UNITY_VERSION_STRING_COUNT=$(cat $UNITY_ARTIFACT_PATH | grep -c -o "ts-immutable-sdk-${{ env.TS_SDK_TAG }}")
# if [ "$UNITY_VERSION_STRING_COUNT" -eq 0 ]; then
# echo "Error: Updated version string not found in $UNITY_ARTIFACT_PATH"
# exit 1
# fi
# - name: Check Unreal Version String Updated
# if: ${{ github.event.inputs.game_engine == 'Unreal' || github.event.inputs.game_engine == 'Both' }}
# run: |
# UNREAL_ARTIFACT_PATH="./packages/game-bridge/dist/unreal/index.js"
# UNREAL_VERSION_STRING_COUNT=$(cat $UNREAL_ARTIFACT_PATH | grep -c -o "ts-immutable-sdk-${{ env.TS_SDK_TAG }}")
# if [ "$UNREAL_VERSION_STRING_COUNT" -eq 0 ]; then
# echo "Error: Updated version string not found in $UNREAL_ARTIFACT_PATH"
# exit 1
# fi
- name: Cache build artifacts
uses: actions/cache@v4
with:
path: ./packages/game-bridge/dist
key: "${{ runner.os }}-game-bridge-build-${{ env.TS_SDK_TAG }}"
- name: Upload Game Bridge Build
uses: actions/upload-artifact@v4
with:
path: ./packages/game-bridge/dist
create-unity-pr:
name: Create Unity PR
needs: build-game-bridge
if: ${{ github.event.inputs.game_engine == 'Unity' || github.event.inputs.game_engine == 'Both' }}
runs-on: ubuntu-latest-4-cores
steps:
- name: Checkout SDK Repository
uses: actions/checkout@v4
with:
token: ${{ env.GH_TOKEN }}
ref: "${{ env.TS_SDK_TAG }}"
- name: Setup Github
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Restore Cached Build Artifacts
id: restore-cache-game-bridge-build
uses: actions/cache@v4
with:
path: ./packages/game-bridge/dist
key: ${{ runner.os }}-game-bridge-build-${{ env.TS_SDK_TAG }}
- name: Check Cache Restore
if: steps.restore-cache-game-bridge-build.outputs.cache-hit != 'true'
run: echo "Game Bridge build cache not restored, exiting" && exit 1
- name: Checkout Unity SDK Repo
uses: actions/checkout@v4
with:
repository: immutable/unity-immutable-sdk
token: ${{ env.GH_TOKEN }}
path: unity-immutable-sdk
ref: main
clean: true
fetch-depth: 0
- name: Change Unity Branch
run: |
cd unity-immutable-sdk
git checkout -b "chore/update-game-bridge-${{ env.TS_SDK_TAG }}"
cd ..
- name: Copy Game Bridge Build
run: cp -r ./packages/game-bridge/dist/unity/index.html ./unity-immutable-sdk/src/Packages/Passport/Runtime/Resources/index.html
- name: Commit Changes
run: |
cd unity-immutable-sdk
git add src/Packages/Passport/Runtime/Resources/index.html
git commit -m "chore: update game bridge to ${{ env.TS_SDK_TAG }}"
cd ..
- name: Push Changes
if: ${{ env.DRY_RUN == 'false' }}
run: |
cd unity-immutable-sdk
git push -u origin "chore/update-game-bridge-${{ env.TS_SDK_TAG }}"
cd ..
- name: Create PR (Dry Run)
if: ${{ env.DRY_RUN == 'true' }}
run: |
cd unity-immutable-sdk
echo "gh pr create --base main --head chore/update-game-bridge-${{ env.TS_SDK_TAG }} --title 'chore: update game bridge to ${{ env.TS_SDK_TAG }}' --body 'Update game bridge (build from ts-immutable-sdk version [${{ env.TS_SDK_TAG }}](https://github.com/immutable/ts-immutable-sdk/releases/tag/${{ env.TS_SDK_TAG }}))'"
cd ..
- name: Create PR
if: ${{ env.DRY_RUN == 'false' }}
run: |
cd unity-immutable-sdk
gh pr create --base main --head "chore/update-game-bridge-${{ env.TS_SDK_TAG }}" --title "chore: update game bridge to ${{ env.TS_SDK_TAG }}" --body "Update game bridge (build from ts-immutable-sdk version [${{ env.TS_SDK_TAG }}](https://github.com/immutable/ts-immutable-sdk/releases/tag/${{ env.TS_SDK_TAG }}))"
cd ..
create-unreal-pr:
name: Create Unreal PR
needs: build-game-bridge
if: ${{ github.event.inputs.game_engine == 'Unreal' || github.event.inputs.game_engine == 'Both' }}
runs-on: ubuntu-latest-4-cores
steps:
- name: Checkout SDK Repository
uses: actions/checkout@v4
with:
token: ${{ env.GH_TOKEN }}
ref: "${{ env.TS_SDK_TAG }}"
- name: Setup Github
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Restore Cached Build Artifacts
id: restore-cache-game-bridge-build
uses: actions/cache@v4
with:
path: ./packages/game-bridge/dist
key: ${{ runner.os }}-game-bridge-build-${{ env.TS_SDK_TAG }}
- name: Check Cache Restore
if: steps.restore-cache-game-bridge-build.outputs.cache-hit != 'true'
run: echo "Game Bridge build cache not restored, exiting" && exit 1
- name: Checkout Unreal SDK Repo
uses: actions/checkout@v4
with:
repository: immutable/unreal-immutable-sdk
token: ${{ env.GH_TOKEN }}
path: unreal-immutable-sdk
ref: main
clean: true
fetch-depth: 0
- name: Change Unreal Branch
run: |
cd unreal-immutable-sdk
git checkout -b "chore/update-game-bridge-${{ env.TS_SDK_TAG }}"
cd ..
- name: Copy Game Bridge Build
run: cp -r ./packages/game-bridge/dist/unreal/index.js ./unreal-immutable-sdk/Web/index.js
- name: Commit Changes
run: |
cd unreal-immutable-sdk
git add Web/index.js
git commit -m "chore: update game bridge to ${{ env.TS_SDK_TAG }}"
cd ..
- name: Push Changes
if: ${{ env.DRY_RUN == 'false' }}
run: |
cd unreal-immutable-sdk
git push -u origin "chore/update-game-bridge-${{ env.TS_SDK_TAG }}"
cd ..
- name: Create PR (Dry Run)
if: ${{ env.DRY_RUN == 'true' }}
run: |
cd unreal-immutable-sdk
echo "gh pr create --base main --head chore/update-game-bridge-${{ env.TS_SDK_TAG }} --title 'chore: update game bridge to ${{ env.TS_SDK_TAG }}' --body 'Update game bridge (build from ts-immutable-sdk version [${{ env.TS_SDK_TAG }}](https://github.com/immutable/ts-immutable-sdk/releases/tag/${{ env.TS_SDK_TAG }}))'"
cd ..
- name: Create PR
if: ${{ env.DRY_RUN == 'false' }}
run: |
cd unreal-immutable-sdk
gh pr create --base main --head "chore/update-game-bridge-${{ env.TS_SDK_TAG }}" --title "chore: update game bridge to ${{ env.TS_SDK_TAG }}" --body "Update game bridge (build from ts-immutable-sdk version [${{ env.TS_SDK_TAG }}](https://github.com/immutable/ts-immutable-sdk/releases/tag/${{ env.TS_SDK_TAG }}))"
cd ..