Skip to content

Commit 7c4f1cf

Browse files
committed
fix: workflow
1 parent 900e410 commit 7c4f1cf

File tree

1 file changed

+52
-28
lines changed

1 file changed

+52
-28
lines changed

.github/workflows/release-dev.yml

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,31 @@ jobs:
9191
SIMPLECLOUD_PASSWORD: ${{ secrets.SIMPLECLOUD_PASSWORD }}
9292

9393
- name: Publish to Modrinth (with retries)
94-
uses: nick-fields/retry-action@v3
95-
with:
96-
timeout_minutes: 10
97-
max_attempts: 3
98-
retry_wait_seconds: 30
99-
command: |
100-
./gradlew modrinth \
94+
run: |
95+
MAX_ATTEMPTS=3
96+
ATTEMPT=1
97+
98+
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
99+
echo "Attempt $ATTEMPT of $MAX_ATTEMPTS..."
100+
101+
if ./gradlew modrinth \
101102
--parallel \
102103
--build-cache \
103104
--no-configuration-cache \
104105
-Dorg.gradle.internal.http.socketTimeout=180000 \
105-
-Dorg.gradle.internal.http.connectionTimeout=180000
106+
-Dorg.gradle.internal.http.connectionTimeout=180000; then
107+
echo "✓ Modrinth upload successful"
108+
break
109+
else
110+
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
111+
echo "✗ Modrinth upload failed after $MAX_ATTEMPTS attempts"
112+
exit 1
113+
fi
114+
echo "⚠ Attempt $ATTEMPT failed, retrying in 30 seconds..."
115+
sleep 30
116+
ATTEMPT=$((ATTEMPT + 1))
117+
fi
118+
done
106119
env:
107120
COMMIT_HASH: ${{ steps.versions.outputs.commit_hash }}
108121
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
@@ -168,29 +181,40 @@ jobs:
168181
local URL="${REGISTRY_URL}/v1/applications/${APP_ID}/releases/${{ needs.build-and-publish.outputs.gradle_version }}/files"
169182
170183
echo "Uploading $ARCH..."
171-
response=$(curl -s -w "\n%{http_code}" -X POST \
172-
--max-time 300 \
173-
--retry 3 \
174-
--retry-delay 5 \
175-
-H "Authorization: Bearer ${{ secrets.REGISTRY_TOKEN }}" \
176-
-H "Content-Type: multipart/form-data" \
177-
-F "file=@$FILE" \
178-
-F "platform=minecraft_plugin" \
179-
-F "arch=$ARCH" \
180-
-F "platform_versions=$PLATFORM_VERSIONS" \
181-
"$URL")
182184
183-
http_code=$(echo "$response" | tail -n1)
184-
body=$(echo "$response" | sed '$d')
185+
# Retry logic for each upload
186+
MAX_ATTEMPTS=3
187+
ATTEMPT=1
185188
186-
if [ "$http_code" -ge 400 ]; then
187-
echo "Error uploading $ARCH: HTTP $http_code"
188-
echo "$body"
189-
return 1
190-
fi
189+
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
190+
response=$(curl -s -w "\n%{http_code}" -X POST \
191+
--max-time 300 \
192+
-H "Authorization: Bearer ${{ secrets.REGISTRY_TOKEN }}" \
193+
-H "Content-Type: multipart/form-data" \
194+
-F "file=@$FILE" \
195+
-F "platform=minecraft_plugin" \
196+
-F "arch=$ARCH" \
197+
-F "platform_versions=$PLATFORM_VERSIONS" \
198+
"$URL")
199+
200+
http_code=$(echo "$response" | tail -n1)
201+
body=$(echo "$response" | sed '$d')
202+
203+
if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then
204+
echo "✓ $ARCH uploaded successfully"
205+
return 0
206+
fi
207+
208+
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
209+
echo "✗ Error uploading $ARCH after $MAX_ATTEMPTS attempts: HTTP $http_code"
210+
echo "$body"
211+
return 1
212+
fi
191213
192-
echo "✓ $ARCH uploaded successfully"
193-
return 0
214+
echo "⚠ Attempt $ATTEMPT failed for $ARCH (HTTP $http_code), retrying in 5 seconds..."
215+
sleep 5
216+
ATTEMPT=$((ATTEMPT + 1))
217+
done
194218
}
195219
196220
# Upload all platforms in parallel

0 commit comments

Comments
 (0)