-
Notifications
You must be signed in to change notification settings - Fork 0
257 lines (222 loc) · 8.27 KB
/
githubactionsbuilds.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
255
256
257
name: GitHubActionsBuilds
on: push
jobs:
generate_version_number:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
build_number: ${{ github.ref == 'refs/heads/master' && steps.buildnumber.outputs.build_number || 1 }}
steps:
- name: Generate build number
if: github.ref == 'refs/heads/master'
id: buildnumber
uses: onyxmueller/build-tag-number@v1
with:
token: ${{secrets.github_token}}
build_linux_WebGL:
needs: generate_version_number
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: devedse
password: ${{ secrets.DOCKERHUBTOKEN }}
# - name: Load Cache
# uses: actions/cache/restore@v3
# with:
# path: |
# UnityGame/Library
# key: build_linux_WebGL
- run: find .
- uses: game-ci/unity-builder@v3
name: Build WebGL
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE_FILE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: WebGL
projectPath: './UnityGame'
versioning: Custom
version: 1.0.${{needs.generate_version_number.outputs.build_number}}
# - name: Save Cache
# uses: actions/cache/save@v3
# with:
# path: |
# UnityGame/Library
# key: build_linux_WebGL
- run: find ./build
- uses: actions/upload-artifact@v3
with:
name: build_linux_WebGL
path: build/WebGL
# Docker build steps
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set Image Tags
id: tags
run: |
VERSION=1.0.${{needs.generate_version_number.outputs.build_number}}
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')
if [[ "${{ github.ref }}" == 'refs/heads/master' ]]; then
echo "TAGS=-t devedse/ld54_webgl:${VERSION} -t devedse/ld54_webgl:latest" >> $GITHUB_OUTPUT
elif [[ "${{ github.actor }}" == 'dependabot[bot]' ]]; then
echo "TAGS=-t devedse/ld54_webgl:beta_${BRANCH_NAME}" >> $GITHUB_OUTPUT
else
echo "TAGS=-t devedse/ld54_webgl:beta_${BRANCH_NAME} -t devedse/ld54_webgl:beta_nightly" >> $GITHUB_OUTPUT
fi
- name: Run Buildx
run: |
docker buildx build -f UnityGame/Docker/Dockerfile --build-arg BUILD_VERSION=${{steps.tags.outputs.version}} --platform linux/arm64,linux/amd64 ${{steps.tags.outputs.tags}} ${{ (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) && '--push' || '' }} .
build_linux_StandaloneWindows64:
needs: generate_version_number
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Disable IL2CPP
run: |
sed -i '/scriptingBackend:/,/Standalone:/ s/Standalone: [0-9]*/Standalone: 0/' UnityGame/ProjectSettings/ProjectSettings.asset
# - name: Load Cache
# uses: actions/cache/restore@v3
# with:
# path: |
# UnityGame/Library
# key: build_linux_StandaloneWindows64
- uses: game-ci/unity-builder@v3
name: Build StandaloneWindows64
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE_FILE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: StandaloneWindows64
allowDirtyBuild: true
projectPath: './UnityGame'
versioning: Custom
version: 1.0.${{needs.generate_version_number.outputs.build_number}}
# - name: Save Cache
# uses: actions/cache/save@v3
# with:
# path: |
# UnityGame/Library
# key: build_linux_StandaloneWindows64
- run: find ./build
- uses: actions/upload-artifact@v3
with:
name: build_linux_StandaloneWindows64
path: build/StandaloneWindows64
build_server_docker:
needs: generate_version_number
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: devedse
password: ${{ secrets.DOCKERHUBTOKEN }}
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Builder instance name
run: echo ${{ steps.buildx.outputs.name }}
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Set Image Tags
id: tags
run: |
VERSION=1.0.${{needs.generate_version_number.outputs.build_number}}
echo Version: $VERSION
echo github.ref: ${{ github.ref }}
echo github.actor: ${{ github.actor }}
echo branch name: ${GITHUB_REF#refs/heads/}
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')
echo parsed branch name: ${BRANCH_NAME}
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
if [[ "${{ github.ref }}" == 'refs/heads/master' ]]; then
echo "TAGS=-t devedse/ld54_server:${VERSION} -t devedse/ld54_server:latest" >> $GITHUB_OUTPUT
elif [[ "${{ github.actor }}" == 'dependabot[bot]' ]]; then
echo "TAGS=-t devedse/ld54_server:beta_${BRANCH_NAME}" >> $GITHUB_OUTPUT
else
echo "TAGS=-t devedse/ld54_server:beta_${BRANCH_NAME} -t devedse/ld54_server:beta_nightly" >> $GITHUB_OUTPUT
fi
- name: Run Buildx
run: |
docker buildx build -f UnityGameServer/UnityGameServer/Dockerfile --build-arg BUILD_VERSION=${{steps.tags.outputs.version}} --platform linux/arm64,linux/amd64 ${{steps.tags.outputs.tags}} ${{ (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) && '--push' || '' }} ./UnityGameServer
# build_windows_StandaloneWindows64:
# needs: generate_version_number
# runs-on: windows-2019
# steps:
# - uses: actions/checkout@v4
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: devedse
# password: ${{ secrets.DOCKERHUBTOKEN }}
# - uses: game-ci/unity-builder@v3
# name: Build StandaloneWindows64
# env:
# UNITY_LICENSE: ${{ secrets.UNITY_LICENSE_FILE }}
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# with:
# targetPlatform: StandaloneWindows64
# - run: find ./build
# - uses: actions/upload-artifact@v3
# with:
# name: build_windows_StandaloneWindows64
# path: build/StandaloneWindows64
release_github:
permissions:
contents: write
needs: [generate_version_number, build_linux_WebGL, build_linux_StandaloneWindows64]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: ./artifacts/
- name: Create Zip Archives
run: |
cd ./artifacts/
for dir in */; do
zip -r "${dir%/}.zip" "$dir"
done
ls -R
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: 1.0.${{ needs.generate_version_number.outputs.build_number }}
release_name: 1.0.${{ needs.generate_version_number.outputs.build_number }}
body: |
${{ github.event.head_commit.message }}
draft: false
prerelease: false
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: 1.0.${{ needs.generate_version_number.outputs.build_number }}
files: |
./artifacts/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}