Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

fix(release): fail closed on malformed release notes

rcourtman7ab605452d8f
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 334e6fd378..bfc0bd8ebe 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -182,9 +182,12 @@ jobs:
git fetch --prune origin main "${REQUIRED_BRANCH}" --tags
- RELEASE_NOTES_INPUT="$(jq -r '.inputs.release_notes // ""' "$GITHUB_EVENT_PATH")"
NOTES_FILE="$(mktemp)"
- printf '%s\n' "$RELEASE_NOTES_INPUT" > "$NOTES_FILE"
+ if ! jq -er '.inputs.release_notes | select(type == "string" and length > 0)' \
+ "$GITHUB_EVENT_PATH" > "$NOTES_FILE"; then
+ echo "::error::release_notes must be a non-empty Markdown string"
+ exit 1
+ fi
HELPER_ARGS=(
--version "${VERSION}"
@@ -697,17 +700,13 @@ jobs:
- name: Prepare release notes
id: generate_notes
run: |
+ set -euo pipefail
VERSION="${{ needs.prepare.outputs.version }}"
- RELEASE_NOTES_INPUT=$(jq -r '.inputs.release_notes // ""' "$GITHUB_EVENT_PATH" 2>/dev/null || echo "")
-
NOTES_FILE=$(mktemp)
-
- if [ -n "$RELEASE_NOTES_INPUT" ]; then
- printf "%s\n" "$RELEASE_NOTES_INPUT" > "$NOTES_FILE"
- else
- echo "# Pulse v${VERSION} Release Notes" > "$NOTES_FILE"
- echo "" >> "$NOTES_FILE"
- echo "See commit history for changes." >> "$NOTES_FILE"
+ if ! jq -er '.inputs.release_notes | select(type == "string" and length > 0)' \
+ "$GITHUB_EVENT_PATH" > "$NOTES_FILE"; then
+ echo "::error::release_notes must be a non-empty Markdown string"
+ exit 1
fi
RENDERED_NOTES_FILE=$(mktemp)
@@ -795,6 +794,7 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
+ set -euo pipefail
TAG="${{ needs.prepare.outputs.tag }}"
NOTES_FILE="${{ steps.generate_notes.outputs.notes_file }}"
IS_PRERELEASE="${{ needs.prepare.outputs.is_prerelease }}"
@@ -804,41 +804,51 @@ jobs:
RELEASE_URL="${{ steps.existing_release.outputs.release_url }}"
IS_DRAFT="${{ steps.existing_release.outputs.release_is_draft }}"
PUBLISHED_AT="${{ steps.existing_release.outputs.release_published_at }}"
+ RELEASE_PAYLOAD=$(mktemp)
+ RELEASE_JSON_FILE=$(mktemp)
+ ACTUAL_BODY_FILE=$(mktemp)
+
+ jq -n \
+ --arg tag_name "$TAG" \
+ --arg target_commitish "$HEAD_SHA" \
+ --arg name "Pulse ${TAG}" \
+ --rawfile body "$NOTES_FILE" \
+ --argjson draft true \
+ --argjson prerelease "$IS_PRERELEASE" \
+ '{
+ tag_name: $tag_name,
+ target_commitish: $target_commitish,
+ name: $name,
+ body: $body,
+ draft: $draft,
+ prerelease: $prerelease
+ }' > "$RELEASE_PAYLOAD"
if [ -n "$RELEASE_ID" ]; then
if [ "$IS_DRAFT" = "true" ] && [ -z "$PUBLISHED_AT" ]; then
echo "Updating existing draft release for ${TAG}"
gh api "repos/${{ github.repository }}/releases/${RELEASE_ID}" \
-X PATCH \
- -F tag_name="${TAG}" \
- -F target_commitish="${HEAD_SHA}" \
- -F name="Pulse ${TAG}" \
- -F body="$(cat "$NOTES_FILE")" \
- -F draft=true \
- -F prerelease=${IS_PRERELEASE} > /dev/null
+ --input "$RELEASE_PAYLOAD" > "$RELEASE_JSON_FILE"
else
echo "::error::Published release already exists for ${TAG}."
exit 1
fi
else
echo "Creating draft release for ${TAG}..."
- RELEASE_JSON=$(gh api "repos/${{ github.repository }}/releases" \
+ gh api "repos/${{ github.repository }}/releases" \
-X POST \
- -F tag_name="${TAG}" \
- -F target_commitish="${HEAD_SHA}" \
- -F name="Pulse ${TAG}" \
- -F body="$(cat "$NOTES_FILE")" \
- -F draft=true \
- -F prerelease=${IS_PRERELEASE})
-
- RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
- RELEASE_URL=$(echo "$RELEASE_JSON" | jq -r '.html_url')
+ --input "$RELEASE_PAYLOAD" > "$RELEASE_JSON_FILE"
+
+ RELEASE_ID=$(jq -r '.id' "$RELEASE_JSON_FILE")
+ RELEASE_URL=$(jq -r '.html_url' "$RELEASE_JSON_FILE")
fi
- RELEASE_JSON=$(gh api "repos/${{ github.repository }}/releases/${RELEASE_ID}")
- ACTUAL_RELEASE_TAG=$(echo "$RELEASE_JSON" | jq -r '.tag_name // empty')
- ACTUAL_TARGET_COMMITISH=$(echo "$RELEASE_JSON" | jq -r '.target_commitish // empty')
- RELEASE_URL=$(echo "$RELEASE_JSON" | jq -r '.html_url')
+ gh api "repos/${{ github.repository }}/releases/${RELEASE_ID}" > "$RELEASE_JSON_FILE"
+ ACTUAL_RELEASE_TAG=$(jq -r '.tag_name // empty' "$RELEASE_JSON_FILE")
+ ACTUAL_TARGET_COMMITISH=$(jq -r '.target_commitish // empty' "$RELEASE_JSON_FILE")
+ RELEASE_URL=$(jq -r '.html_url' "$RELEASE_JSON_FILE")
+ jq -r '.body // ""' "$RELEASE_JSON_FILE" > "$ACTUAL_BODY_FILE"
if [ "$ACTUAL_RELEASE_TAG" != "$TAG" ]; then
echo "::error::Draft release ${RELEASE_ID} is bound to tag ${ACTUAL_RELEASE_TAG}, expected ${TAG}."
@@ -850,7 +860,12 @@ jobs:
exit 1
fi
- rm -f "$NOTES_FILE"
+ python3 scripts/release_control/render_release_body.py \
+ --version "${{ needs.prepare.outputs.version }}" \
+ --validate-body-file "$ACTUAL_BODY_FILE" \
+ --expected-body-file "$NOTES_FILE"
+
+ rm -f "$NOTES_FILE" "$RELEASE_PAYLOAD" "$RELEASE_JSON_FILE" "$ACTUAL_BODY_FILE"
echo "release_url=${RELEASE_URL}" >> $GITHUB_OUTPUT
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT
diff --git a/.github/workflows/validate-release-assets.yml b/.github/workflows/validate-release-assets.yml
index 40e15a4f20..bb668d07c4 100644
--- a/.github/workflows/validate-release-assets.yml
+++ b/.github/workflows/validate-release-assets.yml
@@ -119,15 +119,78 @@ jobs:
cat context.env >> "$GITHUB_OUTPUT"
cat context.env
+ - name: Validate release body integrity
+ id: body_integrity
+ if: steps.context.outputs.should_run == 'true'
+ continue-on-error: true
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+ RELEASE_JSON_FILE=$(mktemp)
+ RELEASE_BODY_FILE=$(mktemp)
+ gh api "repos/${{ github.repository }}/releases/${{ steps.context.outputs.release_id }}" \
+ > "$RELEASE_JSON_FILE"
+ jq -r '.body // ""' "$RELEASE_JSON_FILE" > "$RELEASE_BODY_FILE"
+ python3 scripts/release_control/render_release_body.py \
+ --version "${{ steps.context.outputs.version }}" \
+ --validate-body-file "$RELEASE_BODY_FILE"
+
+ - name: Quarantine malformed release body
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'failure'
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+ PATCH_PAYLOAD=$(mktemp)
+ RELEASE_JSON_FILE=$(mktemp)
+
+ jq -n \
+ --arg tag "${{ steps.context.outputs.tag }}" \
+ --arg target_commitish "${{ steps.context.outputs.target_commitish }}" \
+ '{draft: true, tag_name: $tag, target_commitish: $target_commitish}' \
+ > "$PATCH_PAYLOAD"
+
+ gh api "repos/${{ github.repository }}/releases/${{ steps.context.outputs.release_id }}" \
+ -X PATCH \
+ --input "$PATCH_PAYLOAD" > "$RELEASE_JSON_FILE"
+
+ ACTUAL_RELEASE_TAG=$(jq -r '.tag_name // empty' "$RELEASE_JSON_FILE")
+ ACTUAL_TARGET_COMMITISH=$(jq -r '.target_commitish // empty' "$RELEASE_JSON_FILE")
+ ACTUAL_DRAFT=$(jq -r '.draft // false' "$RELEASE_JSON_FILE")
+ if [ "$ACTUAL_RELEASE_TAG" != "${{ steps.context.outputs.tag }}" ]; then
+ echo "::error::Body-integrity quarantine detached release tag ${ACTUAL_RELEASE_TAG}; expected ${{ steps.context.outputs.tag }}."
+ exit 1
+ fi
+ if [ "$ACTUAL_TARGET_COMMITISH" != "${{ steps.context.outputs.target_commitish }}" ]; then
+ echo "::error::Body-integrity quarantine changed target_commitish ${ACTUAL_TARGET_COMMITISH}; expected ${{ steps.context.outputs.target_commitish }}."
+ exit 1
+ fi
+ if [ "$ACTUAL_DRAFT" != "true" ]; then
+ echo "::error::Malformed release body was not quarantined as a draft."
+ exit 1
+ fi
+
+ curl --fail-with-body --silent --show-error -X POST \
+ -H "Authorization: token $GH_TOKEN" \
+ -H "Accept: application/vnd.github+json" \
+ "https://api.github.com/repos/${{ github.repository }}/statuses/${{ steps.context.outputs.target_commitish }}" \
+ -d '{
+ "state": "failure",
+ "target_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
+ "description": "Release body integrity failed",
+ "context": "Release Asset Validation"
+ }'
+
- name: Download immutable candidate manifest
- if: steps.context.outputs.should_run == 'true' && inputs.candidate_manifest_artifact != ''
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success' && inputs.candidate_manifest_artifact != ''
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ inputs.candidate_manifest_artifact }}
path: release-candidate-manifest
- name: Fetch release asset metadata
- if: steps.context.outputs.should_run == 'true'
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
@@ -143,7 +206,7 @@ jobs:
echo "Found ${count} published release assets."
- name: Download all release assets for legacy validation
- if: steps.context.outputs.should_run == 'true' && inputs.candidate_manifest_artifact == ''
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success' && inputs.candidate_manifest_artifact == ''
id: download
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -189,11 +252,11 @@ jobs:
ls -lh
- name: Install Docker
- if: steps.context.outputs.should_run == 'true' && inputs.candidate_manifest_artifact == ''
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success' && inputs.candidate_manifest_artifact == ''
run: docker --version
- name: Pull Docker image (with retry logic)
- if: steps.context.outputs.should_run == 'true' && inputs.candidate_manifest_artifact == ''
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success' && inputs.candidate_manifest_artifact == ''
id: docker
continue-on-error: true
run: |
@@ -235,7 +298,7 @@ jobs:
echo "image_available=false" >> $GITHUB_OUTPUT
- name: Run validation script
- if: steps.context.outputs.should_run == 'true'
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success'
id: validate
env:
CANDIDATE_MANIFEST_ARTIFACT: ${{ inputs.candidate_manifest_artifact }}
@@ -282,7 +345,7 @@ jobs:
exit $VALIDATION_EXIT_CODE
- name: Set commit status - Success
- if: steps.context.outputs.should_run == 'true' && steps.validate.outputs.validation_passed == 'true'
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success' && steps.validate.outputs.validation_passed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
@@ -298,10 +361,11 @@ jobs:
}'
- name: Update release body - Success
- if: steps.context.outputs.should_run == 'true' && steps.validate.outputs.validation_passed == 'true'
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success' && steps.validate.outputs.validation_passed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
+ set -euo pipefail
echo "✅ Validation passed - updating release description"
INITIAL_STATE="${{ steps.context.outputs.draft }}"
@@ -315,11 +379,21 @@ jobs:
INTRO_LINE="Assets were revalidated after publication due to a release edit."
fi
- CURRENT_BODY=$(curl -s -H "Authorization: token $GH_TOKEN" \
- "https://api.github.com/repos/${{ github.repository }}/releases/${{ steps.context.outputs.release_id }}" \
- | jq -r '.body // ""')
-
- CURRENT_BODY=$(echo "$CURRENT_BODY" | sed '/<!-- VALIDATION_STATUS_START -->/,/<!-- VALIDATION_STATUS_END -->/d')
+ CURRENT_RELEASE_JSON=$(mktemp)
+ CURRENT_BODY_FILE=$(mktemp)
+ CLEAN_BODY_FILE=$(mktemp)
+ NEW_BODY_FILE=$(mktemp)
+ PATCH_PAYLOAD=$(mktemp)
+ PATCH_RESPONSE=$(mktemp)
+ PATCHED_BODY_FILE=$(mktemp)
+
+ gh api "repos/${{ github.repository }}/releases/${{ steps.context.outputs.release_id }}" \
+ > "$CURRENT_RELEASE_JSON"
+ jq -r '.body // ""' "$CURRENT_RELEASE_JSON" > "$CURRENT_BODY_FILE"
+ python3 scripts/release_control/render_release_body.py \
+ --version "${{ steps.context.outputs.version }}" \
+ --validate-body-file "$CURRENT_BODY_FILE" \
+ --output "$CLEAN_BODY_FILE"
read -r -d '' VALIDATION_BLOCK <<'EOF' || true
<!-- VALIDATION_STATUS_START -->
@@ -346,22 +420,23 @@ jobs:
VALIDATION_BLOCK="${VALIDATION_BLOCK//TIMESTAMP_PLACEHOLDER/$(date -u +"%Y-%m-%d %H:%M:%S UTC")}"
VALIDATION_BLOCK="${VALIDATION_BLOCK//WORKFLOW_LINK_PLACEHOLDER/[${{ github.workflow }} #${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})}"
- NEW_BODY="$VALIDATION_BLOCK
-
- $CURRENT_BODY"
+ printf '%s\n\n' "$VALIDATION_BLOCK" > "$NEW_BODY_FILE"
+ cat "$CLEAN_BODY_FILE" >> "$NEW_BODY_FILE"
+ jq -n \
+ --rawfile body "$NEW_BODY_FILE" \
+ --arg tag "${{ steps.context.outputs.tag }}" \
+ --arg target_commitish "${{ steps.context.outputs.target_commitish }}" \
+ '{body: $body, tag_name: $tag, target_commitish: $target_commitish}' \
+ > "$PATCH_PAYLOAD"
- RELEASE_JSON=$(curl --fail-with-body --silent --show-error -X PATCH \
+ curl --fail-with-body --silent --show-error -X PATCH \
-H "Authorization: token $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/${{ steps.context.outputs.release_id }}" \
- -d "$(jq -n \
- --arg body "$NEW_BODY" \
- --arg tag "${{ steps.context.outputs.tag }}" \
- --arg target_commitish "${{ steps.context.outputs.target_commitish }}" \
- '{body: $body, tag_name: $tag, target_commitish: $target_commitish}')")
-
- ACTUAL_RELEASE_TAG=$(echo "$RELEASE_JSON" | jq -r '.tag_name // empty')
- ACTUAL_TARGET_COMMITISH=$(echo "$RELEASE_JSON" | jq -r '.target_commitish // empty')
+ --data-binary "@$PATCH_PAYLOAD" > "$PATCH_RESPONSE"
+
+ ACTUAL_RELEASE_TAG=$(jq -r '.tag_name // empty' "$PATCH_RESPONSE")
+ ACTUAL_TARGET_COMMITISH=$(jq -r '.target_commitish // empty' "$PATCH_RESPONSE")
if [ "$ACTUAL_RELEASE_TAG" != "${{ steps.context.outputs.tag }}" ]; then
echo "::error::Validation release body update detached release tag ${ACTUAL_RELEASE_TAG}; expected ${{ steps.context.outputs.tag }}."
exit 1
@@ -370,9 +445,14 @@ jobs:
echo "::error::Validation release body update changed target_commitish ${ACTUAL_TARGET_COMMITISH}; expected ${{ steps.context.outputs.target_commitish }}."
exit 1
fi
+ jq -r '.body // ""' "$PATCH_RESPONSE" > "$PATCHED_BODY_FILE"
+ python3 scripts/release_control/render_release_body.py \
+ --version "${{ steps.context.outputs.version }}" \
+ --validate-body-file "$PATCHED_BODY_FILE" \
+ --expected-body-file "$CLEAN_BODY_FILE"
- name: Set commit status - Failure
- if: steps.context.outputs.should_run == 'true' && (failure() || steps.validate.outputs.validation_passed == 'false')
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success' && (failure() || steps.validate.outputs.validation_passed == 'false')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
@@ -388,7 +468,7 @@ jobs:
}'
- name: Delete all release assets on failure
- if: steps.context.outputs.should_run == 'true' && (failure() || steps.validate.outputs.validation_passed == 'false')
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success' && (failure() || steps.validate.outputs.validation_passed == 'false')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
@@ -438,10 +518,11 @@ jobs:
fi
- name: Update release body - Failure
- if: steps.context.outputs.should_run == 'true' && (failure() || steps.validate.outputs.validation_passed == 'false')
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success' && (failure() || steps.validate.outputs.validation_passed == 'false')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
+ set -euo pipefail
echo "❌ Validation failed - updating release description"
INITIAL_STATE="${{ steps.context.outputs.draft }}"
@@ -455,11 +536,21 @@ jobs:
INTRO_LINE="A published release edit introduced invalid assets. The release has been reverted to draft and assets were deleted to stop further downloads."
fi
- CURRENT_BODY=$(curl -s -H "Authorization: token $GH_TOKEN" \
- "https://api.github.com/repos/${{ github.repository }}/releases/${{ steps.context.outputs.release_id }}" \
- | jq -r '.body // ""')
-
- CURRENT_BODY=$(echo "$CURRENT_BODY" | sed '/<!-- VALIDATION_STATUS_START -->/,/<!-- VALIDATION_STATUS_END -->/d')
+ CURRENT_RELEASE_JSON=$(mktemp)
+ CURRENT_BODY_FILE=$(mktemp)
+ CLEAN_BODY_FILE=$(mktemp)
+ NEW_BODY_FILE=$(mktemp)
+ PATCH_PAYLOAD=$(mktemp)
+ PATCH_RESPONSE=$(mktemp)
+ PATCHED_BODY_FILE=$(mktemp)
+
+ gh api "repos/${{ github.repository }}/releases/${{ steps.context.outputs.release_id }}" \
+ > "$CURRENT_RELEASE_JSON"
+ jq -r '.body // ""' "$CURRENT_RELEASE_JSON" > "$CURRENT_BODY_FILE"
+ python3 scripts/release_control/render_release_body.py \
+ --version "${{ steps.context.outputs.version }}" \
+ --validate-body-file "$CURRENT_BODY_FILE" \
+ --output "$CLEAN_BODY_FILE"
VALIDATION_OUTPUT="${{ steps.validate.outputs.VALIDATION_OUTPUT }}"
if [ -n "$VALIDATION_OUTPUT" ]; then
@@ -509,22 +600,23 @@ jobs:
VALIDATION_BLOCK="${VALIDATION_BLOCK//WORKFLOW_URL_PLACEHOLDER/${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}}"
VALIDATION_BLOCK="${VALIDATION_BLOCK//ERRORS_PLACEHOLDER/$ERRORS}"
- NEW_BODY="$VALIDATION_BLOCK
+ printf '%s\n\n' "$VALIDATION_BLOCK" > "$NEW_BODY_FILE"
+ cat "$CLEAN_BODY_FILE" >> "$NEW_BODY_FILE"
+ jq -n \
+ --rawfile body "$NEW_BODY_FILE" \
+ --arg tag "${{ steps.context.outputs.tag }}" \
+ --arg target_commitish "${{ steps.context.outputs.target_commitish }}" \
+ '{body: $body, tag_name: $tag, target_commitish: $target_commitish}' \
+ > "$PATCH_PAYLOAD"
- $CURRENT_BODY"
-
- RELEASE_JSON=$(curl --fail-with-body --silent --show-error -X PATCH \
+ curl --fail-with-body --silent --show-error -X PATCH \
-H "Authorization: token $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/${{ steps.context.outputs.release_id }}" \
- -d "$(jq -n \
- --arg body "$NEW_BODY" \
- --arg tag "${{ steps.context.outputs.tag }}" \
- --arg target_commitish "${{ steps.context.outputs.target_commitish }}" \
- '{body: $body, tag_name: $tag, target_commitish: $target_commitish}')")
-
- ACTUAL_RELEASE_TAG=$(echo "$RELEASE_JSON" | jq -r '.tag_name // empty')
- ACTUAL_TARGET_COMMITISH=$(echo "$RELEASE_JSON" | jq -r '.target_commitish // empty')
+ --data-binary "@$PATCH_PAYLOAD" > "$PATCH_RESPONSE"
+
+ ACTUAL_RELEASE_TAG=$(jq -r '.tag_name // empty' "$PATCH_RESPONSE")
+ ACTUAL_TARGET_COMMITISH=$(jq -r '.target_commitish // empty' "$PATCH_RESPONSE")
if [ "$ACTUAL_RELEASE_TAG" != "${{ steps.context.outputs.tag }}" ]; then
echo "::error::Validation failure body update detached release tag ${ACTUAL_RELEASE_TAG}; expected ${{ steps.context.outputs.tag }}."
exit 1
@@ -533,9 +625,20 @@ jobs:
echo "::error::Validation failure body update changed target_commitish ${ACTUAL_TARGET_COMMITISH}; expected ${{ steps.context.outputs.target_commitish }}."
exit 1
fi
+ jq -r '.body // ""' "$PATCH_RESPONSE" > "$PATCHED_BODY_FILE"
+ python3 scripts/release_control/render_release_body.py \
+ --version "${{ steps.context.outputs.version }}" \
+ --validate-body-file "$PATCHED_BODY_FILE" \
+ --expected-body-file "$CLEAN_BODY_FILE"
- name: Fail the workflow
- if: steps.context.outputs.should_run == 'true' && (failure() || steps.validate.outputs.validation_passed == 'false')
+ if: steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'success' && (failure() || steps.validate.outputs.validation_passed == 'false')
run: |
echo "::error::Release asset validation failed. All assets have been deleted."
exit 1
+
+ - name: Fail malformed release body
+ if: always() && steps.context.outputs.should_run == 'true' && steps.body_integrity.outcome == 'failure'
+ run: |
+ echo "::error::Release body integrity failed. The release was quarantined as a draft without deleting its assets."
+ exit 1
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index aa52c39c58..48f76fc639 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -1288,6 +1288,15 @@ When operators pass draft packet markdown to `.github/workflows/create-release.y
the workflow must sanitize draft-only framing and append the standardized
installation and promotion metadata sections exactly once, rather than trusting
raw packet text to already be publish-safe.
+Release-note transport is file-backed and fail-closed: operator helpers must
+send the Markdown through JSON input rather than multiline form-field
+substitution, the renderer must reject missing standalone title/section
+structure before any tag or draft mutation, and draft creation must compare
+GitHub's stored body with the exact rendered file before asset upload.
+`validate-release-assets.yml` must repeat the structural check before validating
+assets, preserve the authored body through validation-status edits, and compare
+the API response with the pre-edit body. A malformed edited body is quarantined
+as a draft without deleting otherwise valid assets.
That same frontend-release boundary also owns shared header-composition proof.
`.github/workflows/release-dry-run.yml` and `.github/workflows/create-release.yml`
must both run the same `lint:headers` audit so a branch that would be rejected
diff --git a/docs/releases/V6_PRERELEASE_RUNBOOK.md b/docs/releases/V6_PRERELEASE_RUNBOOK.md
index 36b16cb56a..c07322ffdc 100644
--- a/docs/releases/V6_PRERELEASE_RUNBOOK.md
+++ b/docs/releases/V6_PRERELEASE_RUNBOOK.md
@@ -111,28 +111,37 @@ git push origin pulse/v6-release
- `version`: `RC_VERSION`
- optional `note`
-3. Create draft prerelease:
- - Run workflow: `Pulse Release Pipeline`
- - Ref: `pulse/v6-release`
- - Inputs:
- - `version`: `RC_VERSION`
- - `release_notes`: markdown text from the current release-notes packet
- - `draft_only`: `true`
+3. Dispatch through the canonical file-backed helper:
+
+ ```bash
+ RELEASE_NOTES_FILE="docs/releases/RELEASE_NOTES_v${RC_VERSION}.md"
+ ./scripts/trigger-release.sh "$RC_VERSION" "$RELEASE_NOTES_FILE"
+ ```
+
- Keep the current release-notes, changelog, and operator-support packet in
sync. Do not update only one of them and treat the packet as ready.
-
-4. Validate draft outputs:
+ - Do not paste multiline release notes into the GitHub workflow form as the
+ normal operator path. The helper sends the file through JSON transport so
+ line breaks are preserved.
+ - The workflow independently rejects flattened Markdown before it creates a
+ tag or draft, then compares GitHub's stored body byte-for-byte with the
+ rendered file before asset upload.
+
+4. Validate the integrated release result:
+ - Treat `Definitive Release Verdict` as the release result.
- Confirm assets exist and checksums match.
- - Confirm GitHub release is marked prerelease.
+ - Confirm GitHub marks the release as a prerelease.
+ - Confirm the rendered release body retains its standalone headings, lists,
+ code fences, Installation section, and Promotion Metadata section.
- Smoke install on a test host/container.
-5. Publish prerelease:
- - Re-run `Pulse Release Pipeline` on `pulse/v6-release`
- - Same `version` and release-notes packet
- - `draft_only`: `false`
+5. Retry an unpublished draft only through the same helper:
+ - Use the same version and exact release-notes file.
- Existing unpublished draft releases for the same tag are updated in place
- and their tag is retargeted to the current governed `pulse/v6-release`
- head automatically. Do not delete the tag manually just to retry publish.
+ and their tag is retargeted to the current governed release-line head
+ automatically. Do not delete the tag manually just to retry publication.
+ - A malformed body edit is quarantined back to draft without deleting valid
+ assets; correct the notes file and rerun the canonical helper.
- Historical prerelease publications used a separate preview demo runtime
while v5 remained the public stable demo.
- Prerelease public demo deployment is retired after v6 GA; future
diff --git a/scripts/installtests/build_release_assets_test.go b/scripts/installtests/build_release_assets_test.go
index 54be3de73a..5e2257eb16 100644
--- a/scripts/installtests/build_release_assets_test.go
+++ b/scripts/installtests/build_release_assets_test.go
@@ -153,7 +153,9 @@ func TestCreateReleaseUploadsPowerShellInstaller(t *testing.T) {
`subject-path: release/*`,
`gh api "repos/${{ github.repository }}/releases?per_page=100" --paginate`,
`git push origin "refs/tags/${TAG}" --force`,
- `-F target_commitish="${HEAD_SHA}"`,
+ `--rawfile body "$NOTES_FILE"`,
+ `--input "$RELEASE_PAYLOAD"`,
+ `--expected-body-file "$NOTES_FILE"`,
`historical_asset_backfill_only=${HISTORICAL_ASSET_BACKFILL_ONLY}`,
`if: ${{ always() && needs.prepare.result == 'success' && needs.build_release_candidate.result == 'success' && needs.create_release.result == 'success' && needs.prepare.outputs.historical_asset_backfill_only != 'true' }}`,
`candidate_manifest_artifact: ${{ needs.build_release_candidate.outputs.manifest_artifact_name }}`,
@@ -161,8 +163,8 @@ func TestCreateReleaseUploadsPowerShellInstaller(t *testing.T) {
`permissions:`,
`issues: write`,
`statuses: write`,
- `ACTUAL_RELEASE_TAG=$(echo "$RELEASE_JSON" | jq -r '.tag_name // empty')`,
- `ACTUAL_TARGET_COMMITISH=$(echo "$RELEASE_JSON" | jq -r '.target_commitish // empty')`,
+ `ACTUAL_RELEASE_TAG=$(jq -r '.tag_name // empty' "$RELEASE_JSON_FILE")`,
+ `ACTUAL_TARGET_COMMITISH=$(jq -r '.target_commitish // empty' "$RELEASE_JSON_FILE")`,
`Draft release ${RELEASE_ID} is bound to tag ${ACTUAL_RELEASE_TAG}, expected ${TAG}.`,
`Draft release ${RELEASE_ID} target_commitish is ${ACTUAL_TARGET_COMMITISH}, expected ${HEAD_SHA}.`,
`./scripts/backfill-release-assets.sh --tag "${{ needs.prepare.outputs.tag }}" --repo "${{ github.repository }}"`,
@@ -237,6 +239,11 @@ func TestCreateReleaseUploadsPowerShellInstaller(t *testing.T) {
`{draft: true, tag_name: $tag, target_commitish: $target_commitish}`,
`Validation release body update detached release tag`,
`Validation release body update changed target_commitish`,
+ `Validate release body integrity`,
+ `--validate-body-file "$RELEASE_BODY_FILE"`,
+ `--expected-body-file "$CLEAN_BODY_FILE"`,
+ `Quarantine malformed release body`,
+ `The release was quarantined as a draft without deleting its assets.`,
}
for _, needle := range validationRequired {
if !strings.Contains(validationWorkflow, needle) {
diff --git a/scripts/release_control/release_promotion_policy_test.py b/scripts/release_control/release_promotion_policy_test.py
index 3aa19b2f2c..58c1248a25 100644
--- a/scripts/release_control/release_promotion_policy_test.py
+++ b/scripts/release_control/release_promotion_policy_test.py
@@ -537,6 +537,7 @@ class ReleasePromotionPolicyTest(unittest.TestCase):
candidate_workflow = read(".github/workflows/build-release-candidate.yml")
release_validator = read("scripts/validate-release.sh")
helper = read("scripts/trigger-release.sh")
+ stable_patch_helper = read("scripts/trigger-stable-patch.sh")
renderer = read("scripts/release_control/render_release_body.py")
policy = read("docs/release-control/v6/internal/RELEASE_PROMOTION_POLICY.md")
source_of_truth = read("docs/release-control/v6/internal/SOURCE_OF_TRUTH.md")
@@ -558,6 +559,13 @@ class ReleasePromotionPolicyTest(unittest.TestCase):
self.assertIn("hardcoded `image: rcourtman/pulse:...`", normalize_ws(contract))
self.assertIn("Resolving governed promotion metadata...", helper)
self.assertIn("--release-notes-file \"$NOTES_FILE\"", helper)
+ self.assertIn("--validate-notes-file \"$NOTES_FILE\"", helper)
+ self.assertIn("--rawfile release_notes \"$NOTES_FILE\"", helper)
+ self.assertIn("gh workflow run create-release.yml --ref \"$CURRENT_BRANCH\" --json", helper)
+ self.assertNotIn('-f release_notes="$(cat "$NOTES_FILE")"', helper)
+ self.assertIn("--validate-notes-file \"$NOTES_FILE\"", stable_patch_helper)
+ self.assertIn("--rawfile release_notes \"$NOTES_FILE\"", stable_patch_helper)
+ self.assertIn("gh workflow run create-release.yml --ref \"$CURRENT_BRANCH\" --json", stable_patch_helper)
self.assertIn("blank for hotfix with no RC lineage", helper)
self.assertIn('if [ -z "$PROMOTED_FROM_TAG" ] && [ "$HOTFIX_EXCEPTION" != "true" ]; then', helper)
self.assertIn("control_plane.py --branch-for-version", content)
@@ -572,6 +580,9 @@ class ReleasePromotionPolicyTest(unittest.TestCase):
self.assertNotIn('gh workflow run publish-docker.yml --ref "${REQUIRED_BRANCH}"', content)
self.assertNotIn('gh workflow run update-demo-server.yml --ref "${REQUIRED_BRANCH}"', content)
self.assertIn("sanitize_release_notes", renderer)
+ self.assertIn("validate_release_notes_shape", renderer)
+ self.assertIn("validate_release_body_shape", renderer)
+ self.assertIn("GitHub's stored release body does not exactly match", renderer)
self.assertIn("Do not treat this as published", renderer)
self.assertIn("_DRAFT.md", renderer)
self.assertIn("rollback target and exact reinstall command recorded", policy)
@@ -590,7 +601,9 @@ class ReleasePromotionPolicyTest(unittest.TestCase):
self.assertIn('gh api "repos/${{ github.repository }}/releases?per_page=100" --paginate', content)
self.assertIn('git push origin "refs/tags/${TAG}" --force', content)
self.assertIn('Retargeting existing draft tag ${TAG}', content)
- self.assertIn('-F target_commitish="${HEAD_SHA}"', content)
+ self.assertIn('--rawfile body "$NOTES_FILE"', content)
+ self.assertIn('--input "$RELEASE_PAYLOAD"', content)
+ self.assertIn('--expected-body-file "$NOTES_FILE"', content)
self.assertIn('historical_asset_backfill_only=${HISTORICAL_ASSET_BACKFILL_ONLY}', content)
self.assertIn(
"if: ${{ always() && needs.prepare.result == 'success' && needs.build_release_candidate.result == 'success' && needs.create_release.result == 'success' && needs.prepare.outputs.historical_asset_backfill_only != 'true' }}",
@@ -610,9 +623,19 @@ class ReleasePromotionPolicyTest(unittest.TestCase):
self.assertIn("{draft: true, tag_name: $tag, target_commitish: $target_commitish}", validation_workflow)
self.assertIn("Validation release body update detached release tag", validation_workflow)
self.assertIn("Validation release body update changed target_commitish", validation_workflow)
- self.assertIn('ACTUAL_RELEASE_TAG=$(echo "$RELEASE_JSON" | jq -r \'.tag_name // empty\')', content)
+ self.assertIn("--validate-body-file \"$RELEASE_BODY_FILE\"", validation_workflow)
+ self.assertIn("--expected-body-file \"$CLEAN_BODY_FILE\"", validation_workflow)
+ self.assertIn("Quarantine malformed release body", validation_workflow)
self.assertIn(
- 'ACTUAL_TARGET_COMMITISH=$(echo "$RELEASE_JSON" | jq -r \'.target_commitish // empty\')',
+ "The release was quarantined as a draft without deleting its assets.",
+ validation_workflow,
+ )
+ self.assertIn(
+ 'ACTUAL_RELEASE_TAG=$(jq -r \'.tag_name // empty\' "$RELEASE_JSON_FILE")',
+ content,
+ )
+ self.assertIn(
+ 'ACTUAL_TARGET_COMMITISH=$(jq -r \'.target_commitish // empty\' "$RELEASE_JSON_FILE")',
content,
)
self.assertIn('./scripts/backfill-release-assets.sh --tag "${{ needs.prepare.outputs.tag }}" --repo "${{ github.repository }}"', content)
@@ -743,7 +766,7 @@ class ReleasePromotionPolicyTest(unittest.TestCase):
self.assertIn("Derived rollback command:", helper)
self.assertIn("./scripts/install.sh --version", helper)
self.assertIn("v6 GA date to publish with GA", helper)
- self.assertIn("-f ga_date", helper)
+ self.assertIn("--arg ga_date \"$GA_DATE\"", helper)
self.assertIn("Planned GA date", renderer)
self.assertIn("Planned v5 end-of-support date", renderer)
self.assertIn("Stable v6.0.0 requires v5_eos_date in YYYY-MM-DD form", resolver)
@@ -796,9 +819,17 @@ class ReleasePromotionPolicyTest(unittest.TestCase):
if rc_packet_paths_for_version(current_version) is not None:
self.assertIn(f'export RC_VERSION="{current_version}"', runbook)
self.assertIn("printf '%s\\n' \"$RC_VERSION\" > VERSION", runbook)
- self.assertIn("markdown text from the current release-notes packet", runbook)
+ self.assertIn("canonical file-backed helper", runbook)
+ self.assertIn(
+ './scripts/trigger-release.sh "$RC_VERSION" "$RELEASE_NOTES_FILE"',
+ runbook,
+ )
+ self.assertIn("Do not paste multiline release notes", runbook)
+ self.assertIn("compares GitHub's stored body byte-for-byte", runbook)
self.assertIn("Keep the current release-notes, changelog, and operator-support packet in", runbook)
self.assertIn("Published release bodies must also stay publication-safe", contract)
+ self.assertIn("Release-note transport is file-backed and fail-closed", contract)
+ self.assertIn("malformed edited body is quarantined", contract)
self.assertIn("must state the continuity impact explicitly", normalize_ws(contract))
self.assertIn(
"append the standardized installation and promotion metadata sections exactly once",
diff --git a/scripts/release_control/render_release_body.py b/scripts/release_control/render_release_body.py
index 027cab9f7c..a3b61ef566 100644
--- a/scripts/release_control/render_release_body.py
+++ b/scripts/release_control/render_release_body.py
@@ -5,13 +5,129 @@ from __future__ import annotations
import argparse
import re
+import sys
from pathlib import Path
+class ReleaseBodyIntegrityError(ValueError):
+ """Raised when release-note Markdown is not safe to publish."""
+
+
+_VALIDATION_STATUS_BLOCK_RE = re.compile(
+ r"(?:^|\n)<!-- VALIDATION_STATUS_START -->.*?"
+ r"<!-- VALIDATION_STATUS_END -->(?:\n{0,2}|$)",
+ re.DOTALL,
+)
+
+
def _normalize_newlines(text: str) -> str:
return text.replace("\r\n", "\n").replace("\r", "\n")
+def _canonical_body(text: str) -> str:
+ return _normalize_newlines(text).rstrip("\n") + "\n"
+
+
+def _find_inline_markdown_markers(text: str) -> list[str]:
+ markers: list[str] = []
+ for line_number, line in enumerate(_normalize_newlines(text).splitlines(), start=1):
+ heading_markers = re.finditer(r"#{2,6}[ \t]+\S", line)
+ if any(match.start() != 0 for match in heading_markers):
+ markers.append(f"inline heading marker on line {line_number}")
+ fence_markers = re.finditer(r"```(?:[A-Za-z0-9_-]+)?", line)
+ if any(match.start() != 0 for match in fence_markers):
+ markers.append(f"inline code-fence marker on line {line_number}")
+ return markers
+
+
+def validate_release_notes_shape(raw_text: str, version: str) -> None:
+ """Fail closed when authored release-note Markdown has lost its structure."""
+
+ text = _normalize_newlines(raw_text).strip()
+ if not text:
+ raise ReleaseBodyIntegrityError("release notes are empty")
+
+ lines = text.splitlines()
+ expected_title = re.compile(
+ rf"^# Pulse v{re.escape(version)} (?:Draft )?Release Notes$"
+ )
+ if not expected_title.fullmatch(lines[0]):
+ raise ReleaseBodyIntegrityError(
+ "the first line must be the standalone release title "
+ f"'# Pulse v{version} Release Notes' (or its Draft form)"
+ )
+
+ level_two_headings = [
+ line for line in lines if re.fullmatch(r"##[ \t]+\S.*", line)
+ ]
+ if not level_two_headings:
+ raise ReleaseBodyIntegrityError(
+ "release notes must contain at least one standalone level-two section"
+ )
+
+ inline_markers = _find_inline_markdown_markers(text)
+ if inline_markers:
+ raise ReleaseBodyIntegrityError(
+ "release notes contain flattened Markdown: " + ", ".join(inline_markers)
+ )
+
+
+def strip_validation_status_block(text: str) -> str:
+ """Remove the workflow-owned validation annotation from a release body."""
+
+ stripped = _VALIDATION_STATUS_BLOCK_RE.sub("\n", _normalize_newlines(text), count=1)
+ return _canonical_body(stripped.lstrip("\n"))
+
+
+def validate_release_body_shape(
+ body: str,
+ version: str,
+ *,
+ expected_body: str | None = None,
+) -> str:
+ """Validate a stored GitHub release body and return its authored body."""
+
+ clean_body = strip_validation_status_block(body)
+ validate_release_notes_shape(clean_body, version)
+
+ if clean_body.count("## Installation\n") != 1:
+ raise ReleaseBodyIntegrityError(
+ "published release body must contain exactly one Installation section"
+ )
+ if clean_body.count("## Promotion Metadata\n") != 1:
+ raise ReleaseBodyIntegrityError(
+ "published release body must contain exactly one Promotion Metadata section"
+ )
+ if "Draft Release Notes" in clean_body or "_DRAFT.md" in clean_body:
+ raise ReleaseBodyIntegrityError(
+ "published release body still contains draft-only framing"
+ )
+
+ installation_index = clean_body.index("## Installation\n")
+ promotion_index = clean_body.index("## Promotion Metadata\n")
+ if installation_index >= promotion_index:
+ raise ReleaseBodyIntegrityError(
+ "Installation must precede Promotion Metadata in the published body"
+ )
+
+ authored_prefix = clean_body[:installation_index]
+ authored_sections = re.findall(r"(?m)^##[ \t]+\S.*$", authored_prefix)
+ if not authored_sections:
+ raise ReleaseBodyIntegrityError(
+ "published release body has no authored section before Installation"
+ )
+
+ if expected_body is not None:
+ expected_clean = strip_validation_status_block(expected_body)
+ if clean_body != expected_clean:
+ raise ReleaseBodyIntegrityError(
+ "GitHub's stored release body does not exactly match the expected "
+ "rendered Markdown"
+ )
+
+ return clean_body
+
+
def _replace_draft_heading(text: str, version: str) -> str:
lines = text.splitlines()
for index, line in enumerate(lines):
@@ -109,31 +225,91 @@ def build_promotion_metadata_section(args: argparse.Namespace) -> str:
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--version", required=True)
- parser.add_argument("--release-notes-file", required=True)
- parser.add_argument("--output", required=True)
- parser.add_argument("--promotion-channel", required=True)
- parser.add_argument("--candidate-tag", required=True)
+ parser.add_argument("--release-notes-file")
+ parser.add_argument("--validate-notes-file")
+ parser.add_argument("--validate-body-file")
+ parser.add_argument("--expected-body-file")
+ parser.add_argument("--output")
+ parser.add_argument("--promotion-channel")
+ parser.add_argument("--candidate-tag")
parser.add_argument("--promoted-prerelease-tag", default="")
- parser.add_argument("--rollback-target", required=True)
- parser.add_argument("--rollback-command", required=True)
+ parser.add_argument("--rollback-target")
+ parser.add_argument("--rollback-command")
parser.add_argument("--planned-ga-date", default="")
parser.add_argument("--planned-v5-eos-date", default="")
- parser.add_argument("--hotfix-exception", required=True)
+ parser.add_argument("--hotfix-exception")
parser.add_argument("--hotfix-reason", default="")
- return parser.parse_args()
+ args = parser.parse_args()
+
+ if args.validate_notes_file or args.validate_body_file:
+ if args.release_notes_file:
+ parser.error(
+ "validation modes cannot be combined with --release-notes-file"
+ )
+ if args.validate_notes_file and args.validate_body_file:
+ parser.error(
+ "--validate-notes-file cannot be combined with --validate-body-file"
+ )
+ if args.validate_notes_file and (args.expected_body_file or args.output):
+ parser.error(
+ "--validate-notes-file cannot use --expected-body-file or --output"
+ )
+ return args
+
+ required_render_args = {
+ "--release-notes-file": args.release_notes_file,
+ "--output": args.output,
+ "--promotion-channel": args.promotion_channel,
+ "--candidate-tag": args.candidate_tag,
+ "--rollback-target": args.rollback_target,
+ "--rollback-command": args.rollback_command,
+ "--hotfix-exception": args.hotfix_exception,
+ }
+ missing = [name for name, value in required_render_args.items() if value is None]
+ if missing:
+ parser.error("render mode requires " + ", ".join(missing))
+ if args.expected_body_file:
+ parser.error("--expected-body-file requires --validate-body-file")
+ return args
def main() -> int:
args = parse_args()
- raw_text = Path(args.release_notes_file).read_text(encoding="utf-8")
- sanitized = sanitize_release_notes(raw_text, args.version).rstrip("\n")
- sections = [
- sanitized,
- build_installation_section(args.version),
- build_promotion_metadata_section(args),
- ]
- Path(args.output).write_text("\n\n".join(sections) + "\n", encoding="utf-8")
- return 0
+ try:
+ if args.validate_notes_file:
+ raw_text = Path(args.validate_notes_file).read_text(encoding="utf-8")
+ validate_release_notes_shape(raw_text, args.version)
+ return 0
+
+ if args.validate_body_file:
+ body = Path(args.validate_body_file).read_text(encoding="utf-8")
+ expected_body = None
+ if args.expected_body_file:
+ expected_body = Path(args.expected_body_file).read_text(encoding="utf-8")
+ clean_body = validate_release_body_shape(
+ body,
+ args.version,
+ expected_body=expected_body,
+ )
+ if args.output:
+ Path(args.output).write_text(clean_body, encoding="utf-8")
+ return 0
+
+ raw_text = Path(args.release_notes_file).read_text(encoding="utf-8")
+ validate_release_notes_shape(raw_text, args.version)
+ sanitized = sanitize_release_notes(raw_text, args.version).rstrip("\n")
+ sections = [
+ sanitized,
+ build_installation_section(args.version),
+ build_promotion_metadata_section(args),
+ ]
+ rendered = "\n\n".join(sections) + "\n"
+ validate_release_body_shape(rendered, args.version)
+ Path(args.output).write_text(rendered, encoding="utf-8")
+ return 0
+ except ReleaseBodyIntegrityError as exc:
+ print(f"release body integrity check failed: {exc}", file=sys.stderr)
+ return 1
if __name__ == "__main__":
diff --git a/scripts/release_control/render_release_body_test.py b/scripts/release_control/render_release_body_test.py
index 0ffc923135..60bda0ef99 100644
--- a/scripts/release_control/render_release_body_test.py
+++ b/scripts/release_control/render_release_body_test.py
@@ -66,7 +66,9 @@ Old metadata section.
notes_file.write_text(
"# Pulse v6.0.0-rc.2 Draft Release Notes\n\n"
"_Draft only. Do not treat this as published until the governed `v6.0.0-rc.2` tag and GitHub prerelease exist._\n\n"
- "Body.\n",
+ "Body.\n\n"
+ "## Fixed\n\n"
+ "- Corrected a release issue.\n",
encoding="utf-8",
)
@@ -111,6 +113,91 @@ Old metadata section.
)
self.assertIn("https://pulserelay.pro/download.html", body)
self.assertIn("- Rollback target: v5.1.28", body)
+ render_release_body.validate_release_body_shape(body, "6.0.0-rc.2")
+
+ def test_flattened_release_notes_fail_closed(self) -> None:
+ flattened = (
+ "# Pulse v6.1.0-rc.2 Release Notes"
+ "`v6.1.0-rc.2` is a release candidate."
+ "## Highlights"
+ "- Patrol findings stay governed."
+ "## Upgrade Notes"
+ "Use the RC channel."
+ )
+
+ with self.assertRaisesRegex(
+ render_release_body.ReleaseBodyIntegrityError,
+ "standalone release title",
+ ):
+ render_release_body.validate_release_notes_shape(
+ flattened,
+ "6.1.0-rc.2",
+ )
+
+ def test_stored_release_body_must_match_expected_rendered_markdown(self) -> None:
+ expected = """# Pulse v6.1.0-rc.2 Release Notes
+
+Intro.
+
+## Highlights
+
+- Patrol findings stay governed.
+
+## Installation
+
+Install details.
+
+## Promotion Metadata
+
+- Promotion channel: rc
+"""
+ validation_block = """<!-- VALIDATION_STATUS_START -->
+## Release Asset Validation: PASSED
+
+Assets passed.
+<!-- VALIDATION_STATUS_END -->
+
+"""
+ stored = validation_block + expected
+
+ clean = render_release_body.validate_release_body_shape(
+ stored,
+ "6.1.0-rc.2",
+ expected_body=expected,
+ )
+ self.assertEqual(clean, expected)
+
+ with self.assertRaisesRegex(
+ render_release_body.ReleaseBodyIntegrityError,
+ "does not exactly match",
+ ):
+ render_release_body.validate_release_body_shape(
+ stored,
+ "6.1.0-rc.2",
+ expected_body=expected.replace("Patrol", "Assistant"),
+ )
+
+ def test_stored_release_body_rejects_inline_headings(self) -> None:
+ flattened = """# Pulse v6.1.0-rc.2 Release Notes
+
+Intro.## Highlights- Patrol findings stay governed.
+
+## Installation
+
+Install details.
+
+## Promotion Metadata
+
+- Promotion channel: rc
+"""
+ with self.assertRaisesRegex(
+ render_release_body.ReleaseBodyIntegrityError,
+ "flattened Markdown",
+ ):
+ render_release_body.validate_release_body_shape(
+ flattened,
+ "6.1.0-rc.2",
+ )
def test_current_release_packets_use_pulse_mobile_handoff_copy(self) -> None:
repo_root = _REPO_ROOT
diff --git a/scripts/trigger-release.sh b/scripts/trigger-release.sh
index 729cf963eb..29c1d31bb7 100755
--- a/scripts/trigger-release.sh
+++ b/scripts/trigger-release.sh
@@ -2,9 +2,10 @@
set -euo pipefail
# Helper script to trigger a release with pre-flight validation
-# Usage: ./scripts/trigger-release.sh 4.30.0
+# Usage: ./scripts/trigger-release.sh 4.30.0 [release-notes-file]
VERSION="${1:-}"
+NOTES_FILE_ARG="${2:-}"
if [ -z "$VERSION" ]; then
echo "Error: Version number required"
@@ -128,8 +129,8 @@ echo ""
echo "Next: Provide release notes when prompted"
echo ""
-# Check 5: Release notes file (optional)
-NOTES_FILE="/tmp/release_notes_${VERSION}.md"
+# Check 5: Release notes file
+NOTES_FILE="${NOTES_FILE_ARG:-/tmp/release_notes_${VERSION}.md}"
if [ -f "$NOTES_FILE" ]; then
echo "Found release notes file: ${NOTES_FILE}"
echo ""
@@ -182,6 +183,11 @@ if [ -z "$NOTES_FILE" ]; then
exit 1
fi
+python3 scripts/release_control/render_release_body.py \
+ --version "$VERSION" \
+ --validate-notes-file "$NOTES_FILE"
+echo "✓ Release-note Markdown structure validated"
+
ROLLBACK_VERSION=""
ROLLBACK_COMMAND=""
PROMOTED_FROM_TAG=""
@@ -279,18 +285,32 @@ cat /tmp/pulse-release-metadata.out
echo ""
echo "Triggering release workflow..."
if [ -n "$NOTES_FILE" ]; then
- gh workflow run create-release.yml \
- --ref "$CURRENT_BRANCH" \
- -f version="${VERSION}" \
- -f release_notes="$(cat "$NOTES_FILE")" \
- -f rollback_version="${ROLLBACK_VERSION}" \
- -f promoted_from_tag="${PROMOTED_FROM_TAG}" \
- -f ga_date="${GA_DATE}" \
- -f v5_eos_date="${V5_EOS_DATE}" \
- -f hotfix_exception="${HOTFIX_EXCEPTION}" \
- -f hotfix_reason="${HOTFIX_REASON}" \
- -f mobile_release_decision="${MOBILE_RELEASE_DECISION}" \
- -f mobile_release_evidence="${MOBILE_RELEASE_EVIDENCE}"
+ jq -n \
+ --arg version "$VERSION" \
+ --rawfile release_notes "$NOTES_FILE" \
+ --arg rollback_version "$ROLLBACK_VERSION" \
+ --arg promoted_from_tag "$PROMOTED_FROM_TAG" \
+ --arg ga_date "$GA_DATE" \
+ --arg v5_eos_date "$V5_EOS_DATE" \
+ --argjson hotfix_exception "$HOTFIX_EXCEPTION" \
+ --arg hotfix_reason "$HOTFIX_REASON" \
+ --argjson draft_only false \
+ --arg mobile_release_decision "$MOBILE_RELEASE_DECISION" \
+ --arg mobile_release_evidence "$MOBILE_RELEASE_EVIDENCE" \
+ '{
+ version: $version,
+ release_notes: $release_notes,
+ rollback_version: $rollback_version,
+ promoted_from_tag: $promoted_from_tag,
+ ga_date: $ga_date,
+ v5_eos_date: $v5_eos_date,
+ hotfix_exception: $hotfix_exception,
+ hotfix_reason: $hotfix_reason,
+ draft_only: $draft_only,
+ mobile_release_decision: $mobile_release_decision,
+ mobile_release_evidence: $mobile_release_evidence
+ }' |
+ gh workflow run create-release.yml --ref "$CURRENT_BRANCH" --json
else
# This should be unreachable due to check above, but kept for safety
echo "❌ Error: Release notes are required"
diff --git a/scripts/trigger-stable-patch.sh b/scripts/trigger-stable-patch.sh
index e3ef0271ab..e8206e5365 100755
--- a/scripts/trigger-stable-patch.sh
+++ b/scripts/trigger-stable-patch.sh
@@ -167,6 +167,10 @@ if [ "$MODE" = "dry-run" ]; then
-f mobile_release_decision="$MOBILE_RELEASE_DECISION" \
-f mobile_release_evidence="$MOBILE_RELEASE_EVIDENCE"
else
+ python3 scripts/release_control/render_release_body.py \
+ --version "$VERSION" \
+ --validate-notes-file "$NOTES_FILE"
+
python3 scripts/check-workflow-dispatch-inputs.py \
--workflow-path .github/workflows/create-release.yml \
--branch "$CURRENT_BRANCH" \
@@ -182,19 +186,32 @@ else
--require mobile_release_decision \
--require mobile_release_evidence
- gh workflow run create-release.yml \
- --ref "$CURRENT_BRANCH" \
- -f version="$VERSION" \
- -f release_notes="$(<"$NOTES_FILE")" \
- -f promoted_from_tag="" \
- -f rollback_version="$ROLLBACK_TAG" \
- -f ga_date="" \
- -f v5_eos_date="" \
- -f hotfix_exception="$HOTFIX_EXCEPTION" \
- -f hotfix_reason="$HOTFIX_REASON" \
- -f draft_only=false \
- -f mobile_release_decision="$MOBILE_RELEASE_DECISION" \
- -f mobile_release_evidence="$MOBILE_RELEASE_EVIDENCE"
+ jq -n \
+ --arg version "$VERSION" \
+ --rawfile release_notes "$NOTES_FILE" \
+ --arg promoted_from_tag "" \
+ --arg rollback_version "$ROLLBACK_TAG" \
+ --arg ga_date "" \
+ --arg v5_eos_date "" \
+ --argjson hotfix_exception "$HOTFIX_EXCEPTION" \
+ --arg hotfix_reason "$HOTFIX_REASON" \
+ --argjson draft_only false \
+ --arg mobile_release_decision "$MOBILE_RELEASE_DECISION" \
+ --arg mobile_release_evidence "$MOBILE_RELEASE_EVIDENCE" \
+ '{
+ version: $version,
+ release_notes: $release_notes,
+ promoted_from_tag: $promoted_from_tag,
+ rollback_version: $rollback_version,
+ ga_date: $ga_date,
+ v5_eos_date: $v5_eos_date,
+ hotfix_exception: $hotfix_exception,
+ hotfix_reason: $hotfix_reason,
+ draft_only: $draft_only,
+ mobile_release_decision: $mobile_release_decision,
+ mobile_release_evidence: $mobile_release_evidence
+ }' |
+ gh workflow run create-release.yml --ref "$CURRENT_BRANCH" --json
fi