33# example usage
44# sh add-tags.sh "6000.0.0f1" -> Creates tags for non-urp version
55# sh add-tags.sh "6000.0.0f1" "true" -> Creates tags for urp version
6+ # sh add-tags.sh "6000.0.0f1" "true" "10" -> Creates tags for urp version with 10 second delay between pushes
67
78# Input parameters
89UNITY_VERSION=$1
910IS_URP=${2:- " false" }
10- echo " Running add_tags.sh with UNITY_VERSION: $UNITY_VERSION , IS_URP: $IS_URP "
11+ DELAY_TAGS=${3:- " 0" }
12+
13+ echo " Running add_tags.sh with UNITY_VERSION: $UNITY_VERSION , IS_URP: $IS_URP , DELAY_TAGS: $DELAY_TAGS seconds"
1114
1215# Extract the value before the first dot as an integer
1316MAJOR_VERSION=$( echo $UNITY_VERSION | cut -d. -f1)
1922TAG_PREFIX=$UNITY_VERSION -urp
2023fi
2124
25+ # Build array of tags to create and push
26+ TAGS=()
27+
2228if [[ " $MAJOR_VERSION " -lt " 2023" ]]
2329then
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 "
30+ TAGS+=( " $TAG_PREFIX -minsize-webgl1" )
31+ TAGS+=( " $TAG_PREFIX -webgl1" )
2632else
27- git tag -a -f $TAG_PREFIX -minsize-webgl2 -m " [Automated workflow] Created by upgrade-unity "
33+ TAGS+=( " $TAG_PREFIX -minsize-webgl2" )
2834fi
29- # Push tags in between - pushing more than 3 tags won't trigger tag workflows
30- git push origin -f --tags
3135
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 "
36+ TAGS+=( " $TAG_PREFIX -webgl2" )
37+ TAGS+=( " $TAG_PREFIX -webgl2-debug" )
3438
3539if [[ " $MAJOR_VERSION " -ge " 6000" ]]
3640then
37- git tag -a -f $TAG_PREFIX -webgpu -m " [Automated workflow] Created by upgrade-unity "
41+ TAGS+=( " $TAG_PREFIX -webgpu" )
3842fi
3943
40- git push origin -f --tags
44+ # Loop through tags, create and push each one with delay
45+ for i in " ${! TAGS[@]} " ; do
46+ TAG=" ${TAGS[$i]} "
47+ echo " Creating and pushing tag: $TAG "
48+
49+ # Create the tag
50+ git tag -a -f " $TAG " -m " [Automated workflow] Created by upgrade-unity"
51+
52+ # Push the tag
53+ git push origin -f " $TAG "
54+
55+ # Wait between pushes if not the last tag and delay is specified
56+ if [[ $i -lt $(( ${# TAGS[@]} - 1 )) ]] && [[ " $DELAY_TAGS " -gt " 0" ]]
57+ then
58+ echo " Waiting $DELAY_TAGS seconds before next tag push..."
59+ sleep $DELAY_TAGS
60+ fi
61+ done
62+
63+ echo " All tags created and pushed successfully."
0 commit comments