Skip to content

Commit 4c85b58

Browse files
authored
Merge pull request #88 from TrueNine/dev
ci: skip republish conflicts for npm packages
2 parents d62fa75 + fdef012 commit 4c85b58

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

.github/workflows/release-cli.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,12 @@ jobs:
390390
return 0
391391
fi
392392
393+
if grep -Eiq 'cannot publish over the previously published versions|previously published versions' "$publish_log"; then
394+
echo "${package_name}@${package_version} was already published according to npm, skipping"
395+
rm -f "$publish_log"
396+
return 0
397+
fi
398+
393399
if version_exists "$package_name" "$package_version"; then
394400
echo "${package_name}@${package_version} already exists on npm after publish attempt, skipping"
395401
rm -f "$publish_log"
@@ -489,17 +495,28 @@ jobs:
489495
exit 0
490496
fi
491497
492-
if (cd cli && pnpm publish --access public --no-git-checks); then
498+
publish_log=$(mktemp)
499+
500+
if (cd cli && pnpm publish --access public --no-git-checks) 2>&1 | tee "$publish_log"; then
493501
verify_version_exists
502+
rm -f "$publish_log"
503+
exit 0
504+
fi
505+
506+
if grep -Eiq 'cannot publish over the previously published versions|previously published versions' "$publish_log"; then
507+
echo "${package_name}@${package_version} was already published according to npm, skipping"
508+
rm -f "$publish_log"
494509
exit 0
495510
fi
496511
497512
if version_exists; then
498513
echo "${package_name}@${package_version} already exists on npm after publish attempt, skipping"
514+
rm -f "$publish_log"
499515
exit 0
500516
fi
501517
502518
echo "::error::Failed to publish ${package_name}@${package_version}. Exact version is still missing from npm."
519+
rm -f "$publish_log"
503520
exit 1
504521
505522
# 4.5. CLI 可用后,发布 MCP 包到 npm
@@ -586,17 +603,28 @@ jobs:
586603
exit 0
587604
fi
588605
589-
if (cd mcp && pnpm publish --access public --no-git-checks); then
606+
publish_log=$(mktemp)
607+
608+
if (cd mcp && pnpm publish --access public --no-git-checks) 2>&1 | tee "$publish_log"; then
590609
verify_version_exists
610+
rm -f "$publish_log"
611+
exit 0
612+
fi
613+
614+
if grep -Eiq 'cannot publish over the previously published versions|previously published versions' "$publish_log"; then
615+
echo "${package_name}@${package_version} was already published according to npm, skipping"
616+
rm -f "$publish_log"
591617
exit 0
592618
fi
593619
594620
if version_exists; then
595621
echo "${package_name}@${package_version} already exists on npm after publish attempt, skipping"
622+
rm -f "$publish_log"
596623
exit 0
597624
fi
598625
599626
echo "::error::Failed to publish ${package_name}@${package_version}. Exact version is still missing from npm."
627+
rm -f "$publish_log"
600628
exit 1
601629
602630
# 5. 构建 CLI 独立二进制(仅 artifact,不发 Release)

0 commit comments

Comments
 (0)