diff --git a/.github/release-requests/v0.5.12-notes.md b/.github/release-requests/v0.5.12-notes.md new file mode 100644 index 000000000..9b6a13bde --- /dev/null +++ b/.github/release-requests/v0.5.12-notes.md @@ -0,0 +1,9 @@ +# WebCodex v0.5.12 + +- Desktop clears the stale green Tunnel indicator when polling stops. It shows Tunnel polling and local MCP availability separately. +- The Tunnel reconnects faster when polling recovers in the same process. Recovery uses short polls and quicker retries after transport failures, with periodic longer polls for slow routes. It still honors the server’s `Retry-After` instructions. + +## 中文 + +- 轮询停止后,桌面端会清除残留的绿色隧道连接提示,并分别显示隧道轮询状态和本地 MCP 的可用状态。 +- 隧道在同一进程内恢复轮询时,重连更快。恢复期间会使用短轮询,传输失败后也会更快重试,同时定期使用更长的等待时间照顾慢线路。服务端发出 `Retry-After` 时,仍按其要求等待。 diff --git a/.github/release-requests/v0.5.12.json b/.github/release-requests/v0.5.12.json new file mode 100644 index 000000000..549db669b --- /dev/null +++ b/.github/release-requests/v0.5.12.json @@ -0,0 +1,21 @@ +{ + "ci_run_attempt": 1, + "ci_run_id": 44474561280, + "evidence_run_attempt": 1, + "evidence_run_id": 44474561158, + "github_only": true, + "include_runtime_installers": false, + "include_unified_installers": true, + "notes_path": ".github/release-requests/v0.5.12-notes.md", + "notes_sha256": "7aa9ee50a17226e77200476864e13e51d02ad9f977e14b14efc0a0c0fb51368c", + "owner": "9holy", + "owner_id": 45361924, + "repo": "9holy/webcodex", + "repo_id": 1404596174, + "schema_version": 1, + "source_ref": "release/v0.5.12", + "source_sha": "3f588c2ff3f3515c169f80a7fb2da9727c6d75d1", + "source_tree": "1fc7258c5537074574b7ec67a5996029e213c65e", + "tag": "v0.5.12", + "version": "0.5.12" +} diff --git a/.github/workflows/release-publish-v0512.yml b/.github/workflows/release-publish-v0512.yml new file mode 100644 index 000000000..f5b3e5c8f --- /dev/null +++ b/.github/workflows/release-publish-v0512.yml @@ -0,0 +1,429 @@ +name: Publish approved GitHub release v0.5.12 + +run-name: Publish WebCodex v0.5.12 + +on: + push: + branches: [main] + paths: + - .github/release-requests/v0.5.12.json + workflow_dispatch: + +# A reviewed request on main authorizes only this repository's fixed release. +# Candidate workflows retain their existing read-only permissions. Publication +# uses the repository-scoped Actions installation token; no personal token or npm. +permissions: + contents: read + +concurrency: + group: publish-approved-github-v0.5.12 + cancel-in-progress: false + +jobs: + publish: + if: >- + github.repository == '9holy/webcodex' && + github.repository_id == '1404596174' && + github.ref == 'refs/heads/main' && + github.actor == '9holy' && github.triggering_actor == '9holy' + runs-on: ubuntu-latest + timeout-minutes: 360 + permissions: + contents: write + actions: write + defaults: + run: + shell: bash + working-directory: control + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PYTHONDONTWRITEBYTECODE: '1' + CONTROL_REQUEST: ${{ github.workspace }}/control/.github/release-requests/v0.5.12.json + SOURCE_ROOT: ${{ github.workspace }}/release-source + steps: + - name: Checkout reviewed publication controller + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + ref: ${{ github.sha }} + path: control + fetch-depth: 1 + persist-credentials: false + - name: Initialize publication directories + run: | + printf 'STATE_DIR=%s/webcodex-release-control\n' "$RUNNER_TEMP" >> "$GITHUB_ENV" + printf 'BUNDLE_DIR=%s/webcodex-release-bundle\n' "$RUNNER_TEMP" >> "$GITHUB_ENV" + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 + with: + python-version: '3.12' + - name: Read the reviewed fixed source identity + id: release-spec + run: | + python3 - <<'PYTHON' >> "$GITHUB_OUTPUT" + import os + from pathlib import Path + from scripts import release_github_actions as controller + from scripts.release_github_actions_v0512 import SPEC, require_finalized + + if (SPEC.pinned_request["tag"] != "v0.5.12" + or SPEC.request_path != ".github/release-requests/v0.5.12.json" + or SPEC.workflow_path != ".github/workflows/release-publish-v0512.yml"): + raise SystemExit("The reviewed publication specification does not match this fixed entry point.") + require_finalized(SPEC) + request = controller.validate_request( + controller._read_json(Path(os.environ["CONTROL_REQUEST"])), spec=SPEC) + print("source_sha=" + request["source_sha"]) + PYTHON + - name: Checkout immutable release source + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + ref: ${{ steps.release-spec.outputs.source_sha }} + path: release-source + fetch-depth: 0 + fetch-tags: true + persist-credentials: false + - name: Validate publication controller contracts + run: >- + python3 -m unittest scripts.tests.test_release_github_actions + scripts.tests.test_release_assembly_publication + scripts.tests.test_recover_release_assembly + scripts.tests.test_release_checksum_layout + scripts.tests.test_release_github_actions_v054 + scripts.tests.test_release_github_actions_v055 + scripts.tests.test_release_github_actions_v056 + scripts.tests.test_release_github_actions_v057 + scripts.tests.test_release_github_actions_v058 + scripts.tests.test_release_github_actions_v059 + scripts.tests.test_release_github_actions_v0510 + scripts.tests.test_release_github_actions_v0511 + scripts.tests.test_release_github_actions_v0512 + scripts.tests.test_release_windows_acceptance + scripts.tests.test_verify_public_release + - name: Restore this run's verified checkpoint on retry + run: >- + python3 scripts/release_github_actions_v0512.py restore-state --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Verify repository, machine identity and exact source proofs + run: >- + python3 scripts/release_github_actions_v0512.py preflight --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain preflight + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-01-preflight + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Prepare one correlated readiness request + run: >- + python3 scripts/release_github_actions_v0512.py prepare-readiness --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain readiness-intent + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-02-readiness-intent + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Dispatch the prepared readiness request once + run: >- + python3 scripts/release_github_actions_v0512.py dispatch-readiness --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain readiness-dispatched + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-03-readiness-dispatched + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Require successful exact-source readiness + run: | + set -euo pipefail + deadline=$((SECONDS + 1800)) + while true; do + code=0 + python3 scripts/release_github_actions_v0512.py status-readiness --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" --wait-secs 0 || code=$? + if [ "$code" -eq 0 ]; then break; fi + if [ "$code" -ne 2 ]; then exit "$code"; fi + if [ "$SECONDS" -ge "$deadline" ]; then + echo "The bound workflow is still pending; retain its identity and resume this run." >&2 + exit 2 + fi + sleep 45 + done + - name: Retain readiness-verified + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-04-readiness-verified + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Prepare the immutable annotated tag + run: >- + python3 scripts/release_github_actions_v0512.py prepare-tag --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain tag-intent + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-05-tag-intent + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Create or reconcile the exact annotated tag + run: >- + python3 scripts/release_github_actions_v0512.py create-tag --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain tag-created + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-06-tag-created + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Prepare one formal build request + run: >- + python3 scripts/release_github_actions_v0512.py prepare-build --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain build-intent + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-07-build-intent + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Dispatch the prepared tagged build once + run: >- + python3 scripts/release_github_actions_v0512.py dispatch-build --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain build-dispatched + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-08-build-dispatched + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Require the exact formal build to succeed + run: | + set -euo pipefail + deadline=$((SECONDS + 14400)) + while true; do + code=0 + python3 scripts/release_github_actions_v0512.py status-build --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" --wait-secs 0 || code=$? + if [ "$code" -eq 0 ]; then break; fi + if [ "$code" -ne 2 ]; then exit "$code"; fi + if [ "$SECONDS" -ge "$deadline" ]; then + echo "The bound workflow is still pending; retain its identity and resume this run." >&2 + exit 2 + fi + sleep 45 + done + - name: Retain build-verified + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-09-build-verified + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Collect and verify the same-run installer bundle + run: >- + python3 scripts/release_github_actions_v0512.py collect --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain bundle-verified + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-10-bundle-verified + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Prepare the bound draft Release + run: >- + python3 scripts/release_github_actions_v0512.py prepare-draft --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain draft-intent + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-11-draft-intent + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Create or reconcile the bound draft + run: >- + python3 scripts/release_github_actions_v0512.py create-draft --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain draft-created + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-12-draft-created + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Freeze the exact public asset list and hashes + run: >- + python3 scripts/release_github_actions_v0512.py prepare-upload --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain upload-intent + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-13-upload-intent + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Upload retained assets without replacing existing bytes + run: >- + python3 scripts/release_github_actions_v0512.py upload-assets --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain assets-uploaded + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-14-assets-uploaded + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Verify every draft asset digest and size + run: >- + python3 scripts/release_github_actions_v0512.py verify-draft --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain draft-verified + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-15-draft-verified + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Freeze preview publication intent + run: >- + python3 scripts/release_github_actions_v0512.py prepare-preview --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain preview-intent + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-16-preview-intent + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Publish immutable preview once + run: >- + python3 scripts/release_github_actions_v0512.py publish-preview --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain preview-published + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-17-preview-published + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Verify real public prerelease installer bytes + run: >- + python3 scripts/release_github_actions_v0512.py verify-preview --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain preview-verified + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-18-preview-verified + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Freeze exact native Windows acceptance request + run: >- + python3 scripts/release_github_actions_v0512.py prepare-acceptance --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain acceptance-intent + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-19-acceptance-intent + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Dispatch the bound read-only Windows workflow once + run: >- + python3 scripts/release_github_actions_v0512.py dispatch-acceptance --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain acceptance-dispatched + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-20-acceptance-dispatched + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Require both native Windows architectures and all five install scenarios + run: | + set -euo pipefail + deadline=$((SECONDS + 5400)) + while true; do + code=0 + python3 scripts/release_github_actions_v0512.py status-acceptance --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" --wait-secs 0 || code=$? + if [ "$code" -eq 0 ]; then break; fi + if [ "$code" -ne 2 ]; then exit "$code"; fi + if [ "$SECONDS" -ge "$deadline" ]; then + echo "The bound workflow is still pending; retain its identity and resume this run." >&2 + exit 2 + fi + sleep 45 + done + - name: Retain acceptance-verified + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-21-acceptance-verified + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Freeze stable promotion against successful Windows proof + run: >- + python3 scripts/release_github_actions_v0512.py prepare-promotion --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain promotion-intent + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-22-promotion-intent + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Promote the same Release to stable and latest once + run: >- + python3 scripts/release_github_actions_v0512.py promote --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain stable-promoted + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-23-stable-promoted + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Verify stable public installer bytes + run: >- + python3 scripts/release_github_actions_v0512.py verify-public --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain public-verified + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-24-public-verified + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Freeze image and Intel Desktop dispatches after promotion + run: >- + python3 scripts/release_github_actions_v0512.py prepare-post --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain post-intent + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-25-post-intent + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Dispatch the existing post-publication workflows + run: >- + python3 scripts/release_github_actions_v0512.py dispatch-post --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" + - name: Retain post-dispatched + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-26-post-dispatched + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Require image verification and completed Intel DMG publication + run: | + set -euo pipefail + deadline=$((SECONDS + 7200)) + while true; do + code=0 + python3 scripts/release_github_actions_v0512.py status-post --request "$CONTROL_REQUEST" --source-root "$SOURCE_ROOT" --state-dir "$STATE_DIR" --bundle-dir "$BUNDLE_DIR" --wait-secs 0 || code=$? + if [ "$code" -eq 0 ]; then break; fi + if [ "$code" -ne 2 ]; then exit "$code"; fi + if [ "$SECONDS" -ge "$deadline" ]; then + echo "The bound workflow is still pending; retain its identity and resume this run." >&2 + exit 2 + fi + sleep 45 + done + - name: Retain post-verified + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-27-post-verified + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: error + retention-days: 90 + - name: Retain final-state + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-control-v0.5.12-${{ github.run_id }}-${{ github.run_attempt }}-99-final-state + path: ${{ runner.temp }}/webcodex-release-control/*.json + if-no-files-found: warn + retention-days: 90 diff --git a/scripts/release_github_actions_v0512.py b/scripts/release_github_actions_v0512.py new file mode 100644 index 000000000..608db14ce --- /dev/null +++ b/scripts/release_github_actions_v0512.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +"""Fixed v0.5.12 authority using the reviewed staged publication gates. + +Only this entry's source/proof pins may change during finalization. The request +cannot select another source, workflow, asset scope, or acceptance policy. +""" +from __future__ import annotations + +from pathlib import Path +import sys + +if __package__: + from . import release_github_actions as base + from . import release_github_actions_v054 as staged +else: + # Preserve one validation error class across the script and shared worker. + sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) + from scripts import release_github_actions as base + from scripts import release_github_actions_v054 as staged + + +# Final source, successful proof attempts, and notes must be fixed in reviewed control code. +SPEC = base.ReleaseSpec( + {**base.PINNED_REQUEST, + "version": "0.5.12", "tag": "v0.5.12", "source_ref": "release/v0.5.12", + "source_sha": "3f588c2ff3f3515c169f80a7fb2da9727c6d75d1", + "source_tree": "1fc7258c5537074574b7ec67a5996029e213c65e", + "ci_run_id": 44474561280, "ci_run_attempt": 1, + "evidence_run_id": 44474561158, "evidence_run_attempt": 1, + "notes_path": ".github/release-requests/v0.5.12-notes.md", + "notes_sha256": "7aa9ee50a17226e77200476864e13e51d02ad9f977e14b14efc0a0c0fb51368c"}, + ".github/release-requests/v0.5.12.json", + ".github/workflows/release-publish-v0512.yml", +) + + +def require_finalized(spec: base.ReleaseSpec) -> None: + request = spec.pinned_request + base._require( + request["version"] == "0.5.12" and request["tag"] == "v0.5.12" + and request["source_ref"] == "release/v0.5.12" + and spec.request_path == ".github/release-requests/v0.5.12.json" + and spec.workflow_path == ".github/workflows/release-publish-v0512.yml" + and spec.platform_scope == "all" + and request["source_sha"] != "0" * 40 and request["source_tree"] != "0" * 40 + and request["ci_run_id"] > 1 and request["evidence_run_id"] > 1 + and request["notes_sha256"] != "0" * 64, + "v0.5.12 固定源码或成功验收 pins 尚未完成审核;不执行任何发布操作。", + ) + + +class StagedController(staged.StagedController): + def run(self, stage: str, wait_secs: int = 0) -> int: + require_finalized(self.spec) + # Replace only the v0.5.4 entry guard. The unchanged base dispatcher still + # authenticates, locks, restores, validates source, and calls the inherited + # staged method; no publication or acceptance gate is overridden. + return base.Controller.run(self, stage, wait_secs) + + +if __name__ == "__main__": + raise SystemExit(base.main(spec=SPEC, controller_type=StagedController)) diff --git a/scripts/release_windows_acceptance.py b/scripts/release_windows_acceptance.py index 9b167a312..1f51a37ca 100644 --- a/scripts/release_windows_acceptance.py +++ b/scripts/release_windows_acceptance.py @@ -55,7 +55,8 @@ def scenarios_for_request(request: dict) -> tuple[str, ...]: ("v0.5.8", ".github/workflows/release-publish-v058.yml"), ("v0.5.9", ".github/workflows/release-publish-v059.yml"), ("v0.5.10", ".github/workflows/release-publish-v0510.yml"), - ("v0.5.11", ".github/workflows/release-publish-v0511.yml")}: + ("v0.5.11", ".github/workflows/release-publish-v0511.yml"), + ("v0.5.12", ".github/workflows/release-publish-v0512.yml")}: return V056_SCENARIOS return SCENARIOS @@ -131,6 +132,8 @@ def select_release_spec(request: dict) -> control.ReleaseSpec: from scripts.release_github_actions_v0510 import SPEC, require_finalized elif identity == ("v0.5.11", ".github/workflows/release-publish-v0511.yml"): from scripts.release_github_actions_v0511 import SPEC, require_finalized + elif identity == ("v0.5.12", ".github/workflows/release-publish-v0512.yml"): + from scripts.release_github_actions_v0512 import SPEC, require_finalized else: raise control.ReleaseControlError("Windows 验收请求不属于已审核的固定发布入口。") require_finalized(SPEC) diff --git a/scripts/tests/test_release_github_actions_v0512.py b/scripts/tests/test_release_github_actions_v0512.py new file mode 100644 index 000000000..b0f3ab8c5 --- /dev/null +++ b/scripts/tests/test_release_github_actions_v0512.py @@ -0,0 +1,96 @@ +from __future__ import annotations + +from dataclasses import replace +import hashlib +from pathlib import Path +import runpy +import unittest +from unittest import mock + +from scripts import release_github_actions as base +from scripts import release_github_actions_v0510 as windows_only +from scripts import release_github_actions_v0511 as previous +from scripts import release_github_actions_v0512 as staged +from scripts import release_windows_acceptance as worker +from scripts.tests import test_release_windows_acceptance as fixtures + + +class V0512PublicationTests(unittest.TestCase): + def setUp(self): + self.spec = self.spec_with(source_sha="c" * 40, source_tree="d" * 40, + ci_run_id=1001, evidence_run_id=1002, notes_sha256="e" * 64) + + def spec_with(self, **pins): + return replace(staged.SPEC, pinned_request={**staged.SPEC.pinned_request, **pins}) + + def test_checked_in_request_and_notes_match_immutable_authority(self): + root = Path(__file__).resolve().parents[2] + request = base.validate_request(base._read_json(root / staged.SPEC.request_path), spec=staged.SPEC) + self.assertEqual(hashlib.sha256((root / request["notes_path"]).read_bytes()).hexdigest(), + request["notes_sha256"]) + self.assertTrue(request["github_only"]) + self.assertTrue(request["include_unified_installers"]) + self.assertFalse(request["include_runtime_installers"]) + + def test_unfinalized_spec_never_reaches_authenticated_dispatcher(self): + controller = mock.Mock(spec=staged.StagedController) + for key, placeholder in (("source_sha", "0" * 40), ("source_tree", "0" * 40), + ("ci_run_id", 1), ("evidence_run_id", 1), ("notes_sha256", "0" * 64)): + controller.spec = replace(self.spec, pinned_request={**self.spec.pinned_request, key: placeholder}) + with self.subTest(pin=key), mock.patch.object(base.Controller, "run") as dispatch: + with self.assertRaises(base.ReleaseControlError): + staged.StagedController.run(controller, "preflight") + dispatch.assert_not_called() + + controller.spec = self.spec + with mock.patch.object(base.Controller, "run", return_value=17) as dispatch: + self.assertEqual(staged.StagedController.run(controller, "status-acceptance", 1), 17) + dispatch.assert_called_once_with(controller, "status-acceptance", 1) + + def test_fixed_policy_reuses_all_platform_stages_without_overrides(self): + staged.require_finalized(self.spec) + for spec in (previous.SPEC, windows_only.SPEC, self.spec_with(platform_scope="windows"), + replace(self.spec, workflow_path=windows_only.SPEC.workflow_path)): + with self.subTest(tag=spec.pinned_request["tag"], workflow=spec.workflow_path): + with self.assertRaises(base.ReleaseControlError): + staged.require_finalized(spec) + + self.assertEqual(self.spec.pinned_request["tag"], "v0.5.12") + self.assertEqual(self.spec.pinned_request["source_ref"], "release/v0.5.12") + self.assertEqual(self.spec.platform_scope, "all") + self.assertEqual(set(self.spec.post_workflows), {"image", "intel"}) + self.assertIs(staged.StagedController.stages, previous.StagedController.stages) + for method in ("prepare_preview", "publish_preview", "verify_preview", "prepare_acceptance", + "dispatch_acceptance", "_acceptance_reports", "status_acceptance", "prepare_promotion", + "promote", "verify_public", "prepare_post", "dispatch_post", "status_post"): + with self.subTest(method=method): + self.assertIs(getattr(staged.StagedController, method), getattr(previous.StagedController, method)) + + def test_windows_worker_requires_exact_authority_and_all_five_scenarios(self): + request = fixtures.fixed_request(self.spec) + unreviewed = dict(request, controller_workflow=previous.SPEC.workflow_path) + with mock.patch.object(staged, "SPEC", self.spec): + self.assertIs(worker.select_release_spec(request), self.spec) + with self.assertRaises(base.ReleaseControlError): + worker.select_release_spec(unreviewed) + + self.assertEqual(worker.scenarios_for_request(request), worker.V056_SCENARIOS) + for platform in worker.PLATFORMS: + with self.subTest(platform=platform): + report = fixtures.report(request, platform) + worker.validate_report(report, request, platform, 456, 1) + del report["scenarios"]["v054_configured"] + with self.assertRaises(base.ReleaseControlError): + worker.validate_report(report, request, platform, 456, 1) + + def test_workflow_preserves_reviewed_steps_permissions_and_checkpoints(self): + root = Path(__file__).resolve().parents[2] + entry = runpy.run_path(str(root / "scripts/release_github_actions_v0512.py"), run_name="v0512_fixture") + self.assertIs(entry["base"].ReleaseControlError, worker.control.ReleaseControlError) + + expected = (root / previous.SPEC.workflow_path).read_text(encoding="utf-8") + expected = expected.replace("v0.5.11", "v0.5.12").replace("v0511", "v0512") + expected = expected.replace(" scripts.tests.test_release_github_actions_v0512\n", + " scripts.tests.test_release_github_actions_v0511\n" + " scripts.tests.test_release_github_actions_v0512\n") + self.assertEqual((root / staged.SPEC.workflow_path).read_text(encoding="utf-8"), expected)