@@ -32,6 +32,7 @@ import {
3232 validateReleasePreflightTagIdentity ,
3333} from "./npm-preflight-tooling-identity.mjs" ;
3434import { validatePluginSdkApiReleaseEvidence } from "./plugin-sdk-api-release-evidence.mjs" ;
35+ import { verifyReleaseToolingIdentity } from "./release-tooling-identity.mjs" ;
3536import {
3637 dedicatedSectionVersionForTag ,
3738 extractChangelogReleaseSections ,
@@ -108,6 +109,7 @@ const RELEASE_CANDIDATE_STATE_KEYS = [
108109 "targetSha" ,
109110 "toolingSha" ,
110111 "workflowRef" ,
112+ "publishWorkflowRef" ,
111113 "provider" ,
112114 "mode" ,
113115 "releaseProfile" ,
@@ -145,6 +147,7 @@ Options:
145147 --tag <tag> Planned release tag. The tag must not exist yet.
146148 --target-sha <sha> Frozen release SHA. Defaults to the current HEAD.
147149 --workflow-ref <ref> Trusted workflow ref. Default: main; matching Tideclaw branch required for alpha.
150+ --publish-workflow-ref <tag> Protected publication tooling tag matching the trusted helper checkout.
148151 --repo <owner/repo> GitHub repo. Default: ${ DEFAULT_REPO }
149152 --full-release-run <id> Reuse successful Full Release Validation run.
150153 --npm-preflight-run <id> Reuse successful OpenClaw NPM Release preflight run.
@@ -207,6 +210,7 @@ export function parseArgs(argv: string[]) {
207210 tag : "" ,
208211 targetSha : "" ,
209212 workflowRef : "" ,
213+ publishWorkflowRef : "" ,
210214 fullReleaseRunId : "" ,
211215 npmPreflightRunId : "" ,
212216 pluginSdkApiAcknowledgement : "" ,
@@ -224,6 +228,7 @@ export function parseArgs(argv: string[]) {
224228 [ "--tag" , "tag" ] ,
225229 [ "--target-sha" , "targetSha" ] ,
226230 [ "--workflow-ref" , "workflowRef" ] ,
231+ [ "--publish-workflow-ref" , "publishWorkflowRef" ] ,
227232 [ "--repo" , "repo" ] ,
228233 [ "--full-release-run" , "fullReleaseRunId" ] ,
229234 [ "--npm-preflight-run" , "npmPreflightRunId" ] ,
@@ -286,6 +291,15 @@ export function parseArgs(argv: string[]) {
286291 if ( ! options . tag . includes ( "-alpha." ) && options . workflowRef !== "main" ) {
287292 throw new Error ( "--workflow-ref must be main for regular beta and stable release candidates" ) ;
288293 }
294+ if (
295+ options . publishWorkflowRef &&
296+ ( options . tag . includes ( "-alpha." ) ||
297+ ! / ^ r e l e a s e - p u b l i s h \/ [ a - f 0 - 9 ] { 12 } - [ 1 - 9 ] [ 0 - 9 ] * $ / u. test ( options . publishWorkflowRef ) )
298+ ) {
299+ throw new Error (
300+ "--publish-workflow-ref must name a protected release-publish tag for a regular release" ,
301+ ) ;
302+ }
289303 options . releaseProfile ||=
290304 options . tag . includes ( "-alpha." ) || options . tag . includes ( "-beta." ) ? "beta" : "stable" ;
291305 if ( ! [ "beta" , "stable" , "full" ] . includes ( options . releaseProfile ) ) {
@@ -451,6 +465,7 @@ export function buildReleaseCandidateState(
451465 targetSha,
452466 toolingSha,
453467 workflowRef : options . workflowRef ,
468+ publishWorkflowRef : options . publishWorkflowRef ,
454469 provider : options . provider ,
455470 mode : options . mode ,
456471 releaseProfile : options . releaseProfile ,
@@ -1461,7 +1476,9 @@ function pluginPlanArgs(options: ReturnType<typeof parseArgs>) {
14611476
14621477function collectPluginPlan ( script : string , options : ReturnType < typeof parseArgs > ) : unknown {
14631478 return JSON . parse (
1464- run ( "node" , [ "--import" , "tsx" , script , ...pluginPlanArgs ( options ) ] , { capture : true } ) ,
1479+ run ( "node" , [ "--import" , "tsx" , join ( TOOLING_ROOT , script ) , ...pluginPlanArgs ( options ) ] , {
1480+ capture : true ,
1481+ } ) ,
14651482 ) ;
14661483}
14671484
@@ -1505,7 +1522,8 @@ export function buildPublishCommand(
15051522 npmPreflightSource ?: Awaited < ReturnType < typeof validateNpmPreflightRunSource > > ,
15061523) {
15071524 const workflowRef =
1508- npmPreflightSource ?. workflowRef ??
1525+ options . publishWorkflowRef ||
1526+ npmPreflightSource ?. workflowRef ||
15091527 ( options . tag . includes ( "-alpha." ) ? options . workflowRef : "main" ) ;
15101528 if ( options . tag . includes ( "-alpha." ) && ! TIDECLAW_ALPHA_WORKFLOW_REF_PATTERN . test ( workflowRef ) ) {
15111529 throw new Error (
@@ -1872,6 +1890,15 @@ async function main() {
18721890 toolingTrackedStatus : gitTrackedStatus ( TOOLING_ROOT ) ,
18731891 workflowRef : options . workflowRef ,
18741892 } ) ;
1893+ // Publication may use repaired tooling while the prepared tarball retains its original producer.
1894+ const publishWorkflowIdentity = options . publishWorkflowRef
1895+ ? verifyReleaseToolingIdentity ( {
1896+ repository : options . repo ,
1897+ workflowRef : options . publishWorkflowRef ,
1898+ workflowFullRef : `refs/tags/${ options . publishWorkflowRef } ` ,
1899+ workflowSha : toolingSha ,
1900+ } )
1901+ : undefined ;
18751902 options . parallelsRegistryPackageArtifacts = options . parallelsRegistryPackageArtifactDirs . map (
18761903 ( artifactDir ) =>
18771904 validateParallelsRegistryPackageArtifact ( artifactDir , {
@@ -2148,6 +2175,7 @@ async function main() {
21482175 tag : options . tag ,
21492176 targetSha,
21502177 workflowRef : options . workflowRef ,
2178+ publishWorkflowIdentity,
21512179 npmDistTag : options . npmDistTag ,
21522180 fullReleaseValidationRunId : options . fullReleaseRunId ,
21532181 fullReleaseValidationRunAttempt : fullRun . runAttempt ,
0 commit comments