File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,29 @@ set -euo pipefail
33
44TAG=" ${NPM_TAG:- next} "
55
6+ pkg_name=" $( node -p " require('./package.json').name" ) "
7+ pkg_version=" $( node -p " require('./package.json').version" ) "
8+
9+ # Skip publishing if this exact version already exists on npm.
10+ # This keeps CI logs clean and avoids attempting to publish unchanged packages.
11+ view_log_file=" $( mktemp) "
12+ set +e
13+ npm view " ${pkg_name} @${pkg_version} " version --registry " https://registry.npmjs.org" 2>&1 | tee " $view_log_file " > /dev/null
14+ view_status=${PIPESTATUS[0]}
15+ set -e
16+
17+ if [ " $view_status " -eq 0 ]; then
18+ echo " Skip publish: ${pkg_name} @${pkg_version} already exists on npm."
19+ exit 0
20+ fi
21+
22+ # If npm view failed because the package/version doesn't exist, continue to publish.
23+ if ! grep -qiE ' (E404|404 Not Found|code E404|is not in this registry)' " $view_log_file " ; then
24+ echo " npm view failed unexpectedly for ${pkg_name} @${pkg_version} ; refusing to publish."
25+ cat " $view_log_file " >&2
26+ exit " $view_status "
27+ fi
28+
629args=(
730 --tag " $TAG "
831 --access public
Original file line number Diff line number Diff line change 3737 run : |
3838 echo "Publishing templates to npm with tag $NPM_TAG via OIDC trusted publishing..."
3939 unset NODE_AUTH_TOKEN
40+ # Ensure we don't have token-based npm auth config lingering from setup-node
41+ rm -f ~/.npmrc
4042 if [ -n "${NPM_CONFIG_USERCONFIG:-}" ]; then
4143 rm -f "$NPM_CONFIG_USERCONFIG"
4244 unset NPM_CONFIG_USERCONFIG
You can’t perform that action at this time.
0 commit comments