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
3338jobs :
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 : |
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"
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 :
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