diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c8437ff3..44305dd3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,9 +93,11 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - # Post-publish smoke test: install the just-published package from the registry - # (clean dir) and confirm it resolves to the expected version. Catches - # "published but unusable" (bad files/exports), wrong dist-tag, or wrong access. + # Post-publish smoke test: install the just-published package from the registry (clean dir) + # and confirm it resolves to the expected version. Catches "published but unusable" + # (bad files/exports/version). The publish already succeeded and npm is immutable, so a + # persistent miss here is a WARNING (registry propagation lag — common on a first publish), + # NOT a release failure. A version MISMATCH after install still hard-fails. - name: Smoke-test published package run: | VERSION="${{ steps.meta.outputs.version }}" @@ -103,17 +105,18 @@ jobs: workdir="$(mktemp -d)" cd "$workdir" npm init -y >/dev/null - # Registry propagation can lag a few seconds after publish; retry. - for attempt in 1 2 3 4 5 6; do - if npm install "${PROJECT_NAME}@${VERSION}"; then - installed=true - break - fi - echo "install attempt ${attempt} failed; waiting 10s for registry propagation..." - sleep 10 + # First publishes propagate slowly; --prefer-online bypasses the negative cache. Back off ~2min. + installed=false + for attempt in 1 2 3 4 5 6 7 8; do + if npm install --prefer-online "${PROJECT_NAME}@${VERSION}"; then installed=true; break; fi + echo "install attempt ${attempt} failed; waiting 15s for registry propagation..." + sleep 15 done - [ "${installed:-false}" = true ] || { echo "::error::Could not install ${PROJECT_NAME}@${VERSION} from the registry."; exit 1; } - node -e "const p = require('${PROJECT_NAME}/package.json'); if (p.version !== '${VERSION}') { throw new Error('installed ' + p.version + ', expected ${VERSION}'); } console.log('smoke ok:', p.name, p.version);" - echo "::notice::Smoke test passed: ${PROJECT_NAME}@${VERSION} installs and resolves (dist-tag ${DIST_TAG})." + if [ "$installed" = true ]; then + node -e "const p = require('${PROJECT_NAME}/package.json'); if (p.version !== '${VERSION}') { throw new Error('installed ' + p.version + ', expected ${VERSION}'); } console.log('smoke ok:', p.name, p.version);" + echo "::notice::Smoke test passed: ${PROJECT_NAME}@${VERSION} installs and resolves (dist-tag ${DIST_TAG})." + else + echo "::warning::${PROJECT_NAME}@${VERSION} published successfully but did not resolve from the registry within the wait window (propagation lag — common on a first publish). Verify manually: npm view ${PROJECT_NAME}@${VERSION} --prefer-online" + fi env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}