1+ # Manually upgrade unity and update packages
2+ # Check if the Unity version already exists as a docker image: https://game.ci/docs/docker/versions
13name : Upgrade Unity version
24
35on :
79 description : ' Unity Version'
810 required : true
911 type : string
12+ createTags :
13+ description : ' Create Tags'
14+ required : false
15+ type : boolean
16+ default : true
17+ urp :
18+ description : ' URP branch'
19+ required : true
20+ type : boolean
21+ default : false
22+ tagsOnly :
23+ description : ' Only create tags'
24+ required : true
25+ type : boolean
26+ default : false
1027 customParameters :
1128 description : ' Custom cli arguments'
1229 required : false
1330 type : string
14- default : ' -accept-apiupdate ‑ignorecompilererrors '
31+ default : ' -accept-apiupdate'
1532
1633jobs :
1734 upgrade-unity-version :
@@ -20,23 +37,69 @@ jobs:
2037 strategy :
2138 fail-fast : false
2239 steps :
23- - run : |
40+ - name : Log input parameter
41+ run : |
2442 echo "Upgrading to Unity Version: $UNITY_VERSION"
43+ echo "Create tags: $CREATE_TAGS"
44+ echo "URP branch: $URP_BRANCH"
45+ echo "Custom cli arguments: $CUSTOM_PARAMETERS"
2546 env :
2647 UNITY_VERSION : ${{ inputs.unityVersion }}
48+ CREATE_TAGS : ${{ inputs.createTags }}
49+ URP_BRANCH : ${{ inputs.urp }}
50+ TAGS_ONLY : ${{ inputs.tagsOnly }}
51+ CUSTOM_PARAMETERS : ${{ inputs.customParameters }}
2752
2853 - uses : actions/checkout@v3
2954 with :
3055 fetch-depth : 0
3156 lfs : true
57+ # Makes sure, that pushing new tags will trigger workflows
58+ token : ${{ secrets.PR_GITHUB_TOKEN }}
59+
60+ # Unity 2020 cache is not compatible with older versions
61+ - name : Unity Library Cache 2020 or higher
62+ if : ${{ !startsWith(inputs.unityVersion, '201') }}
63+ uses : actions/cache@v3
64+ with :
65+ path : Library
66+ key : Library-202x-WebGL
67+ restore-keys : Library-202x-
3268
33- - uses : actions/cache@v3
69+ - name : Unity Library Cache 2019 or lower
70+ if : ${{ startsWith(inputs.unityVersion, '201') }}
71+ uses : actions/cache@v3
3472 with :
3573 path : Library
36- key : Library-WebGL
37- restore-keys : Library-
74+ key : Library-201x-WebGL
75+ restore-keys : Library-201x-
76+
77+ - name : Set last unity version
78+ id : last_unity_version
79+ run : |
80+ LAST_UNITY_VERSION=$(sed -n 's/^\m_EditorVersion: //p'< ./ProjectSettings/ProjectVersion.txt)
81+ echo "VERSION=$LAST_UNITY_VERSION" >> $GITHUB_OUTPUT
82+
83+ - name : Set upgrade name
84+ id : upgrade_name
85+ run : |
86+ if [[ "$URP_BRANCH" == "true" ]]
87+ then
88+ echo "NAME=$UNITY_VERSION-urp" >> $GITHUB_OUTPUT
89+ else
90+ echo "NAME=$UNITY_VERSION" >> $GITHUB_OUTPUT
91+ fi
92+ env :
93+ UNITY_VERSION : ${{ inputs.unityVersion }}
94+ URP_BRANCH : ${{ inputs.urp }}
95+
96+ - name : Log variables
97+ run : |
98+ echo "last_unity_version -> ${{ steps.last_unity_version.outputs.VERSION }}"
99+ echo "upgrade_name -> ${{ steps.upgrade_name.outputs.NAME }}"
38100
39101 - name : Build project
102+ if : ${{ !inputs.tagsOnly }}
40103 uses : JohannesDeml/unity-builder@no-quit-parameter
41104 env :
42105 UNITY_LICENSE : ${{ secrets.UNITY_LICENSE }}
@@ -49,16 +112,56 @@ jobs:
49112 allowDirtyBuild : true
50113
51114 - name : Delete build folder with elevated rights
115+ if : ${{ !inputs.tagsOnly }}
52116 run : sudo rm -rf ./build
53117
54- - name : Log git status
55- run : git status
118+ - name : Set git user
119+ run : |
120+ git status
121+ git config --global user.email "$GIT_USER@users.noreply.github.com"
122+ git config --global user.name "$GIT_USER"
123+ env :
124+ GIT_USER : ${{ github.actor }}
125+
126+ - name : Render template
127+ if : ${{ !inputs.tagsOnly }}
128+ id : template
129+ uses : chuhlomin/render-template@v1.4
130+ with :
131+ template : .github/templates/upgrade-unity-pr-body.md
132+ vars : |
133+ unityversion: ${{ steps.upgrade_name.outputs.NAME }}
56134
57135 - name : Create Pull Request
136+ if : ${{ !inputs.tagsOnly }}
58137 uses : peter-evans/create-pull-request@v4
59138 with :
60139 token : ${{ secrets.PR_GITHUB_TOKEN }}
61- commit-message : " [Automated workflow] upgrade-unity to ${{ inputs.unityVersion }}"
62- branch : " ci/upgrade-unity/${{ inputs.unityVersion }}"
140+ commit-message : " [Automated workflow] upgrade-unity from ${{steps.last_unity_version.outputs.VERSION}} to ${{ inputs.unityVersion }}"
141+ branch : " ci/upgrade-unity/from- ${{steps.last_unity_version.outputs.VERSION}}-to-${{ steps.upgrade_name.outputs.NAME }}"
63142 delete-branch : true
64- title : " [Automated Pull Request] upgrade-unity to ${{ inputs.unityVersion }}"
143+ title : " [Automated workflow] upgrade-unity from ${{steps.last_unity_version.outputs.VERSION}} to ${{ steps.upgrade_name.outputs.NAME }}"
144+ body : ${{ steps.template.outputs.result }}
145+
146+ - name : Add tags
147+ if : ${{ inputs.createTags || inputs.tagsOnly }}
148+ run : |
149+ if [[ "$URP_BRANCH" == "true" ]]
150+ then
151+ git tag -a -f $UNITY_VERSION-urp-webgl1 -m "[Automated workflow] Created by upgrade-unity"
152+ git tag -a -f $UNITY_VERSION-urp-webgl2 -m "[Automated workflow] Created by upgrade-unity"
153+ git tag -a -f $UNITY_VERSION-urp-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
154+ else
155+ git tag -a -f $UNITY_VERSION-minsize-webgl1 -m "[Automated workflow] Created by upgrade-unity"
156+ git tag -a -f $UNITY_VERSION-webgl1 -m "[Automated workflow] Created by upgrade-unity"
157+ git tag -a -f $UNITY_VERSION-webgl2 -m "[Automated workflow] Created by upgrade-unity"
158+ # Push tags in between - pushing more than 3 tags won't trigger tag workflows
159+ git push origin -f --tags
160+ git tag -a -f $UNITY_VERSION-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
161+ fi
162+
163+ git push origin -f --tags
164+ env :
165+ UNITY_VERSION : ${{ inputs.unityVersion }}
166+ URP_BRANCH : ${{ inputs.urp }}
167+
0 commit comments