Skip to content

Commit 0cf2bed

Browse files
committed
Add a delay between tag pushes
1 parent 595c22a commit 0cf2bed

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

.github/scripts/add-tags.sh

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
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
89
UNITY_VERSION=$1
910
IS_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
1316
MAJOR_VERSION=$(echo $UNITY_VERSION | cut -d. -f1)
@@ -19,22 +22,42 @@ then
1922
TAG_PREFIX=$UNITY_VERSION-urp
2023
fi
2124

25+
# Build array of tags to create and push
26+
TAGS=()
27+
2228
if [[ "$MAJOR_VERSION" -lt "2023" ]]
2329
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"
30+
TAGS+=("$TAG_PREFIX-minsize-webgl1")
31+
TAGS+=("$TAG_PREFIX-webgl1")
2632
else
27-
git tag -a -f $TAG_PREFIX-minsize-webgl2 -m "[Automated workflow] Created by upgrade-unity"
33+
TAGS+=("$TAG_PREFIX-minsize-webgl2")
2834
fi
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

3539
if [[ "$MAJOR_VERSION" -ge "6000" ]]
3640
then
37-
git tag -a -f $TAG_PREFIX-webgpu -m "[Automated workflow] Created by upgrade-unity"
41+
TAGS+=("$TAG_PREFIX-webgpu")
3842
fi
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."

.github/workflows/upgrade-unity.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ on:
3030
type: string
3131
default: '-accept-apiupdate'
3232
delayTags:
33-
description: 'Delay before force pushing tags (in minutes)'
33+
description: 'Delay between tag pushes (in seconds, minimum 1)'
3434
required: false
3535
type: number
36-
default: 0
36+
default: 1
3737

3838
jobs:
3939
upgrade-unity-version:
@@ -50,7 +50,7 @@ jobs:
5050
echo "Only create tags: $TAGS_ONLY"
5151
echo "Merge master into branch: $MERGE_MASTER"
5252
echo "Custom cli arguments: $CUSTOM_PARAMETERS"
53-
echo "Delay tags: $DELAY_TAGS minutes"
53+
echo "Delay tags: $DELAY_TAGS seconds"
5454
if [[ "$BRANCH_NAME" == *"urp"* ]]
5555
then
5656
echo "urp: true"
@@ -202,16 +202,6 @@ jobs:
202202
title: "[Automated workflow] upgrade-unity from ${{steps.last_unity_version.outputs.NAME}} to ${{ steps.upgrade_name.outputs.NAME }}"
203203
body: ${{ steps.template.outputs.result }}
204204

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-
215205
- name: Add tags
216206
if: ${{ inputs.createTags || inputs.tagsOnly }}
217207
run: |
@@ -222,8 +212,9 @@ jobs:
222212
IS_URP=true
223213
fi
224214
225-
# Run add tags script
226-
./.github/scripts/add-tags.sh "$UNITY_VERSION" "$IS_URP"
215+
# Run add tags script with delay parameter
216+
./.github/scripts/add-tags.sh "$UNITY_VERSION" "$IS_URP" "$DELAY_TAGS"
227217
env:
228218
UNITY_VERSION: ${{ inputs.unityVersion }}
219+
DELAY_TAGS: ${{ inputs.delayTags }}
229220

0 commit comments

Comments
 (0)