7676 timeout-minutes : 20
7777 outputs :
7878 sha : ${{ steps.manifest.outputs.sha || steps.ref.outputs.sha }}
79+ preflight_artifact_name : ${{ steps.preflight_artifact.outputs.name }}
7980 steps :
8081 - name : Validate inputs
8182 env :
@@ -131,14 +132,43 @@ jobs:
131132 esac
132133
133134 - name : Download OpenClaw npm preflight manifest
135+ id : preflight_artifact
134136 if : ${{ inputs.publish_openclaw_npm }}
135- uses : actions/download-artifact@v8
136- with :
137- name : openclaw-npm-preflight-${{ inputs.tag }}
138- path : ${{ runner.temp }}/openclaw-npm-preflight-manifest
139- repository : ${{ github.repository }}
140- run-id : ${{ inputs.preflight_run_id }}
141- github-token : ${{ github.token }}
137+ env :
138+ GH_TOKEN : ${{ github.token }}
139+ PREFLIGHT_RUN_ID : ${{ inputs.preflight_run_id }}
140+ RELEASE_TAG : ${{ inputs.tag }}
141+ run : |
142+ set -euo pipefail
143+
144+ preferred_name="openclaw-npm-preflight-${RELEASE_TAG}"
145+ preflight_dir="${RUNNER_TEMP}/openclaw-npm-preflight-manifest"
146+ rm -rf "${preflight_dir}"
147+ mkdir -p "${preflight_dir}"
148+ if gh run download "${PREFLIGHT_RUN_ID}" \
149+ --repo "${GITHUB_REPOSITORY}" \
150+ --name "${preferred_name}" \
151+ --dir "${preflight_dir}"; then
152+ echo "name=${preferred_name}" >> "$GITHUB_OUTPUT"
153+ exit 0
154+ fi
155+
156+ echo "::warning::${preferred_name} not found; checking run artifacts for a single compatible preflight artifact."
157+ mapfile -t matches < <(gh api -X GET "repos/${GITHUB_REPOSITORY}/actions/runs/${PREFLIGHT_RUN_ID}/artifacts" \
158+ --jq '.artifacts[] | select(.expired != true) | .name' |
159+ grep '^openclaw-npm-preflight-' || true)
160+ if [[ "${#matches[@]}" != "1" ]]; then
161+ echo "Expected ${preferred_name}, or exactly one openclaw-npm-preflight-* fallback artifact in run ${PREFLIGHT_RUN_ID}." >&2
162+ printf 'Available preflight candidates:\n' >&2
163+ printf -- '- %s\n' "${matches[@]:-<none>}" >&2
164+ exit 1
165+ fi
166+ fallback_name="${matches[0]}"
167+ gh run download "${PREFLIGHT_RUN_ID}" \
168+ --repo "${GITHUB_REPOSITORY}" \
169+ --name "${fallback_name}" \
170+ --dir "${preflight_dir}"
171+ echo "name=${fallback_name}" >> "$GITHUB_OUTPUT"
142172
143173 - name : Download full release validation manifest
144174 if : ${{ inputs.publish_openclaw_npm }}
@@ -306,6 +336,7 @@ jobs:
306336 PLUGINS : ${{ inputs.plugins }}
307337 PUBLISH_OPENCLAW_NPM : ${{ inputs.publish_openclaw_npm && 'true' || 'false' }}
308338 WAIT_FOR_CLAWHUB : ${{ inputs.wait_for_clawhub && 'true' || 'false' }}
339+ PREFLIGHT_ARTIFACT_NAME : ${{ needs.resolve_release_target.outputs.preflight_artifact_name }}
309340 run : |
310341 set -euo pipefail
311342
@@ -314,7 +345,10 @@ jobs:
314345 shift
315346
316347 local before_json dispatch_output run_id
317- before_json="$(gh run list --repo "$GITHUB_REPOSITORY" --workflow "$workflow" --event workflow_dispatch --limit 100 --json databaseId --jq '[.[].databaseId]')"
348+ before_json="$(gh api -X GET "repos/${GITHUB_REPOSITORY}/actions/workflows/${workflow}/runs" \
349+ -F event=workflow_dispatch \
350+ -F per_page=100 \
351+ --jq '[.workflow_runs[].id]')"
318352
319353 dispatch_output="$(gh workflow run --repo "$GITHUB_REPOSITORY" "$workflow" --ref "$CHILD_WORKFLOW_REF" "$@" 2>&1)"
320354 printf '%s\n' "$dispatch_output" >&2
@@ -327,8 +361,10 @@ jobs:
327361 if [[ -z "$run_id" ]]; then
328362 for _ in $(seq 1 60); do
329363 run_id="$(
330- BEFORE_IDS="$before_json" gh run list --repo "$GITHUB_REPOSITORY" --workflow "$workflow" --event workflow_dispatch --limit 50 --json databaseId,createdAt \
331- --jq 'map(select(.databaseId as $id | (env.BEFORE_IDS | fromjson | index($id) | not))) | sort_by(.createdAt) | reverse | .[0].databaseId // empty'
364+ BEFORE_IDS="$before_json" gh api -X GET "repos/${GITHUB_REPOSITORY}/actions/workflows/${workflow}/runs" \
365+ -F event=workflow_dispatch \
366+ -F per_page=50 \
367+ --jq '.workflow_runs | map({databaseId:.id, createdAt:.created_at}) | map(select(.databaseId as $id | (env.BEFORE_IDS | fromjson | index($id) | not))) | sort_by(.createdAt) | reverse | .[0].databaseId // empty'
332368 )"
333369 if [[ -n "$run_id" ]]; then
334370 break
@@ -349,6 +385,23 @@ jobs:
349385 printf '%s\n' "${run_id}"
350386 }
351387
388+ print_pending_deployments() {
389+ local workflow="$1"
390+ local run_id="$2"
391+ local pending_json
392+
393+ pending_json="$(gh api -X GET "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/pending_deployments" 2>/dev/null || true)"
394+ if [[ -z "${pending_json}" ]] || ! printf '%s' "${pending_json}" | jq -e 'length > 0' >/dev/null 2>&1; then
395+ return 0
396+ fi
397+
398+ echo "${workflow} pending environment approval:"
399+ while IFS=$'\t' read -r env_id env_name can_approve; do
400+ echo "- env=${env_name} canApprove=${can_approve}"
401+ echo " approve: gh api -X POST repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/pending_deployments -F 'environment_ids[]=${env_id}' -f state=approved -f comment='Approve release gate'"
402+ done < <(printf '%s' "${pending_json}" | jq -r '.[] | [.environment.id, .environment.name, .current_user_can_approve] | @tsv')
403+ }
404+
352405 wait_for_run() {
353406 local workflow="$1"
354407 local run_id="$2"
@@ -366,6 +419,7 @@ jobs:
366419 state="${status}:${updated_at}"
367420 if [[ "$state" != "$last_state" ]]; then
368421 echo "${workflow} still ${status} (updated ${updated_at}): ${url}"
422+ print_pending_deployments "${workflow}" "${run_id}"
369423 last_state="$state"
370424 fi
371425 sleep 30
@@ -466,17 +520,18 @@ jobs:
466520 }
467521
468522 upload_dependency_evidence_release_asset() {
469- local release_version download_dir asset_path asset_name
523+ local release_version download_dir asset_path asset_name artifact_name
470524 release_version="${RELEASE_TAG#v}"
471525 download_dir="${RUNNER_TEMP}/openclaw-release-dependency-evidence-asset"
472526 asset_name="openclaw-${release_version}-dependency-evidence.zip"
473527 asset_path="${RUNNER_TEMP}/${asset_name}"
528+ artifact_name="${PREFLIGHT_ARTIFACT_NAME:-openclaw-npm-preflight-${RELEASE_TAG}}"
474529
475530 rm -rf "${download_dir}" "${asset_path}"
476531 mkdir -p "${download_dir}"
477532 gh run download "${PREFLIGHT_RUN_ID}" \
478533 --repo "${GITHUB_REPOSITORY}" \
479- --name "openclaw-npm-preflight-${RELEASE_TAG }" \
534+ --name "${artifact_name }" \
480535 --dir "${download_dir}"
481536
482537 if [[ ! -d "${download_dir}/dependency-evidence" ]]; then
0 commit comments