Files
Pulse/.github/workflows/recover-release-activation.yml
courtmanr@gmail.com 6ce41ae9d4 Fold the echo-only release joins into their public writers
candidate_qualification and release_readiness only restated other jobs'
results. publish_release_tag, publish_docker, publish_helm_chart and
activate_release now each carry the exact candidate predicate in their own
needs and if, guarded by !cancelled() with the same allowed integration
skip, and activation joins the tag and both registry publications directly.
The commit verdict restates every candidate result in place of the
readiness join.

recover-release-activation.yml accepts both shapes. A source run that has
release_readiness still has to prove only that join, as before. A run
without it has to prove publish_release_tag and at least one, and only
successful, jobs under the publish_docker and publish_helm_chart caller IDs.

Failure diagnostics and the inspection-only Helm chart artifact, which
nothing downloads, are kept for three days instead of 14 and 90.
2026-10-01 21:47:58 +01:00

511 lines
24 KiB
YAML

name: Recover Release Activation
run-name: Recover release activation ${{ inputs.tag }} source ${{ inputs.source_release_run_id }}
# Resume only a quarantined candidate whose immutable release gates already
# passed. This path revalidates stored artifacts and repeats activation without
# rebuilding or replacing the candidate.
on:
workflow_dispatch:
inputs:
tag:
description: "Exact quarantined release tag."
required: true
type: string
source_release_run_id:
description: "Failed create-release.yml run whose immutable gates passed."
required: true
type: string
concurrency:
group: release-${{ inputs.tag }}
cancel-in-progress: false
permissions:
actions: write
contents: write
packages: read
jobs:
recover_activation:
name: Revalidate and recover activation
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout release control
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Qualify the quarantined source run
id: qualify
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
SOURCE_RELEASE_RUN_ID: ${{ inputs.source_release_run_id }}
run: |
set -euo pipefail
if [[ ! "${TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-((rc|alpha|beta)\.[0-9]+))?$ ]]; then
echo "::error::Invalid recovery tag ${TAG}."
exit 1
fi
if [[ ! "${SOURCE_RELEASE_RUN_ID}" =~ ^[0-9]+$ ]]; then
echo "::error::Source release run ID must be numeric."
exit 1
fi
source_run=$(mktemp)
source_jobs=$(mktemp)
release_json=$(mktemp)
cleanup() { rm -f "${source_run}" "${source_jobs}" "${release_json}"; }
trap cleanup EXIT
gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${SOURCE_RELEASE_RUN_ID}" > "${source_run}"
jq -e \
--arg repository "${GITHUB_REPOSITORY}" \
'.event == "workflow_dispatch" and
.path == ".github/workflows/create-release.yml" and
.head_branch == "main" and
.head_repository.full_name == $repository and
.status == "completed" and
.conclusion == "failure" and
(.head_sha | test("^[0-9a-f]{40}$"))' \
"${source_run}" >/dev/null || {
echo "::error::Run ${SOURCE_RELEASE_RUN_ID} is not a completed failed mainline create-release run."
exit 1
}
gh api --paginate --slurp \
"repos/${GITHUB_REPOSITORY}/actions/runs/${SOURCE_RELEASE_RUN_ID}/jobs?per_page=100" \
| jq '[.[].jobs[]]' > "${source_jobs}"
# release_readiness is the canonical DAG join for every immutable
# gate in runs made before the join was folded into its writers.
# Such a run must still prove that join and nothing else, so it
# recovers exactly as before. A run without that job carries the
# candidate predicate on publish_release_tag itself, and must prove
# the tag, every publish_docker reusable job and the Helm chart
# publication that the join used to require. Reusable jobs are
# matched by caller ID prefix, and at least one must exist. The
# surrounding all-jobs verdict below still rejects every failure
# outside the activation boundary.
immutable_join=release_readiness
if ! jq -e 'any(.[]; .name == "release_readiness")' "${source_jobs}" >/dev/null; then
immutable_join=publish_release_tag
for reusable_job in publish_docker publish_helm_chart; do
jq -e --arg name "${reusable_job}" '
[.[] | select(.name == $name or (.name | startswith($name + " / ")))] |
length > 0 and all(.[]; .status == "completed" and .conclusion == "success")' \
"${source_jobs}" >/dev/null || {
echo "::error::Source run lacks successful immutable gate: ${reusable_job}."
exit 1
}
done
fi
for required_job in \
prepare \
create_release \
"${immutable_join}" \
dispatch_release_convergence; do
jq -e --arg name "${required_job}" \
'any(.[]; .name == $name and .status == "completed" and .conclusion == "success")' \
"${source_jobs}" >/dev/null || {
echo "::error::Source run lacks successful immutable gate: ${required_job}."
exit 1
}
done
jq -e '
all(.[];
.conclusion == "success" or
.conclusion == "skipped" or
(.conclusion == "failure" and
(.name == "activate_release" or
.name == "Release Activation Commit Verdict")))' \
"${source_jobs}" >/dev/null || {
echo "::error::Source run contains a failure outside the recoverable activation boundary."
exit 1
}
gh api "repos/${GITHUB_REPOSITORY}/releases?per_page=100" --paginate \
| jq -sc --arg tag "${TAG}" 'add | map(select(.tag_name == $tag)) | first // empty' \
> "${release_json}"
source_sha=$(jq -r '.head_sha' "${source_run}")
release_id=$(jq -r '.id // empty' "${release_json}")
target_commitish=$(jq -r '.target_commitish // empty' "${release_json}")
is_draft=$(jq -r '.draft // false' "${release_json}")
is_prerelease=$(jq -r '.prerelease // false' "${release_json}")
activation_committed=$(jq -r 'any(.assets[]?; .name == "release-activation.json")' "${release_json}")
if [ -z "${release_id}" ] || [ "${target_commitish}" != "${source_sha}" ] || \
[ "${is_draft}" != "true" ] || [ "${activation_committed}" = "true" ]; then
echo "::error::${TAG} is not the uncommitted quarantined candidate from run ${SOURCE_RELEASE_RUN_ID}."
exit 1
fi
version="${TAG#v}"
manifest_artifact="release-candidate-manifest-${source_sha}-${version}"
gh api --paginate --slurp \
"repos/${GITHUB_REPOSITORY}/actions/runs/${SOURCE_RELEASE_RUN_ID}/artifacts?per_page=100" \
| jq '[.[].artifacts[]]' \
| jq -e --arg name "${manifest_artifact}" \
'any(.[]; .name == $name and .expired == false)' >/dev/null || {
echo "::error::Immutable candidate manifest ${manifest_artifact} is unavailable."
exit 1
}
run_created_date=$(jq -r '.created_at | fromdateiso8601 | strftime("%Y%m%d")' "${source_run}")
r2_prefix="${TAG}-pro-${run_created_date}-${SOURCE_RELEASE_RUN_ID}"
python3 scripts/write_github_output.py version "${version}"
echo "source_sha=${source_sha}" >> "$GITHUB_OUTPUT"
echo "release_id=${release_id}" >> "$GITHUB_OUTPUT"
echo "is_prerelease=${is_prerelease}" >> "$GITHUB_OUTPUT"
python3 scripts/write_github_output.py manifest_artifact "${manifest_artifact}"
python3 scripts/write_github_output.py r2_prefix "${r2_prefix}"
echo "[OK] ${TAG} is eligible for activation-only recovery from run ${SOURCE_RELEASE_RUN_ID}."
- name: Revalidate the immutable staged candidate
env:
GH_TOKEN: ${{ github.token }}
SOURCE_RELEASE_RUN_ID: ${{ inputs.source_release_run_id }}
VERSION: ${{ steps.qualify.outputs.version }}
SOURCE_SHA: ${{ steps.qualify.outputs.source_sha }}
RELEASE_ID: ${{ steps.qualify.outputs.release_id }}
MANIFEST_ARTIFACT: ${{ steps.qualify.outputs.manifest_artifact }}
run: |
set -euo pipefail
manifest_dir=$(mktemp -d)
release_assets=$(mktemp)
release_body=$(mktemp)
cleanup() { rm -rf "${manifest_dir}"; rm -f "${release_assets}" "${release_body}"; }
trap cleanup EXIT
gh run download "${SOURCE_RELEASE_RUN_ID}" \
--repo "${GITHUB_REPOSITORY}" \
--name "${MANIFEST_ARTIFACT}" \
--dir "${manifest_dir}"
gh api --paginate --slurp \
"repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?per_page=100" \
| jq '[.[][]]' > "${release_assets}"
gh api "repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" \
--jq '.body // ""' > "${release_body}"
python3 scripts/release_candidate_manifest.py verify-release \
--manifest "${manifest_dir}/release-candidate.json" \
--assets-json "${release_assets}" \
--version "${VERSION}" \
--source-sha "${SOURCE_SHA}" \
--release-body-file "${release_body}"
python3 scripts/release_control/render_release_body.py \
--version "${VERSION}" \
--validate-body-file "${release_body}"
echo "[OK] GitHub's stored RC packet still matches the immutable source-run manifest."
- name: Set up Helm
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
with:
version: v3.15.2
- name: Revalidate exact Helm chart identity and provenance
id: chart_proof
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
WORKFLOW_OUTPUT_1: ${{ steps.qualify.outputs.source_sha }}
run: |
set -euo pipefail
./scripts/verify-release-helm-chart.sh \
"${TAG}" "${WORKFLOW_OUTPUT_1}" \
"${GITHUB_REPOSITORY}" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
- name: Log in to Docker Hub
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GHCR
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Revalidate exact container identities and provenance
id: container_proof
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
WORKFLOW_OUTPUT_1: ${{ steps.qualify.outputs.source_sha }}
run: |
set -euo pipefail
./scripts/verify-release-container-images.sh \
"${TAG}" "${WORKFLOW_OUTPUT_1}" \
"${{ github.repository }}" >> "$GITHUB_OUTPUT"
- name: Dispatch a fresh durable convergence owner
id: dispatch
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
SOURCE_RELEASE_RUN_ID: ${{ inputs.source_release_run_id }}
VERSION: ${{ steps.qualify.outputs.version }}
SOURCE_SHA: ${{ steps.qualify.outputs.source_sha }}
RELEASE_ID: ${{ steps.qualify.outputs.release_id }}
IS_PRERELEASE: ${{ steps.qualify.outputs.is_prerelease }}
R2_PREFIX: ${{ steps.qualify.outputs.r2_prefix }}
run: |
set -euo pipefail
dispatch="$(
jq -n \
--arg tag "${TAG}" \
--arg version "${VERSION}" \
--arg prerelease "${IS_PRERELEASE}" \
--arg target_commitish "${SOURCE_SHA}" \
--arg release_id "${RELEASE_ID}" \
--arg r2_prefix "${R2_PREFIX}" \
--arg source_release_run_id "${SOURCE_RELEASE_RUN_ID}" \
'{
ref: "main",
return_run_details: true,
inputs: {
tag: $tag,
version: $version,
prerelease: $prerelease,
target_commitish: $target_commitish,
release_id: $release_id,
r2_prefix: $r2_prefix,
source_release_run_id: $source_release_run_id
}
}' | \
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2026-03-10" \
"repos/${GITHUB_REPOSITORY}/actions/workflows/release-convergence.yml/dispatches" \
--input -
)"
run_id=$(jq -r '.workflow_run_id // empty' <<<"${dispatch}")
run_url=$(jq -r '.html_url // empty' <<<"${dispatch}")
if [[ ! "${run_id}" =~ ^[0-9]+$ ]] || [ -z "${run_url}" ]; then
echo "::error::Recovery convergence dispatch did not return an exact workflow run."
exit 1
fi
echo "run_id=${run_id}" >> "$GITHUB_OUTPUT"
echo "run_url=${run_url}" >> "$GITHUB_OUTPUT"
echo "[OK] Fresh convergence owner is durably queued as ${run_url}."
- name: Commit the recovered activation
env:
GH_TOKEN: ${{ github.token }}
IMMUTABILITY_ADMIN_TOKEN: ${{ secrets.WORKFLOW_PAT }}
TAG: ${{ inputs.tag }}
SOURCE_RELEASE_RUN_ID: ${{ inputs.source_release_run_id }}
EXPECTED_COMMIT: ${{ steps.qualify.outputs.source_sha }}
RELEASE_ID: ${{ steps.qualify.outputs.release_id }}
IS_PRERELEASE: ${{ steps.qualify.outputs.is_prerelease }}
R2_PREFIX: ${{ steps.qualify.outputs.r2_prefix }}
CONVERGENCE_RUN_ID: ${{ steps.dispatch.outputs.run_id }}
SERVER_IMAGE_DIGEST: ${{ steps.container_proof.outputs.server_digest }}
CONTROL_PLANE_IMAGE_DIGEST: ${{ steps.container_proof.outputs.control_plane_digest }}
HELM_CHART_DIGEST: ${{ steps.chart_proof.outputs.chart_digest }}
run: |
set -euo pipefail
release_json=$(mktemp)
publish_payload=$(mktemp)
quarantine_payload=$(mktemp)
activation_marker_dir=$(mktemp -d)
activation_marker="${activation_marker_dir}/release-activation.json"
verified_marker=$(mktemp)
activated=false
committed=false
marker_staged=false
require_viable_convergence_owner() {
local attempt owner_state owner_event owner_status owner_conclusion
local owner_workflow owner_title owner_url expected_title
expected_title="Release convergence ${TAG} source ${SOURCE_RELEASE_RUN_ID}"
for attempt in $(seq 1 12); do
owner_state="$(
gh run view "${CONVERGENCE_RUN_ID}" \
--repo "${GITHUB_REPOSITORY}" \
--json event,status,conclusion,workflowName,displayTitle,url \
--jq '[.event, .status, (.conclusion // ""), .workflowName, .displayTitle, .url] | @tsv'
)"
owner_event=$(awk -F '\t' '{print $1}' <<<"${owner_state}")
owner_status=$(awk -F '\t' '{print $2}' <<<"${owner_state}")
owner_conclusion=$(awk -F '\t' '{print $3}' <<<"${owner_state}")
owner_workflow=$(awk -F '\t' '{print $4}' <<<"${owner_state}")
owner_title=$(awk -F '\t' '{print $5}' <<<"${owner_state}")
owner_url=$(awk -F '\t' '{print $6}' <<<"${owner_state}")
if [ "${owner_event}" = "workflow_dispatch" ] && \
[ "${owner_workflow}" = "Release Convergence" ] && \
[ "${owner_title}" = "${expected_title}" ] && \
[ "${owner_status}" != "completed" ] && \
[ -z "${owner_conclusion}" ]; then
echo "Verified viable recovery convergence owner ${CONVERGENCE_RUN_ID}: ${owner_status} ${owner_url}."
return 0
fi
if [ "${owner_status}" = "completed" ] || [ -n "${owner_conclusion}" ]; then
echo "::error::Exact recovery convergence owner ${CONVERGENCE_RUN_ID} is terminal for ${TAG}: status=${owner_status} conclusion=${owner_conclusion:-none} ${owner_url}."
return 1
fi
echo "Recovery convergence owner ${CONVERGENCE_RUN_ID} metadata is not coherent yet (${attempt}/12); waiting for GitHub indexing."
sleep 2
done
echo "::error::Exact recovery convergence owner ${CONVERGENCE_RUN_ID} metadata did not converge for ${TAG}: event=${owner_event:-missing} workflow=${owner_workflow:-missing} title=${owner_title:-missing} status=${owner_status:-missing} ${owner_url:-}."
return 1
}
compensate_uncommitted_activation() {
if [ "${activated}" = "true" ] && [ "${committed}" != "true" ]; then
echo "::warning::Recovered publication did not become immutable; returning ${TAG} to draft quarantine."
gh api "repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" \
-X PATCH --input "${quarantine_payload}" >/dev/null || true
fi
if [ "${marker_staged}" = "true" ] && [ "${committed}" != "true" ]; then
marker_asset_id="$(
gh api --paginate \
"repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?per_page=100" \
--jq '.[] | select(.name == "release-activation.json") | .id' \
2>/dev/null || true
)"
if [[ "${marker_asset_id}" =~ ^[0-9]+$ ]]; then
gh api -X DELETE \
"repos/${GITHUB_REPOSITORY}/releases/assets/${marker_asset_id}" \
>/dev/null || true
fi
fi
}
trap compensate_uncommitted_activation ERR
gh api "repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" > "${release_json}"
jq -e \
--arg tag "${TAG}" \
--arg commit "${EXPECTED_COMMIT}" \
--argjson prerelease "${IS_PRERELEASE}" \
'.tag_name == $tag and .target_commitish == $commit and
.draft == true and .prerelease == $prerelease and
(any(.assets[]?; .name == "release-activation.json") | not)' \
"${release_json}" >/dev/null || {
echo "::error::Release ${RELEASE_ID} no longer matches the recoverable staged candidate."
exit 1
}
make_latest=false
if [ "${IS_PRERELEASE}" != "true" ]; then
highest_stable=$(gh api --paginate "repos/${GITHUB_REPOSITORY}/tags" --jq '.[].name' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)
if [ "${TAG}" = "${highest_stable}" ]; then
make_latest=true
fi
fi
jq -n --arg make_latest "${make_latest}" \
'{draft: false, make_latest: $make_latest}' > "${publish_payload}"
jq -n '{draft: true, make_latest: "false"}' > "${quarantine_payload}"
require_viable_convergence_owner
if [[ ! "${SERVER_IMAGE_DIGEST}" =~ ^sha256:[0-9a-f]{64}$ ]] || \
[[ ! "${CONTROL_PLANE_IMAGE_DIGEST}" =~ ^sha256:[0-9a-f]{64}$ ]] || \
[[ ! "${HELM_CHART_DIGEST}" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "::error::Verified public container and Helm chart digests are required before recovered activation."
exit 1
fi
jq -n \
--arg tag "${TAG}" \
--arg target_commitish "${EXPECTED_COMMIT}" \
--arg release_id "${RELEASE_ID}" \
--arg source_release_run_id "${SOURCE_RELEASE_RUN_ID}" \
--arg convergence_run_id "${CONVERGENCE_RUN_ID}" \
--arg r2_prefix "${R2_PREFIX}" \
--arg activation_recovery_run_id "${GITHUB_RUN_ID}" \
--arg server_image_digest "${SERVER_IMAGE_DIGEST}" \
--arg control_plane_image_digest "${CONTROL_PLANE_IMAGE_DIGEST}" \
--arg helm_chart_digest "${HELM_CHART_DIGEST}" \
'{
schema_version: 1,
tag: $tag,
target_commitish: $target_commitish,
release_id: $release_id,
source_release_run_id: $source_release_run_id,
convergence_run_id: $convergence_run_id,
r2_prefix: $r2_prefix,
activation_recovery_run_id: $activation_recovery_run_id,
server_image_digest: $server_image_digest,
control_plane_image_digest: $control_plane_image_digest,
helm_chart_digest: $helm_chart_digest
}' > "${activation_marker}"
gh release upload "${TAG}" \
"${activation_marker}" --clobber \
--repo "${GITHUB_REPOSITORY}"
marker_staged=true
gh api "repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" > "${release_json}"
expected_marker_digest="sha256:$(sha256sum "${activation_marker}" | awk '{print $1}')"
actual_marker_digest="$(
jq -er \
'[.assets[] | select(.name == "release-activation.json" and .state == "uploaded")] |
if length == 1 then .[0].digest else error("expected exactly one activation marker") end |
select(test("^sha256:[0-9a-f]{64}$"))' \
"${release_json}"
)"
if [ "${actual_marker_digest}" != "${expected_marker_digest}" ]; then
echo "::error::Recovered draft activation marker digest does not match the staged bytes."
exit 1
fi
require_viable_convergence_owner
if [ -z "${IMMUTABILITY_ADMIN_TOKEN:-}" ]; then
echo "::error::WORKFLOW_PAT with repository Administration (read) is required to prove release immutability."
exit 1
fi
GH_TOKEN="${IMMUTABILITY_ADMIN_TOKEN}" \
./scripts/check-github-release-immutability.sh "${GITHUB_REPOSITORY}"
unset IMMUTABILITY_ADMIN_TOKEN
gh api "repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" \
-X PATCH --input "${publish_payload}" > "${release_json}"
activated=true
if [ "$(jq -r '.draft' "${release_json}")" != "false" ] || \
[ -z "$(jq -r '.published_at // ""' "${release_json}")" ] || \
[ "$(jq -r '.immutable // false' "${release_json}")" != "true" ]; then
echo "::error::GitHub did not publish ${TAG} as an immutable release. Enable repository release immutability before activation."
exit 1
fi
committed=true
base="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}"
for asset_name in \
checksums.txt \
install.sh \
"pulse-provider-msp-${TAG}.tar.gz" \
"pulse-${TAG}-linux-amd64.tar.gz"; do
curl -fsSL --retry 12 --retry-delay 5 --retry-all-errors \
-o /dev/null "${base}/${asset_name}"
done
curl -fsSL --retry 12 --retry-delay 5 --retry-all-errors \
-o "${verified_marker}" "${base}/release-activation.json"
./scripts/verify-github-release-integrity.sh \
"${TAG}" "${GITHUB_REPOSITORY}" "${RELEASE_ID}" "${EXPECTED_COMMIT}" \
"${verified_marker}"
jq -e \
--arg tag "${TAG}" \
--arg target_commitish "${EXPECTED_COMMIT}" \
--arg release_id "${RELEASE_ID}" \
--arg source_release_run_id "${SOURCE_RELEASE_RUN_ID}" \
--arg convergence_run_id "${CONVERGENCE_RUN_ID}" \
--arg r2_prefix "${R2_PREFIX}" \
--arg activation_recovery_run_id "${GITHUB_RUN_ID}" \
--arg server_image_digest "${SERVER_IMAGE_DIGEST}" \
--arg control_plane_image_digest "${CONTROL_PLANE_IMAGE_DIGEST}" \
--arg helm_chart_digest "${HELM_CHART_DIGEST}" \
'.schema_version == 1 and .tag == $tag and
.target_commitish == $target_commitish and .release_id == $release_id and
.source_release_run_id == $source_release_run_id and
.convergence_run_id == $convergence_run_id and .r2_prefix == $r2_prefix and
.activation_recovery_run_id == $activation_recovery_run_id and
.server_image_digest == $server_image_digest and
.control_plane_image_digest == $control_plane_image_digest and
.helm_chart_digest == $helm_chart_digest' \
"${verified_marker}" >/dev/null
trap - ERR
echo "[OK] Recovered, immutably committed, and attested ${TAG}; convergence run ${CONVERGENCE_RUN_ID} owns customer rollout."