Skip to content

Commit 4135aa6

Browse files
committed
ci: own simple release admission Git
1 parent b4f8510 commit 4135aa6

13 files changed

Lines changed: 596 additions & 43 deletions

‎.github/workflows/linux-app-release.yml‎

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ jobs:
4545
exit 1
4646
fi
4747
48+
- name: Prepare Git owner
49+
uses: openclaw/openclaw/.github/actions/git-owner@dd4528b6393e7d00063067a080ca7241b48ce475
50+
4851
- name: Checkout selected tag
4952
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
5053
with:
@@ -58,13 +61,39 @@ jobs:
5861
RELEASE_TAG: ${{ inputs.tag }}
5962
run: |
6063
set -euo pipefail
61-
timeout --signal=TERM --kill-after=10s 120s git fetch --quiet origin main
62-
tag_sha=$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")
63-
if ! git merge-base --is-ancestor "${tag_sha}" origin/main; then
64-
echo "Tag ${RELEASE_TAG} (${tag_sha}) is not reachable from main; Linux bundles ship for main-based releases only."
65-
exit 1
66-
fi
67-
echo "tag_sha=${tag_sha}" >> "$GITHUB_OUTPUT"
64+
exec python3 -I -S "$CI_GIT_OWNER" --policy - <<'PYTHON'
65+
import os
66+
import sys
67+
68+
from ci_git_owner import GitFailure, git_output, run_git
69+
70+
workspace = os.environ["GITHUB_WORKSPACE"]
71+
release_tag = os.environ["RELEASE_TAG"]
72+
run_git(
73+
workspace,
74+
"fetch",
75+
"--quiet",
76+
"origin",
77+
"main",
78+
timeout=120,
79+
reclaim_locks=True,
80+
)
81+
tag_sha = git_output(
82+
workspace,
83+
"rev-parse",
84+
f"refs/tags/{release_tag}^{{commit}}",
85+
).rstrip("\n")
86+
try:
87+
run_git(workspace, "merge-base", "--is-ancestor", tag_sha, "origin/main")
88+
except GitFailure:
89+
print(
90+
f"Tag {release_tag} ({tag_sha}) is not reachable from main; "
91+
"Linux bundles ship for main-based releases only."
92+
)
93+
raise SystemExit(1)
94+
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
95+
output.write(f"tag_sha={tag_sha}\n")
96+
PYTHON
6897
6998
- name: Ensure matching GitHub release exists
7099
env:

‎.github/workflows/macos-release.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
exit 1
4343
fi
4444
45+
- name: Prepare Git owner
46+
uses: openclaw/openclaw/.github/actions/git-owner@dd4528b6393e7d00063067a080ca7241b48ce475
47+
4548
- name: Checkout selected tag
4649
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
4750
with:
@@ -74,10 +77,13 @@ jobs:
7477
echo "public_release_branch must be main or release/YYYY.M.PATCH, got ${PUBLIC_RELEASE_BRANCH}." >&2
7578
exit 1
7679
fi
77-
RELEASE_SHA=$(git rev-parse HEAD)
80+
RELEASE_SHA="$(
81+
python3 -I -S "$CI_GIT_OWNER" --git 0 rev-parse HEAD
82+
)"
7883
RELEASE_MAIN_REF="refs/remotes/origin/${PUBLIC_RELEASE_BRANCH}"
7984
export RELEASE_SHA RELEASE_TAG RELEASE_MAIN_REF
80-
timeout --signal=TERM --kill-after=10s 120s git fetch --no-tags origin "+refs/heads/${PUBLIC_RELEASE_BRANCH}:refs/remotes/origin/${PUBLIC_RELEASE_BRANCH}"
85+
python3 -I -S "$CI_GIT_OWNER" --checkout-git 120 fetch --no-tags origin \
86+
"+refs/heads/${PUBLIC_RELEASE_BRANCH}:refs/remotes/origin/${PUBLIC_RELEASE_BRANCH}"
8187
pnpm release:openclaw:npm:check
8288
8389
- name: Summarize next step

‎.github/workflows/npm-placeholder-bootstrap.yml‎

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
producer_run_attempt: ${{ github.run_attempt }}
4141
target_sha: ${{ steps.target.outputs.sha }}
4242
steps:
43+
- name: Prepare Git owner
44+
uses: openclaw/openclaw/.github/actions/git-owner@dd4528b6393e7d00063067a080ca7241b48ce475
45+
4346
- name: Checkout selected source
4447
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
4548
with:
@@ -57,25 +60,56 @@ jobs:
5760
WORKFLOW_SHA: ${{ github.workflow_sha }}
5861
run: |
5962
set -euo pipefail
60-
[[ "$WORKFLOW_REF" == "refs/heads/main" && "$WORKFLOW_SHA" =~ ^[0-9a-f]{40}$ ]] || {
61-
echo "NPM placeholder publication must run from the trusted main workflow." >&2
62-
exit 1
63-
}
64-
[[ "$SOURCE_REF" =~ ^[0-9a-f]{40}$ && "$SOURCE_REF" == "$EVENT_SHA" && "$SOURCE_REF" == "$WORKFLOW_SHA" && "$(git rev-parse HEAD)" == "$SOURCE_REF" ]] || {
65-
echo "NPM placeholder publication requires ref to equal the exact main workflow SHA." >&2
66-
exit 1
67-
}
68-
timeout --signal=TERM --kill-after=10s 120s git fetch --no-tags origin \
69-
+refs/heads/main:refs/remotes/origin/main
70-
git merge-base --is-ancestor "$WORKFLOW_SHA" origin/main || {
71-
echo "NPM placeholder workflow revision is not reachable from current main." >&2
72-
exit 1
73-
}
74-
git merge-base --is-ancestor "$SOURCE_REF" origin/main || {
75-
echo "NPM placeholder target must be reachable from current main." >&2
76-
exit 1
77-
}
78-
echo "sha=$SOURCE_REF" >> "$GITHUB_OUTPUT"
63+
exec python3 -I -S "$CI_GIT_OWNER" --policy - <<'PYTHON'
64+
import os
65+
import re
66+
import sys
67+
68+
from ci_git_owner import GitFailure, git_output, run_git
69+
70+
def fail(message):
71+
print(message, file=sys.stderr)
72+
raise SystemExit(1)
73+
74+
source_ref = os.environ["SOURCE_REF"]
75+
event_sha = os.environ["EVENT_SHA"]
76+
workflow_ref = os.environ["WORKFLOW_REF"]
77+
workflow_sha = os.environ["WORKFLOW_SHA"]
78+
workspace = os.environ["GITHUB_WORKSPACE"]
79+
if workflow_ref != "refs/heads/main" or not re.fullmatch(r"[0-9a-f]{40}", workflow_sha):
80+
fail("NPM placeholder publication must run from the trusted main workflow.")
81+
if (
82+
not re.fullmatch(r"[0-9a-f]{40}", source_ref)
83+
or source_ref != event_sha
84+
or source_ref != workflow_sha
85+
):
86+
fail("NPM placeholder publication requires ref to equal the exact main workflow SHA.")
87+
try:
88+
checked_out_sha = git_output(workspace, "rev-parse", "HEAD").rstrip("\n")
89+
except GitFailure:
90+
fail("NPM placeholder publication requires ref to equal the exact main workflow SHA.")
91+
if checked_out_sha != source_ref:
92+
fail("NPM placeholder publication requires ref to equal the exact main workflow SHA.")
93+
run_git(
94+
workspace,
95+
"fetch",
96+
"--no-tags",
97+
"origin",
98+
"+refs/heads/main:refs/remotes/origin/main",
99+
timeout=120,
100+
reclaim_locks=True,
101+
)
102+
try:
103+
run_git(workspace, "merge-base", "--is-ancestor", workflow_sha, "origin/main")
104+
except GitFailure:
105+
fail("NPM placeholder workflow revision is not reachable from current main.")
106+
try:
107+
run_git(workspace, "merge-base", "--is-ancestor", source_ref, "origin/main")
108+
except GitFailure:
109+
fail("NPM placeholder target must be reachable from current main.")
110+
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
111+
output.write(f"sha={source_ref}\n")
112+
PYTHON
79113
80114
- name: Setup Node
81115
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0

‎docs/ci.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ Generated PR publication prepares the same pinned owner before minting tokens. O
206206

207207
Maturity Scorecard prepares that immutable owner immediately before selected-ref checkout, preserving its runner-temporary environment handoff across checkout. Its trusted inline policy owns the full validation decision. Main, release-branch, and publication-base fetches and all local probes remain unbounded with one attempt. The sole 60-second operation is `ls-remote --exit-code --heads`: ordinary status 0 selects the branch, status 2 retains the default branch, and every other status fails with the lookup diagnostic after cleanup. A timeout is not absence; owner failure and cancellation never select a fallback or publish outputs. Main-ancestor, release-tag, and exact release-branch-head trust ordering, floating-main freeze, publication ancestry and excluded-path diff checks, and publication hash bytes remain unchanged.
208208

209+
Linux App Release, macOS Release, and NPM Placeholder Bootstrap prepare the same pinned owner before their selected-source checkout. Linux keeps one `fetch --quiet origin main` with its 120-second deadline, then performs tag peeling and main ancestry locally without operation deadlines; ordinary ancestry nonzero retains the existing main-reachability rejection, while lifecycle failure or cancellation cannot publish `tag_sha`. macOS keeps its unbounded `rev-parse HEAD`, exact forced public-branch refspec, checkout-persisted read authentication, and one 120-second fetch before the metadata checker. NPM Placeholder keeps non-Git workflow/target identity rejection before checkout inspection, one 120-second forced main fetch, and two unbounded ancestry checks before publishing the immutable target SHA. None adds retries or backoff. The macOS metadata checker's separately owned ten-minute ancestry subprocess remains outside this explicit workflow-Git adoption.
210+
209211
To use the standalone action from another workflow, pin `openclaw/openclaw/.github/actions/git-owner@<full-40-character-commit-SHA>` to a reviewed revision containing the action. Supply policy from the trusted workflow inline or from the same trusted action package, never from the selected candidate. Within `ci.yml`, the existing bundled-protocol and CI-routing matrix tasks smoke-test the action from the separately pinned `.ci-harness` checkout before Node setup, compare its output and copied bytes, and run owned `git --version` without network access. Other workflows' direct Git commands remain outside this ownership coverage until they adopt it.
210212

211213
## Scope and routing
@@ -217,7 +219,7 @@ Release screenshot routing is deliberately conservative because an app change ca
217219
Separate iOS and macOS Periphery workflows enforce a zero-findings dead-code policy. Each runs only when a non-draft pull request touches its native scan scope, or when manually dispatched.
218220

219221
- **CI workflow edits** validate the Node CI graph, workflow linting, and the Windows lane (`ci.yml` executes it), but do not force iOS, Android, or macOS native builds by themselves; those platform lanes stay scoped to platform source changes.
220-
- **Git-owner changes** to its action, base-commit policy, projection generator, lifecycle tests and support, or named owner-adopting workflows such as Workflow Sanity, QA Profile Evidence, Mantis ref validation/installers/worktrees, and Docs Sync Publish Repo select the existing `macos-node` and Windows lanes. These run native checkout ownership proof without selecting Swift, iOS, or Android jobs; Mac app and shared-native changes retain their existing Mac lanes.
222+
- **Git-owner changes** to its action, base-commit policy, projection generator, lifecycle tests and support, or named owner-adopting workflows such as Workflow Sanity, QA Profile Evidence, Mantis ref validation/installers/worktrees, Docs Sync Publish Repo, OpenClaw Performance, and the Linux/macOS/npm-placeholder release admission jobs select the existing `macos-node` and Windows lanes. These run native checkout ownership proof without selecting Swift, iOS, or Android jobs; Mac app and shared-native changes retain their existing Mac lanes.
221223
- **macOS Swift runner budgets** are 20 minutes on Blacksmith and 30 minutes on every GitHub-hosted route, including first-attempt pull requests from untrusted contributors.
222224
- **Workflow Sanity** runs `actionlint`, `zizmor` over all workflow YAML files, the composite-action interpolation guard, and the conflict-marker guard. The PR-scoped `security-fast` job also runs `zizmor` over changed workflow files so workflow security findings fail early in the main CI graph.
223225
- **Docs on `main` pushes** are checked by the standalone `Docs` workflow with the same ClawHub docs mirror used by CI, so mixed code+docs pushes do not also queue the CI `check-docs` shard. Pull requests and manual CI still run `check-docs` from CI when docs changed.

‎scripts/ci-changed-scope.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const APPLE_SHARED_CONTRACT_FIXTURE_RE =
4949
const MACOS_NATIVE_RE =
5050
/^(apps\/macos\/|apps\/macos-mlx-tts\/|apps\/shared\/|apps\/swabble\/|Swabble\/)/;
5151
const GIT_OWNER_SCOPE_RE =
52-
/^(?:\.github\/(?:actions\/(?:git-owner|ensure-base-commit|publish-generated-pr|mantis-validate-trusted-ref)\/|workflows\/(?:workflow-sanity|qa-profile-evidence|maturity-scorecard|docs-agent|docs-sync-publish|openclaw-performance|mantis-(?:discord-(?:smoke|status-reactions|thread-attachment)|slack-desktop-smoke|web-ui-chat-proof))\.yml$)|scripts\/generate-ci-git-owner\.mts$|test\/scripts\/(?:ci-(?:checkout|git-owner|linux-git|platform-checkout)\.test(?:-support)?\.ts|generated-publisher\.test-support\.ts|openclaw-performance-(?:workflow\.test(?:-support)?|git-lifecycle\.test)\.ts|fixtures\/ci-platform-checkout\.mjs)$)/;
52+
/^(?:\.github\/(?:actions\/(?:git-owner|ensure-base-commit|publish-generated-pr|mantis-validate-trusted-ref)\/|workflows\/(?:workflow-sanity|qa-profile-evidence|maturity-scorecard|docs-agent|docs-sync-publish|openclaw-performance|linux-app-release|macos-release|npm-placeholder-bootstrap|mantis-(?:discord-(?:smoke|status-reactions|thread-attachment)|slack-desktop-smoke|web-ui-chat-proof))\.yml$)|scripts\/generate-ci-git-owner\.mts$|test\/scripts\/(?:ci-(?:checkout|git-owner|linux-git|platform-checkout)\.test(?:-support)?\.ts|generated-publisher\.test-support\.ts|openclaw-performance-(?:workflow\.test(?:-support)?|git-lifecycle\.test)\.ts|release-workflow-git-lifecycle\.test\.ts|fixtures\/ci-platform-checkout\.mjs)$)/;
5353
const MACOS_SCRIPT_SCOPE_RE =
5454
/^(?:scripts\/(?:check-swift-tools|codesign-mac-app|create-dmg|format-swift|install-swift-tools|install-xcodegen|lint-swift|mac-elevation-host|notarize-mac-artifact|package-mac-app|package-mac-dist|restart-mac|stage-cua-driver-macos|stage-mac-node-worker)\.sh|scripts\/test-macos-native\.mts|scripts\/(?:verify-mac-node-worker(?:-fs)?|lib\/(?:mac-node-worker-proof-state|mac-worker-portability))\.mjs|scripts\/(?:materialize-mac-node-worker|lib\/(?:mac-native-inventory|mac-bundle-mutation))\.py|scripts\/lib\/(?:mac-app-bundle|plistbuddy|swift-toolchain)\.sh|test\/helpers\/mac-(?:native|signing)\.ts|test\/scripts\/(?:codesign-mac-app|create-dmg|mac-elevation-host|mac-node-worker|macos-native-test-launch|notarize-mac-artifact|package-mac-app|package-mac-dist|restart-mac|verify-mac-node-worker-fs)\.test\.ts|test\/scripts\/(?:mac-elevation-artifact|mac-native-fixtures|mac-node-worker-materialization)\.test-support\.ts)$/;
5555
const WORKSPACE_RSYNC_RECEIVER_SCOPE_RE =

‎scripts/test-projects.test-support.mts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,15 @@ const SEMANTIC_TOOLING_TARGET_PATTERNS: Array<[RegExp, string[]]> = [
23472347
/^\.github\/workflows\/openclaw-performance\.yml$/u,
23482348
["openclaw-performance-workflow", "openclaw-performance-git-lifecycle"],
23492349
],
2350+
[/^\.github\/workflows\/linux-app-release\.yml$/u, ["release-workflow-git-lifecycle"]],
2351+
[
2352+
/^\.github\/workflows\/macos-release\.yml$/u,
2353+
["release-workflow-git-lifecycle", packageAcceptance],
2354+
],
2355+
[
2356+
/^\.github\/workflows\/npm-placeholder-bootstrap\.yml$/u,
2357+
["release-workflow-git-lifecycle", "npm-placeholder-publication"],
2358+
],
23502359
[/^\.github\/workflows\/plugin-prerelease\.yml$/u, [pluginPrerelease]],
23512360
[/^\.github\/workflows\/tui-pty\.yml$/u, [packageAcceptance]],
23522361
[
@@ -2396,7 +2405,7 @@ const SEMANTIC_TOOLING_TARGET_PATTERNS: Array<[RegExp, string[]]> = [
23962405
],
23972406
[/^\.github\/workflows\/android-release\.yml$/u, [packageAcceptance, workflowGuards]],
23982407
[
2399-
/^\.github\/(?:actions\/(?:ensure-base-commit|git-owner|publish-generated-pr|mantis-validate-trusted-ref)\/|workflows\/(?:workflow-sanity|qa-profile-evidence|maturity-scorecard|docs-agent|docs-sync-publish|openclaw-performance|mantis-(?:discord-(?:smoke|status-reactions|thread-attachment)|slack-desktop-smoke|web-ui-chat-proof))\.yml$)/u,
2408+
/^\.github\/(?:actions\/(?:ensure-base-commit|git-owner|publish-generated-pr|mantis-validate-trusted-ref)\/|workflows\/(?:workflow-sanity|qa-profile-evidence|maturity-scorecard|docs-agent|docs-sync-publish|openclaw-performance|linux-app-release|macos-release|npm-placeholder-bootstrap|mantis-(?:discord-(?:smoke|status-reactions|thread-attachment)|slack-desktop-smoke|web-ui-chat-proof))\.yml$)/u,
24002409
["ci-git-owner", "ci-linux-git", "ci-platform-checkout"],
24012410
],
24022411
[/^\.github\/actions\/publish-generated-pr\//u, [workflowGuards]],
@@ -3004,7 +3013,7 @@ function resolveDirectToolingReferenceTests(changedPath: string, cwd: string) {
30043013

30053014
function resolveToolingTestTargets(changedPath: string, cwd = process.cwd()) {
30063015
if (
3007-
/^test\/scripts\/(?:ci-(?:checkout|git-owner|linux-git|platform-checkout)\.test(?:-support)?\.ts|generated-publisher\.test-support\.ts|openclaw-performance-(?:workflow\.test(?:-support)?|git-lifecycle\.test)\.ts|fixtures\/ci-platform-checkout\.mjs)$/u.test(
3016+
/^test\/scripts\/(?:ci-(?:checkout|git-owner|linux-git|platform-checkout)\.test(?:-support)?\.ts|generated-publisher\.test-support\.ts|openclaw-performance-(?:workflow\.test(?:-support)?|git-lifecycle\.test)\.ts|release-workflow-git-lifecycle\.test\.ts|fixtures\/ci-platform-checkout\.mjs)$/u.test(
30083017
changedPath,
30093018
)
30103019
) {
@@ -3014,6 +3023,7 @@ function resolveToolingTestTargets(changedPath: string, cwd = process.cwd()) {
30143023
"ci-platform-checkout",
30153024
"openclaw-performance-workflow",
30163025
"openclaw-performance-git-lifecycle",
3026+
"release-workflow-git-lifecycle",
30173027
workflowGuards,
30183028
);
30193029
}

‎src/scripts/ci-changed-scope.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ describe("detectChangedScope", () => {
408408
".github/workflows/qa-profile-evidence.yml",
409409
".github/workflows/docs-sync-publish.yml",
410410
".github/workflows/docs-agent.yml",
411+
".github/workflows/openclaw-performance.yml",
412+
".github/workflows/linux-app-release.yml",
413+
".github/workflows/macos-release.yml",
414+
".github/workflows/npm-placeholder-bootstrap.yml",
411415
".github/actions/mantis-validate-trusted-ref/action.yml",
412416
".github/workflows/mantis-discord-smoke.yml",
413417
".github/workflows/mantis-discord-status-reactions.yml",
@@ -423,6 +427,10 @@ describe("detectChangedScope", () => {
423427
"test/scripts/ci-git-owner.test-support.ts",
424428
"test/scripts/ci-linux-git.test.ts",
425429
"test/scripts/ci-platform-checkout.test.ts",
430+
"test/scripts/openclaw-performance-git-lifecycle.test.ts",
431+
"test/scripts/openclaw-performance-workflow.test-support.ts",
432+
"test/scripts/openclaw-performance-workflow.test.ts",
433+
"test/scripts/release-workflow-git-lifecycle.test.ts",
426434
"test/scripts/fixtures/ci-platform-checkout.mjs",
427435
])("routes Git-owner native proof for %s without selecting app builds", (changedPath) => {
428436
expect(detectChangedScope([changedPath])).toMatchObject({

0 commit comments

Comments
 (0)