@@ -426,11 +426,32 @@ jobs:
426426 # Promote package version to released status if it's a latest release
427427 if [ "${{ steps.version.outputs.release_type }}" == "latest" ]; then
428428 echo "🚀 Promoting package version to released status..."
429+ echo "🔍 Debug: Package version ID: $PACKAGE_VERSION_ID"
430+ echo "🔍 Debug: Target dev hub: pkgorg"
431+
432+ # Check if package version is ready for promotion
433+ echo "🔍 Checking package version status..."
434+ VERSION_STATUS=$(echo "$PACKAGE_VERSION_OUTPUT" | jq -r '.result.Status // "Unknown"')
435+ CODE_COVERAGE_PASSED=$(echo "$PACKAGE_VERSION_OUTPUT" | jq -r '.result.HasPassedCodeCoverageCheck // false')
436+
437+ echo "Package version status: $VERSION_STATUS"
438+ echo "Code coverage passed: $CODE_COVERAGE_PASSED"
439+
440+ if [ "$CODE_COVERAGE_PASSED" = "false" ]; then
441+ echo "⚠️ WARNING: Code coverage check has not passed yet"
442+ echo "Package version may not be ready for promotion"
443+ echo "Waiting 30 seconds for code coverage to complete..."
444+ sleep 30
445+ fi
446+
447+ # Run promotion with better error handling
448+ set +e # Don't exit on error, we'll handle it manually
429449 PROMOTE_OUTPUT=$(sf package version promote \
430450 --package "$PACKAGE_VERSION_ID" \
431451 --target-dev-hub pkgorg \
432452 --json 2>&1)
433453 PROMOTE_EXIT_CODE=$?
454+ set -e # Re-enable exit on error
434455
435456 echo "Package version promote exit code: $PROMOTE_EXIT_CODE"
436457 echo "Package version promote output:"
@@ -440,7 +461,24 @@ jobs:
440461 echo "✅ Successfully promoted package version to released status"
441462 else
442463 echo "⚠️ WARNING: Failed to promote package version to released status"
464+ echo "Exit code: $PROMOTE_EXIT_CODE"
465+ echo "Error details:"
466+ echo "$PROMOTE_OUTPUT"
467+
468+ # Try to extract specific error information
469+ if echo "$PROMOTE_OUTPUT" | jq -e '.message' > /dev/null 2>&1; then
470+ ERROR_MSG=$(echo "$PROMOTE_OUTPUT" | jq -r '.message')
471+ echo "Error message: $ERROR_MSG"
472+ fi
473+
474+ if echo "$PROMOTE_OUTPUT" | jq -e '.result[0].error' > /dev/null 2>&1; then
475+ ERROR_DETAILS=$(echo "$PROMOTE_OUTPUT" | jq -r '.result[0].error')
476+ echo "Error details: $ERROR_DETAILS"
477+ fi
478+
443479 echo "Package will remain as prerelease version"
480+ echo "You can manually promote it later using:"
481+ echo "sf package version promote --package $PACKAGE_VERSION_ID --target-dev-hub pkgorg"
444482 fi
445483 else
446484 echo "ℹ️ Package version remains as prerelease (release_type is prerelease)"
0 commit comments