9dfa06ffee
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled
Signed-off-by: cls_宁波本机 <908705107@qq.com>
87 lines
3.6 KiB
Bash
87 lines
3.6 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
: "${PR_HEAD_SHA:?}"
|
|
: "${MERGE_SHA:?}"
|
|
: "${MERGED_AT:?}"
|
|
: "${VERSION:?}"
|
|
: "${PR_NUMBER:?}"
|
|
: "${GH_TOKEN:?}"
|
|
|
|
# Keep this list aligned with the main ruleset. Producer IDs prevent a check
|
|
# with a copied display name from authorizing a release. Every current required
|
|
# gate is a check run; add explicit legacy-status verification before introducing
|
|
# any required context that reports only through the commit-status API.
|
|
required_checks=(
|
|
"Desktop E2E Integration:15368"
|
|
"Desktop:15368"
|
|
"Rust Lint:15368"
|
|
"Security:15368"
|
|
"Unit Tests:15368"
|
|
"Windows Rust (x86_64-pc-windows-msvc):15368"
|
|
"Mobile:15368"
|
|
"Web:15368"
|
|
"Backend Integration (relay e2e):15368"
|
|
"Desktop E2E Relay:15368"
|
|
"Relay E2E:15368"
|
|
"Desktop Build (macOS):15368"
|
|
"DCO Check:1455659"
|
|
"Desktop Release Candidate:15368"
|
|
)
|
|
|
|
expected_branch="version-bump/$VERSION"
|
|
[[ "${PR_HEAD_REF:-}" == "$expected_branch" ]] || { echo "unexpected release branch" >&2; exit 1; }
|
|
[[ "${PR_BASE_REF:-}" == main ]] || { echo "desktop release must target main" >&2; exit 1; }
|
|
[[ "${PR_HEAD_REPO:-}" == "$GITHUB_REPOSITORY" ]] || { echo "desktop release must be internal" >&2; exit 1; }
|
|
|
|
# The API identity must match the closed event. Branch names are mutable and are
|
|
# never used to resolve the artifact.
|
|
pr="$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER")"
|
|
jq -e \
|
|
--arg head "$PR_HEAD_SHA" --arg head_ref "$PR_HEAD_REF" --arg head_repo "$PR_HEAD_REPO" \
|
|
--arg base "$PR_BASE_REF" --arg merge "$MERGE_SHA" --arg merged_at "$MERGED_AT" \
|
|
'.merged == true and .head.sha == $head and .head.ref == $head_ref and
|
|
.head.repo.full_name == $head_repo and .base.ref == $base and
|
|
.merge_commit_sha == $merge and .merged_at == $merged_at' <<<"$pr" >/dev/null || {
|
|
echo "pull request API identity does not match the closed merge event" >&2
|
|
exit 1
|
|
}
|
|
|
|
# Pin trusted verifier code from the candidate's frozen base, not from the
|
|
# candidate or its squash. A release PR cannot alter the code that validates it.
|
|
git fetch origin main --no-tags
|
|
git fetch origin "$PR_HEAD_SHA" --no-tags
|
|
candidate_parents="$(git show -s --format=%P "$PR_HEAD_SHA")"
|
|
[[ "$candidate_parents" =~ ^[0-9a-f]{40}$ ]] || {
|
|
echo "desktop candidate must have exactly one parent before validation" >&2
|
|
exit 1
|
|
}
|
|
git merge-base --is-ancestor "$candidate_parents" origin/main || {
|
|
echo "desktop candidate base is not protected main history" >&2
|
|
exit 1
|
|
}
|
|
verifier_dir="$(mktemp -d)"
|
|
trap 'rm -rf "$verifier_dir"' EXIT
|
|
git show "$candidate_parents:scripts/desktop_release.py" > "$verifier_dir/desktop_release.py"
|
|
git show "$candidate_parents:scripts/required-check-succeeded.jq" > "$verifier_dir/required-check-succeeded.jq"
|
|
|
|
git checkout --detach "$PR_HEAD_SHA"
|
|
DESKTOP_RELEASE_ROOT="$PWD" python3 "$verifier_dir/desktop_release.py" \
|
|
validate --candidate "$PR_HEAD_SHA" --version "$VERSION" --repo "$GITHUB_REPOSITORY"
|
|
|
|
# `filter=latest` is deliberate: GitHub exposes no per-rerun creation time. A
|
|
# post-merge rerun replaces the visible attempt and fails closed below.
|
|
checks="$(gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/commits/$PR_HEAD_SHA/check-runs?filter=latest&per_page=100")"
|
|
for entry in "${required_checks[@]}"; do
|
|
required="${entry%:*}"
|
|
integration_id="${entry##*:}"
|
|
jq -e --arg name "$required" --argjson integration_id "$integration_id" \
|
|
--arg merged_at "$MERGED_AT" \
|
|
-f "$verifier_dir/required-check-succeeded.jq" <<<"$checks" >/dev/null || {
|
|
echo "trusted required check was not successful at merge: $required" >&2
|
|
exit 1
|
|
}
|
|
done
|
|
|
|
echo "verified immutable desktop candidate $PR_HEAD_SHA authorized by merged PR $PR_NUMBER"
|