diff --git a/.github/actions/npm-check-bundle/action.yml b/.github/actions/npm-check-bundle/action.yml index e3ab80bdcb..546e7b2565 100644 --- a/.github/actions/npm-check-bundle/action.yml +++ b/.github/actions/npm-check-bundle/action.yml @@ -26,6 +26,22 @@ runs: echo "TAG_NPM not set, aborting" exit 1 fi - ADF_VERSION=$(npm view @alfresco/adf-core@${TAG_NPM} version) + + # Retry to absorb npm registry propagation delay right after publish. + NPM_VIEW_RETRIES=6 + NPM_VIEW_RETRY_DELAY=10 + for attempt in $(seq 1 "$NPM_VIEW_RETRIES"); do + ADF_VERSION=$(npm view @alfresco/adf-core@${TAG_NPM} version 2>/dev/null) + if [[ -n $ADF_VERSION ]]; then + break + fi + sleep "$NPM_VIEW_RETRY_DELAY" + done + + if [[ -z $ADF_VERSION ]]; then + echo "Could not resolve @alfresco/adf-core@${TAG_NPM} version, aborting" >&2 + exit 1 + fi + echo "check bundle on TAG_NPM='${TAG_NPM}' and ADF_VERSION='${ADF_VERSION}'" ./scripts/github/build/npm-check-bundles.sh -v ${ADF_VERSION} diff --git a/scripts/github/build/npm-check-bundles.sh b/scripts/github/build/npm-check-bundles.sh index e2c39e9ce9..b822968dcf 100755 --- a/scripts/github/build/npm-check-bundles.sh +++ b/scripts/github/build/npm-check-bundles.sh @@ -34,6 +34,26 @@ error_out() { # bg: 40 black, 41 red, 44 blue, 45 purple } +# Retry to absorb npm registry propagation delay right after publish. +NPM_VIEW_RETRIES=6 +NPM_VIEW_RETRY_DELAY=10 + +npm_view_version() { + local spec=$1 + local attempt result + for attempt in $(seq 1 "$NPM_VIEW_RETRIES"); do + result=$(npm view "$spec" version 2>/dev/null) + if [ -n "$result" ]; then + echo "$result" + return 0 + fi + if [ "$attempt" -lt "$NPM_VIEW_RETRIES" ]; then + sleep "$NPM_VIEW_RETRY_DELAY" + fi + done + return 1 +} + rm -rf temp mkdir temp cd temp @@ -65,13 +85,13 @@ do fi # Try the calculated package version first - PKG_VERSION=$(npm view @alfresco/$PACKAGE@$PACKAGE_VERSION version 2>/dev/null) + PKG_VERSION=$(npm_view_version @alfresco/$PACKAGE@$PACKAGE_VERSION) # If that fails for js-api, try the original version if [ -z "$PKG_VERSION" ] && [ $PACKAGE == 'js-api' ]; then echo "Warning: js-api@$PACKAGE_VERSION not found, trying @$VERSION" PACKAGE_VERSION=$VERSION - PKG_VERSION=$(npm view @alfresco/$PACKAGE@$PACKAGE_VERSION version 2>/dev/null) + PKG_VERSION=$(npm_view_version @alfresco/$PACKAGE@$PACKAGE_VERSION) fi # If still no version found, exit with error