@@ -407,11 +407,17 @@ jobs:
407
407
shell : bash
408
408
working-directory : artifacts
409
409
run : |
410
- # Check if artifact already exists in Maven Central
410
+ # Check if artifact already exists or is being published
411
411
if curl -f -s -o /dev/null "https://repo1.maven.org/maven2/io/stepfunc/dnp3/${{github.ref_name}}/dnp3-${{github.ref_name}}.jar"; then
412
- echo "Artifact io.stepfunc:dnp3:${{github.ref_name}} already exists in Maven Central - skipping deployment"
412
+ echo "✅ Artifact io.stepfunc:dnp3:${{github.ref_name}} already exists in Maven Central - skipping deployment"
413
413
else
414
- echo "Artifact not found in Maven Central - proceeding with deployment"
414
+ echo "Artifact not found in Maven Central - checking if deployment is in progress..."
415
+
416
+ # Create base64 encoded token for Authorization header
417
+ AUTH_TOKEN=$(echo -n "${{ secrets.MAVEN_CENTRAL_USERNAME }}:${{ secrets.MAVEN_CENTRAL_TOKEN }}" | base64 -w 0)
418
+
419
+ # Try to upload - if it fails due to duplicate, that means it's already being processed
420
+ echo "Attempting to upload to Central Portal..."
415
421
416
422
# Create Maven repository structure (starting from groupId)
417
423
mkdir -p io/stepfunc/dnp3/${{github.ref_name}}
@@ -438,9 +444,6 @@ jobs:
438
444
cd ../../../..
439
445
zip -r bundle.zip io/
440
446
441
- # Create base64 encoded token for Authorization header
442
- AUTH_TOKEN=$(echo -n "${{ secrets.MAVEN_CENTRAL_USERNAME }}:${{ secrets.MAVEN_CENTRAL_TOKEN }}" | base64 -w 0)
443
-
444
447
# Upload bundle to Central Portal
445
448
echo "Uploading bundle to Central Portal..."
446
449
RESPONSE=$(curl -X POST \
@@ -449,8 +452,8 @@ jobs:
449
452
-H "Content-Type: multipart/form-data" \
450
453
-F "[email protected] ;type=application/octet-stream" \
451
454
-F "publishingType=AUTOMATIC" \
452
- --fail-with-body \
453
- -w "\nHTTP_STATUS:%{http_code}" )
455
+ -w "\nHTTP_STATUS:%{http_code}" \
456
+ -s )
454
457
455
458
# Extract HTTP status code
456
459
HTTP_STATUS=$(echo "$RESPONSE" | grep "HTTP_STATUS:" | cut -d: -f2)
@@ -459,13 +462,17 @@ jobs:
459
462
echo "Response: $BODY"
460
463
echo "HTTP Status: $HTTP_STATUS"
461
464
462
- # Extract deployment ID if successful
465
+ # Handle response
463
466
if [[ $HTTP_STATUS -ge 200 && $HTTP_STATUS -lt 300 ]]; then
464
- DEPLOYMENT_ID=$(echo "$BODY" | grep -o '"deploymentId"[[:space:]]*:[[:space:]]*"[^"]*"' | cut -d'"' -f4)
467
+ # The API returns the deployment ID as plain text, not JSON
468
+ DEPLOYMENT_ID=$(echo "$BODY" | tr -d '[:space:]')
465
469
echo "✅ Upload successful! Deployment ID: $DEPLOYMENT_ID"
466
470
echo "The deployment will be automatically published to Maven Central after validation."
471
+ elif [[ $HTTP_STATUS -eq 400 ]] && [[ "$BODY" =~ "duplicate" || "$BODY" =~ "already exists" || "$BODY" =~ "PUBLISHED" ]]; then
472
+ echo "✅ Version ${{github.ref_name}} is already uploaded or being processed - skipping deployment"
467
473
else
468
474
echo "❌ Upload failed with status $HTTP_STATUS"
475
+ echo "Error details: $BODY"
469
476
exit 1
470
477
fi
471
478
fi
0 commit comments