Skip to content

Commit 2fc8075

Browse files
committed
ci: parallelize release publish workflows
1 parent 41f028e commit 2fc8075

3 files changed

Lines changed: 83 additions & 24 deletions

File tree

.github/workflows/openclaw-release-publish.yml

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ on:
3333
required: false
3434
type: string
3535
publish_openclaw_npm:
36-
description: Publish the OpenClaw npm package after plugin npm and ClawHub publish complete
36+
description: Publish the OpenClaw npm package after plugin npm succeeds; ClawHub may still run
3737
required: true
3838
default: true
3939
type: boolean
@@ -169,15 +169,15 @@ jobs:
169169
run: |
170170
set -euo pipefail
171171
172-
dispatch_and_wait() {
172+
dispatch_workflow() {
173173
local workflow="$1"
174174
shift
175175
176-
local before_json dispatch_output run_id status conclusion url
176+
local before_json dispatch_output run_id
177177
before_json="$(gh run list --repo "$GITHUB_REPOSITORY" --workflow "$workflow" --event workflow_dispatch --limit 100 --json databaseId --jq '[.[].databaseId]')"
178178
179179
dispatch_output="$(gh workflow run --repo "$GITHUB_REPOSITORY" "$workflow" --ref "$CHILD_WORKFLOW_REF" "$@" 2>&1)"
180-
printf '%s\n' "$dispatch_output"
180+
printf '%s\n' "$dispatch_output" >&2
181181
run_id="$(
182182
printf '%s\n' "$dispatch_output" |
183183
sed -nE 's#.*actions/runs/([0-9]+).*#\1#p' |
@@ -202,15 +202,14 @@ jobs:
202202
exit 1
203203
fi
204204
205-
echo "Dispatched ${workflow}: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
205+
echo "Dispatched ${workflow}: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${run_id}" >&2
206+
printf '%s\n' "${run_id}"
207+
}
206208
207-
cancel_child() {
208-
if [[ -n "${run_id:-}" ]]; then
209-
echo "Cancelling child workflow ${workflow}: ${run_id}" >&2
210-
gh run cancel --repo "$GITHUB_REPOSITORY" "$run_id" >/dev/null 2>&1 || true
211-
fi
212-
}
213-
trap cancel_child EXIT INT TERM
209+
wait_for_run() {
210+
local workflow="$1"
211+
local run_id="$2"
212+
local status conclusion url
214213
215214
while true; do
216215
status="$(gh run view --repo "$GITHUB_REPOSITORY" "$run_id" --json status --jq '.status')"
@@ -219,7 +218,6 @@ jobs:
219218
fi
220219
sleep 30
221220
done
222-
trap - EXIT INT TERM
223221
224222
conclusion="$(gh run view --repo "$GITHUB_REPOSITORY" "$run_id" --json conclusion --jq '.conclusion')"
225223
url="$(gh run view --repo "$GITHUB_REPOSITORY" "$run_id" --json url --jq '.url')"
@@ -229,16 +227,36 @@ jobs:
229227
} >> "$GITHUB_STEP_SUMMARY"
230228
if [[ "$conclusion" != "success" ]]; then
231229
gh run view --repo "$GITHUB_REPOSITORY" "$run_id" --json jobs --jq '.jobs[] | select(.conclusion != "success" and .conclusion != "skipped") | {name, conclusion, url}' || true
232-
exit 1
230+
return 1
233231
fi
234232
}
235233
234+
wait_for_run_background() {
235+
local workflow="$1"
236+
local run_id="$2"
237+
local result_file="$3"
238+
(
239+
if wait_for_run "${workflow}" "${run_id}"; then
240+
printf 'success\n' > "${result_file}"
241+
else
242+
printf 'failure\n' > "${result_file}"
243+
fi
244+
) &
245+
wait_run_pid="$!"
246+
}
247+
236248
{
237249
echo "### Publish sequence"
238250
echo
239251
echo "- Workflow ref: \`${CHILD_WORKFLOW_REF}\`"
240252
echo "- Release tag: \`${RELEASE_TAG}\`"
241253
echo "- Release SHA: \`${TARGET_SHA}\`"
254+
echo "- Plugin npm and ClawHub publish: dispatched in parallel"
255+
if [[ "${PUBLISH_OPENCLAW_NPM}" == "true" ]]; then
256+
echo "- OpenClaw npm publish: starts after plugin npm succeeds; ClawHub may still be running"
257+
else
258+
echo "- OpenClaw npm publish: skipped by input"
259+
fi
242260
} >> "$GITHUB_STEP_SUMMARY"
243261
244262
npm_args=(-f publish_scope="${PLUGIN_PUBLISH_SCOPE}" -f ref="${TARGET_SHA}")
@@ -248,15 +266,53 @@ jobs:
248266
clawhub_args+=(-f plugins="${PLUGINS}")
249267
fi
250268
251-
dispatch_and_wait plugin-npm-release.yml "${npm_args[@]}"
252-
dispatch_and_wait plugin-clawhub-release.yml "${clawhub_args[@]}"
269+
plugin_npm_run_id="$(dispatch_workflow plugin-npm-release.yml "${npm_args[@]}")"
270+
plugin_clawhub_run_id="$(dispatch_workflow plugin-clawhub-release.yml "${clawhub_args[@]}")"
271+
272+
if ! wait_for_run plugin-npm-release.yml "${plugin_npm_run_id}"; then
273+
echo "Plugin npm publish failed; cancelling ClawHub publish child ${plugin_clawhub_run_id}." >&2
274+
gh run cancel --repo "$GITHUB_REPOSITORY" "${plugin_clawhub_run_id}" >/dev/null 2>&1 || true
275+
exit 1
276+
fi
253277
278+
openclaw_npm_run_id=""
254279
if [[ "${PUBLISH_OPENCLAW_NPM}" == "true" ]]; then
255-
dispatch_and_wait openclaw-npm-release.yml \
280+
openclaw_npm_run_id="$(dispatch_workflow openclaw-npm-release.yml \
256281
-f tag="${RELEASE_TAG}" \
257282
-f preflight_only=false \
258283
-f preflight_run_id="${PREFLIGHT_RUN_ID}" \
259-
-f npm_dist_tag="${RELEASE_NPM_DIST_TAG}"
284+
-f npm_dist_tag="${RELEASE_NPM_DIST_TAG}")"
260285
else
261286
echo "- OpenClaw npm publish: skipped by input" >> "$GITHUB_STEP_SUMMARY"
262287
fi
288+
289+
clawhub_result="$RUNNER_TEMP/clawhub-result.txt"
290+
wait_run_pid=""
291+
wait_for_run_background plugin-clawhub-release.yml "${plugin_clawhub_run_id}" "${clawhub_result}"
292+
clawhub_pid="${wait_run_pid}"
293+
294+
openclaw_result=""
295+
openclaw_pid=""
296+
if [[ -n "${openclaw_npm_run_id}" ]]; then
297+
openclaw_result="$RUNNER_TEMP/openclaw-npm-result.txt"
298+
wait_run_pid=""
299+
wait_for_run_background openclaw-npm-release.yml "${openclaw_npm_run_id}" "${openclaw_result}"
300+
openclaw_pid="${wait_run_pid}"
301+
fi
302+
303+
failed=0
304+
if ! wait "${clawhub_pid}"; then
305+
failed=1
306+
fi
307+
if [[ -n "${openclaw_pid}" ]] && ! wait "${openclaw_pid}"; then
308+
failed=1
309+
fi
310+
if [[ -f "${clawhub_result}" && "$(cat "${clawhub_result}")" != "success" ]]; then
311+
failed=1
312+
fi
313+
if [[ -n "${openclaw_result}" && -f "${openclaw_result}" && "$(cat "${openclaw_result}")" != "success" ]]; then
314+
failed=1
315+
fi
316+
if [[ "${failed}" != "0" ]]; then
317+
exit 1
318+
fi

.github/workflows/plugin-clawhub-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ jobs:
182182
contents: read
183183
strategy:
184184
fail-fast: false
185-
max-parallel: 6
185+
max-parallel: 12
186186
matrix:
187187
plugin: ${{ fromJson(needs.preview_plugins_clawhub.outputs.matrix) }}
188188
steps:
@@ -263,7 +263,7 @@ jobs:
263263
id-token: write
264264
strategy:
265265
fail-fast: false
266-
max-parallel: 6
266+
max-parallel: 12
267267
matrix:
268268
plugin: ${{ fromJson(needs.preview_plugins_clawhub.outputs.matrix) }}
269269
steps:

docs/reference/RELEASING.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,13 @@ the maintainer-only release runbook.
7777
prior evidence stale.
7878
9. For beta, tag `vYYYY.M.D-beta.N`, then run `OpenClaw Release Publish` from
7979
the matching `release/YYYY.M.D` branch. It verifies `pnpm plugins:sync:check`,
80-
publishes all publishable plugin packages to npm first, publishes the same
81-
set to ClawHub second as ClawPack npm-pack tarballs, and then promotes the
82-
prepared OpenClaw npm preflight artifact with the matching dist-tag. After
83-
publish, run post-publish package
80+
dispatches all publishable plugin packages to npm and the same set to
81+
ClawHub in parallel, and then promotes the prepared OpenClaw npm preflight
82+
artifact with the matching dist-tag as soon as plugin npm publish succeeds.
83+
ClawHub publishing may still be running while OpenClaw npm publishes, but the
84+
release publish workflow does not finish until both plugin publish paths and
85+
the OpenClaw npm publish path have completed successfully. After publish, run
86+
the post-publish package
8487
acceptance against the published `openclaw@YYYY.M.D-beta.N` or
8588
`openclaw@beta` package. If a pushed or published prerelease needs a fix,
8689
cut the next matching prerelease number; do not delete or rewrite the old

0 commit comments

Comments
 (0)