mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
Merge pull request #4863 from ruvnet/weaver/ruflo-stable-release-ci
ci(stable-npm-release): wait for npm processing before the integrity check
This commit is contained in:
1 file changed
+49
-17
@@ -20,7 +20,7 @@ jobs:
|
||||
name: Publish stable package train
|
||||
if: github.actor == 'ruvnet'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
timeout-minutes: 75
|
||||
|
||||
steps:
|
||||
- name: Validate release inputs
|
||||
@@ -385,13 +385,35 @@ jobs:
|
||||
test "${#archives[@]}" -eq 3
|
||||
test "${#integrities[@]}" -eq 3
|
||||
|
||||
# Read one field of a published version straight from the registry,
|
||||
# bypassing npm's local cache and the CDN. Prints nothing and fails
|
||||
# when the version is not readable yet.
|
||||
registry_field() {
|
||||
curl -fsS --max-time 30 -H 'Cache-Control: no-cache' -H 'Accept: application/json' \
|
||||
"https://registry.npmjs.org/${1/\//%2f}/$2" 2>/dev/null |
|
||||
FIELD="$3" node -e '
|
||||
let s = ""; process.stdin.on("data", (d) => (s += d)).on("end", () => {
|
||||
let v; try { v = process.env.FIELD.split(".").reduce((o, k) => o?.[k], JSON.parse(s)); } catch {}
|
||||
if (typeof v !== "string" || !v) process.exit(1);
|
||||
process.stdout.write(v);
|
||||
});'
|
||||
}
|
||||
|
||||
for index in "${!packages[@]}"; do
|
||||
package="${packages[$index]}"
|
||||
archive="${archives[$index]}"
|
||||
if npm view "${package}@${version}" version >/dev/null 2>&1; then
|
||||
if registry_field "$package" "$version" version >/dev/null; then
|
||||
echo "${package}@${version} already published"
|
||||
else
|
||||
npm publish "$archive" --ignore-scripts --access public --tag "$candidate_tag"
|
||||
elif ! npm publish "$archive" --ignore-scripts --access public --tag "$candidate_tag" 2>"$RUNNER_TEMP/publish.err"; then
|
||||
cat "$RUNNER_TEMP/publish.err" >&2
|
||||
# A rerun can start while the first upload is still being processed:
|
||||
# the version is not readable yet but the registry refuses it.
|
||||
# Fall through to the integrity wait instead of failing here.
|
||||
if grep -qE 'EPUBLISHCONFLICT|previously published|cannot publish over' "$RUNNER_TEMP/publish.err"; then
|
||||
echo "${package}@${version} was already uploaded; waiting for registry processing"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -399,25 +421,32 @@ jobs:
|
||||
package="${packages[$index]}"
|
||||
expected_integrity="${integrities[$index]}"
|
||||
found=false
|
||||
# npm can acknowledge an upload before its asynchronous processing
|
||||
# makes the version readable. Do not republish or promote it early.
|
||||
for attempt in {1..120}; do
|
||||
registry_version="$(npm view "${package}@${version}" version 2>/dev/null || true)"
|
||||
registry_integrity="$(npm view "${package}@${version}" dist.integrity 2>/dev/null || true)"
|
||||
if [[ "$registry_version" == "$version" && "$registry_integrity" == "$expected_integrity" ]]; then
|
||||
# npm acknowledges an upload before its asynchronous processing makes
|
||||
# the version readable. 3.47.0 took about 5 minutes and 3.47.1 about
|
||||
# 14 (runs 36345167527 and 36445956751 gave up after 30 seconds).
|
||||
# Poll the registry directly for up to 30 minutes. Do not republish
|
||||
# or promote the version early.
|
||||
deadline=$((SECONDS + 1800))
|
||||
delay=5
|
||||
while (( SECONDS < deadline )); do
|
||||
registry_integrity="$(registry_field "$package" "$version" dist.integrity || true)"
|
||||
if [[ "$registry_integrity" == "$expected_integrity" ]]; then
|
||||
found=true
|
||||
break
|
||||
fi
|
||||
if [[ -n "$registry_integrity" && "$registry_integrity" != "$expected_integrity" ]]; then
|
||||
echo "::error::${package}@${version} has a different archive integrity"
|
||||
if [[ -n "$registry_integrity" ]]; then
|
||||
echo "::error::${package}@${version} has a different archive integrity: registry ${registry_integrity}, verified ${expected_integrity}"
|
||||
exit 1
|
||||
fi
|
||||
sleep 5
|
||||
echo "${package}@${version} not readable yet (${SECONDS}s); retrying in ${delay}s"
|
||||
sleep "$delay"
|
||||
delay=$(( delay < 30 ? delay * 2 : 30 ))
|
||||
done
|
||||
if [[ "$found" != true ]]; then
|
||||
echo "::error::${package}@${version} was not available with the verified integrity within 10 minutes; inspect registry processing before retrying publication"
|
||||
echo "::error::${package}@${version} was not available with the verified integrity within 30 minutes; inspect registry processing, then re-run this workflow (versions that are already published are skipped)"
|
||||
fi
|
||||
test "$found" = true
|
||||
echo "${package}@${version} verified at ${expected_integrity}"
|
||||
done
|
||||
|
||||
for package in "${packages[@]}"; do
|
||||
@@ -436,8 +465,11 @@ jobs:
|
||||
packages=("@claude-flow/cli" "claude-flow" "ruflo")
|
||||
for package in "${packages[@]}"; do
|
||||
tags_ready=false
|
||||
for attempt in {1..10}; do
|
||||
tags="$(npm view "$package" dist-tags --json 2>/dev/null || true)"
|
||||
# Read dist-tags uncached; npm view can return a stale packument
|
||||
# for minutes after `npm dist-tag add`.
|
||||
for attempt in {1..60}; do
|
||||
tags="$(curl -fsS --max-time 30 -H 'Cache-Control: no-cache' \
|
||||
"https://registry.npmjs.org/-/package/${package/\//%2f}/dist-tags" 2>/dev/null || true)"
|
||||
if TAGS="$tags" VERSION="$version" node - <<'NODE'
|
||||
const tags = JSON.parse(process.env.TAGS || '{}');
|
||||
process.exit(['latest', 'alpha', 'v3alpha'].every((tag) => tags[tag] === process.env.VERSION) ? 0 : 1);
|
||||
@@ -446,7 +478,7 @@ jobs:
|
||||
tags_ready=true
|
||||
break
|
||||
fi
|
||||
sleep 3
|
||||
sleep 5
|
||||
done
|
||||
test "$tags_ready" = true
|
||||
TAGS="$tags" VERSION="$version" PACKAGE="$package" node - <<'NODE'
|
||||
|
||||
Reference in new issue
Block a user