Skip to content

Commit 6412177

Browse files
committed
Merge branch 'master' into 2022.2-urp
# Conflicts: # Packages/manifest.json # Packages/packages-lock.json # ProjectSettings/ProjectVersion.txt
2 parents 4ed15bf + 595c22a commit 6412177

38 files changed

+1418
-307
lines changed

.github/scripts/add-tags.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# This script creates tags for the given unity version to trigger the release workflow
3+
# example usage
4+
# sh add-tags.sh "6000.0.0f1" -> Creates tags for non-urp version
5+
# sh add-tags.sh "6000.0.0f1" "true" -> Creates tags for urp version
6+
7+
# Input parameters
8+
UNITY_VERSION=$1
9+
IS_URP=${2:-"false"}
10+
echo "Running add_tags.sh with UNITY_VERSION: $UNITY_VERSION, IS_URP: $IS_URP"
11+
12+
# Extract the value before the first dot as an integer
13+
MAJOR_VERSION=$(echo $UNITY_VERSION | cut -d. -f1)
14+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
15+
16+
TAG_PREFIX=$UNITY_VERSION
17+
if [[ "$IS_URP" == "true" ]]
18+
then
19+
TAG_PREFIX=$UNITY_VERSION-urp
20+
fi
21+
22+
if [[ "$MAJOR_VERSION" -lt "2023" ]]
23+
then
24+
git tag -a -f $TAG_PREFIX-minsize-webgl1 -m "[Automated workflow] Created by upgrade-unity"
25+
git tag -a -f $TAG_PREFIX-webgl1 -m "[Automated workflow] Created by upgrade-unity"
26+
else
27+
git tag -a -f $TAG_PREFIX-minsize-webgl2 -m "[Automated workflow] Created by upgrade-unity"
28+
fi
29+
# Push tags in between - pushing more than 3 tags won't trigger tag workflows
30+
git push origin -f --tags
31+
32+
git tag -a -f $TAG_PREFIX-webgl2 -m "[Automated workflow] Created by upgrade-unity"
33+
git tag -a -f $TAG_PREFIX-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
34+
35+
if [[ "$MAJOR_VERSION" -ge "6000" ]]
36+
then
37+
git tag -a -f $TAG_PREFIX-webgpu -m "[Automated workflow] Created by upgrade-unity"
38+
fi
39+
40+
git push origin -f --tags

.github/templates/upgrade-unity-pr-body.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
### Built version demos
66

77
* https://deml.io/experiments/unity-webgl/{{ .unityversion }}-webgl2
8-
* https://deml.io/experiments/unity-webgl/{{ .unityversion }}-webgl1
8+
* https://deml.io/experiments/unity-webgl/{{ .unityversion }}-webgl2-debug
9+
* https://deml.io/experiments/unity-webgl/{{ .unityversion }}-minsize-webgl2
910

1011
### Other links
1112

.github/workflows/activation.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
push:
66
tags:
77
- '*'
8+
branches:
9+
- master
810

911
jobs:
1012
variables:
@@ -28,7 +30,12 @@ jobs:
2830
2931
- name: Set tag
3032
id: set_tag
31-
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
33+
run: |
34+
if [[ $GITHUB_REF == refs/tags/* ]]; then
35+
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
36+
else
37+
echo "VERSION=${{ steps.set_unity_version.outputs.VERSION }}-webgl2-master" >> $GITHUB_OUTPUT
38+
fi
3239
3340
- name: Set target name
3441
id: set_build_name
@@ -62,30 +69,40 @@ jobs:
6269
6370
buildProject:
6471
name: Create Unity WebGL Build 🏗
65-
# only build with additional parameters, the tag alone should only create a release draft
66-
if: ${{ needs.variables.outputs.TAG != needs.variables.outputs.UNITY_VERSION }}
72+
# Build if it's a master push or if the tag is not just the unity version
73+
if: ${{ github.ref == 'refs/heads/master' || needs.variables.outputs.TAG != needs.variables.outputs.UNITY_VERSION }}
6774
needs: [ variables ]
6875
runs-on: ubuntu-latest
69-
strategy:
70-
fail-fast: false
7176
steps:
7277
- uses: actions/checkout@v4
7378
with:
7479
fetch-depth: 0
7580
lfs: true
7681

82+
# Avoid running into space issues for github runners - Docker images can take up quite some space
83+
- name: Free Disk Space
84+
run: |
85+
echo "Disk space before cleanup:"
86+
df -h
87+
sudo rm -rf /usr/share/dotnet
88+
sudo rm -rf /opt/ghc
89+
sudo rm -rf /usr/local/share/boost
90+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
91+
echo "Disk space after cleanup:"
92+
df -h
93+
7794
# Unity 2020 cache is not compatible with older versions
7895
- name: Unity Library Cache 2020 or higher
7996
if: ${{ !startsWith(needs.variables.outputs.UNITY_VERSION, '201') }}
80-
uses: actions/cache@v3
97+
uses: actions/cache@v4
8198
with:
8299
path: Library
83100
key: Library-202x-WebGL
84101
restore-keys: Library-202x-
85102

86103
- name: Unity Library Cache 2019 or lower
87104
if: ${{ startsWith(needs.variables.outputs.UNITY_VERSION, '201') }}
88-
uses: actions/cache@v3
105+
uses: actions/cache@v4
89106
with:
90107
path: Library
91108
key: Library-201x-WebGL
@@ -101,22 +118,34 @@ jobs:
101118
buildMethod: UnityBuilderAction.BuildScript.BuildWithCommandlineArgs
102119
customParameters: -tag ${{ needs.variables.outputs.TAG }}
103120
targetPlatform: WebGL
121+
versioning: None
104122
buildName: ${{ needs.variables.outputs.BUILD_NAME }}
105123

106-
- uses: actions/upload-artifact@v3
124+
- name: Check Disk Space After Build
125+
run: |
126+
echo "Disk space after build:"
127+
df -h
128+
AVAILABLE=$(df / | tail -1 | awk '{print $4}')
129+
AVAILABLE_GB=$(echo $AVAILABLE | sed 's/G//')
130+
echo "Available space: ${AVAILABLE_GB}GB"
131+
if (( $(echo "$AVAILABLE_GB < 1" | bc -l) )); then
132+
echo "::warning::Low disk space! Less than 1GB remaining."
133+
fi
134+
135+
- uses: actions/upload-artifact@v4
107136
with:
108137
name: ${{ needs.variables.outputs.BUILD_NAME }}
109138
path: build/WebGL
110139

111140
createRelease:
112141
name: Create Github release 🐙
113142
# only run for the pure tag without build parameters
114-
if: ${{ needs.variables.outputs.TAG == needs.variables.outputs.UNITY_VERSION }}
143+
if: ${{ github.ref_type == 'tag' && needs.variables.outputs.TAG == needs.variables.outputs.UNITY_VERSION }}
115144
needs: [ variables ]
116145
runs-on: ubuntu-latest
117146
steps:
118147
- name: Create Release
119-
uses: softprops/action-gh-release@v1
148+
uses: softprops/action-gh-release@v2
120149
with:
121150
body: |
122151
## Changes
@@ -140,7 +169,7 @@ jobs:
140169
- name: Checkout code
141170
uses: actions/checkout@v4
142171

143-
- uses: actions/download-artifact@v3
172+
- uses: actions/download-artifact@v4
144173
with:
145174
name: ${{ needs.variables.outputs.BUILD_NAME }}
146175
path: build
@@ -150,7 +179,7 @@ jobs:
150179
working-directory: build/${{ needs.variables.outputs.BUILD_NAME }}
151180

152181
- name: Deploy ⤴
153-
uses: SamKirkland/FTP-Deploy-Action@4.3.3
182+
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
154183
with:
155184
server: ${{ secrets.FTP_SERVER }}
156185
username: ${{ secrets.FTP_USER }}

.github/workflows/upgrade-unity.yml

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ on:
2929
required: false
3030
type: string
3131
default: '-accept-apiupdate'
32+
delayTags:
33+
description: 'Delay before force pushing tags (in minutes)'
34+
required: false
35+
type: number
36+
default: 0
3237

3338
jobs:
3439
upgrade-unity-version:
35-
name: Upgrade Unity version and packages
40+
name: Upgrade Unity version and packages to ${{ inputs.unityVersion }}
3641
runs-on: ubuntu-latest
37-
strategy:
38-
fail-fast: false
3942
steps:
4043
- name: Log input parameter
4144
run: |
@@ -47,6 +50,7 @@ jobs:
4750
echo "Only create tags: $TAGS_ONLY"
4851
echo "Merge master into branch: $MERGE_MASTER"
4952
echo "Custom cli arguments: $CUSTOM_PARAMETERS"
53+
echo "Delay tags: $DELAY_TAGS minutes"
5054
if [[ "$BRANCH_NAME" == *"urp"* ]]
5155
then
5256
echo "urp: true"
@@ -59,6 +63,7 @@ jobs:
5963
TAGS_ONLY: ${{ inputs.tagsOnly }}
6064
MERGE_MASTER: ${{ inputs.mergeMaster }}
6165
CUSTOM_PARAMETERS: ${{ inputs.customParameters }}
66+
DELAY_TAGS: ${{ inputs.delayTags }}
6267

6368
- uses: actions/checkout@v4
6469
with:
@@ -75,6 +80,18 @@ jobs:
7580
env:
7681
GIT_USER: ${{ github.actor }}
7782

83+
# Avoid running into space issues for github runners - Docker images can take up quite some space
84+
- name: Free Disk Space
85+
run: |
86+
echo "Disk space before cleanup:"
87+
df -h
88+
sudo rm -rf /usr/share/dotnet
89+
sudo rm -rf /opt/ghc
90+
sudo rm -rf /usr/local/share/boost
91+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
92+
echo "Disk space after cleanup:"
93+
df -h
94+
7895
# Make sure the branch has the latest master changes in
7996
- name: Merge master into current branch
8097
if: ${{ inputs.mergeMaster }}
@@ -87,15 +104,15 @@ jobs:
87104
# Unity 2020 cache is not compatible with older versions
88105
- name: Unity Library Cache 2020 or higher
89106
if: ${{ !startsWith(inputs.unityVersion, '201') }}
90-
uses: actions/cache@v3
107+
uses: actions/cache@v4
91108
with:
92109
path: Library
93110
key: Library-202x-WebGL
94111
restore-keys: Library-202x-
95112

96113
- name: Unity Library Cache 2019 or lower
97114
if: ${{ startsWith(inputs.unityVersion, '201') }}
98-
uses: actions/cache@v3
115+
uses: actions/cache@v4
99116
with:
100117
path: Library
101118
key: Library-201x-WebGL
@@ -106,6 +123,13 @@ jobs:
106123
run: |
107124
LAST_UNITY_VERSION=$(sed -n 's/^\m_EditorVersion: //p'< ./ProjectSettings/ProjectVersion.txt)
108125
echo "VERSION=$LAST_UNITY_VERSION" >> $GITHUB_OUTPUT
126+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
127+
if [[ "$BRANCH_NAME" == *"urp"* ]]
128+
then
129+
echo "NAME=$LAST_UNITY_VERSION-urp" >> $GITHUB_OUTPUT
130+
else
131+
echo "NAME=$LAST_UNITY_VERSION" >> $GITHUB_OUTPUT
132+
fi
109133
110134
- name: Set upgrade name
111135
id: upgrade_name
@@ -123,6 +147,7 @@ jobs:
123147
- name: Log variables
124148
run: |
125149
echo "last_unity_version -> ${{ steps.last_unity_version.outputs.VERSION }}"
150+
echo "last_unity_name -> ${{ steps.last_unity_version.outputs.NAME }}"
126151
echo "upgrade_name -> ${{ steps.upgrade_name.outputs.NAME }}"
127152
128153
- name: Build project
@@ -137,18 +162,30 @@ jobs:
137162
customParameters: ${{ inputs.customParameters }}
138163
unityVersion: ${{ inputs.unityVersion }}
139164
targetPlatform: WebGL
140-
buildName: ${{ needs.variables.outputs.BUILD_NAME }}
165+
buildName: ${{ steps.upgrade_name.outputs.NAME }}
141166
allowDirtyBuild: true
142167
manualExit: true
143168

169+
- name: Check Disk Space After Build
170+
if: ${{ !inputs.tagsOnly }}
171+
run: |
172+
echo "Disk space after build:"
173+
df -h
174+
AVAILABLE=$(df / | tail -1 | awk '{print $4}')
175+
AVAILABLE_GB=$(echo $AVAILABLE | sed 's/G//')
176+
echo "Available space: ${AVAILABLE_GB}GB"
177+
if (( $(echo "$AVAILABLE_GB < 1" | bc -l) )); then
178+
echo "::warning::Low disk space! Less than 1GB remaining."
179+
fi
180+
144181
- name: Delete build folder with elevated rights
145182
if: ${{ !inputs.tagsOnly }}
146183
run: sudo rm -rf ./build
147184

148185
- name: Render template
149186
if: ${{ !inputs.tagsOnly }}
150187
id: template
151-
uses: chuhlomin/render-template@v1.4
188+
uses: chuhlomin/render-template@v1.9
152189
with:
153190
template: .github/templates/upgrade-unity-pr-body.md
154191
vars: |
@@ -159,39 +196,34 @@ jobs:
159196
uses: peter-evans/create-pull-request@v4
160197
with:
161198
token: ${{ secrets.PR_GITHUB_TOKEN }}
162-
commit-message: "[Automated workflow] upgrade-unity from ${{steps.last_unity_version.outputs.VERSION}} to ${{ inputs.unityVersion }}"
163-
branch: "ci/upgrade-unity/from-${{steps.last_unity_version.outputs.VERSION}}-to-${{ steps.upgrade_name.outputs.NAME }}"
199+
commit-message: "[Automated workflow] upgrade-unity from ${{steps.last_unity_version.outputs.NAME}} to ${{ inputs.unityVersion }}"
200+
branch: "ci/upgrade-unity/from-${{steps.last_unity_version.outputs.NAME}}-to-${{ steps.upgrade_name.outputs.NAME }}"
164201
delete-branch: true
165-
title: "[Automated workflow] upgrade-unity from ${{steps.last_unity_version.outputs.VERSION}} to ${{ steps.upgrade_name.outputs.NAME }}"
202+
title: "[Automated workflow] upgrade-unity from ${{steps.last_unity_version.outputs.NAME}} to ${{ steps.upgrade_name.outputs.NAME }}"
166203
body: ${{ steps.template.outputs.result }}
167204

205+
- name: Wait before pushing tags
206+
if: ${{ (inputs.createTags || inputs.tagsOnly) && inputs.delayTags > 0 }}
207+
run: |
208+
DELAY_SECONDS=$((DELAY_TAGS * 60))
209+
echo "Waiting for $DELAY_TAGS minutes ($DELAY_SECONDS seconds) before pushing tags..."
210+
sleep $DELAY_SECONDS
211+
echo "Wait complete. Proceeding with tag push."
212+
env:
213+
DELAY_TAGS: ${{ inputs.delayTags }}
214+
168215
- name: Add tags
169216
if: ${{ inputs.createTags || inputs.tagsOnly }}
170217
run: |
171-
# Extract the first four characters of UNITY_VERSION
172-
UNITY_YEAR=${UNITY_VERSION:0:4}
173218
BRANCH_NAME=${GITHUB_REF#refs/heads/}
174219
175-
TAG_PREFIX=$UNITY_VERSION
176-
if [[ "$BRANCH_NAME" == *"urp"* ]]
177-
then
178-
TAG_PREFIX=$UNITY_VERSION-urp
220+
IS_URP=false
221+
if [[ "$BRANCH_NAME" == *"urp"* ]]; then
222+
IS_URP=true
179223
fi
180224
181-
if [[ "$UNITY_YEAR" < "2023" ]]
182-
then
183-
git tag -a -f $TAG_PREFIX-minsize-webgl1 -m "[Automated workflow] Created by upgrade-unity"
184-
git tag -a -f $TAG_PREFIX-webgl1 -m "[Automated workflow] Created by upgrade-unity"
185-
else
186-
git tag -a -f $TAG_PREFIX-minsize-webgl2 -m "[Automated workflow] Created by upgrade-unity"
187-
fi
188-
# Push tags in between - pushing more than 3 tags won't trigger tag workflows
189-
git push origin -f --tags
190-
191-
git tag -a -f $TAG_PREFIX-webgl2 -m "[Automated workflow] Created by upgrade-unity"
192-
git tag -a -f $TAG_PREFIX-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
193-
194-
git push origin -f --tags
225+
# Run add tags script
226+
./.github/scripts/add-tags.sh "$UNITY_VERSION" "$IS_URP"
195227
env:
196228
UNITY_VERSION: ${{ inputs.unityVersion }}
197229

0 commit comments

Comments
 (0)