Skip to content

Commit e2af1ca

Browse files
authored
fix: bind ClawHub publication source to the authorized commit (#135368)
1 parent 1d725f3 commit e2af1ca

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎.github/workflows/plugin-clawhub-release.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,8 @@ jobs:
637637
tags: ${{ matrix.plugin.publishTag }}
638638
source_repo: ${{ github.repository }}
639639
source_commit: ${{ needs.preview_plugins_clawhub.outputs.ref_revision }}
640-
source_ref: ${{ inputs.release_tag != '' && format('refs/tags/{0}', inputs.release_tag) || github.ref }}
640+
# ClawHub requires the token's candidate SHA in both fields, not a mutable tag or tooling ref.
641+
source_ref: ${{ needs.preview_plugins_clawhub.outputs.ref_revision }}
641642
source_path: ${{ matrix.plugin.packageDir }}
642643
inspector_artifact_name: ${{ matrix.plugin.artifactName }}-inspector
643644
publish_json_artifact_name: ${{ matrix.plugin.artifactName }}-publish-json

‎test/scripts/clawhub-parent-authorization.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { readFileSync } from "node:fs";
12
import { describe, expect, it } from "vitest";
3+
import { parse } from "yaml";
24
import {
35
clawHubIdentityFromEnvironment,
46
createClawHubParentAuthorization,
@@ -44,6 +46,26 @@ function transactions(count = 1) {
4446
}
4547

4648
describe("ClawHub parent publication authorization", () => {
49+
it("publishes source metadata for the exact candidate sealed into authorization", () => {
50+
const workflow = parse(
51+
readFileSync(".github/workflows/plugin-clawhub-release.yml", "utf8"),
52+
) as {
53+
jobs: Record<
54+
string,
55+
{ steps?: { env?: Record<string, string> }[]; with?: Record<string, string> }
56+
>;
57+
};
58+
const candidate = workflow.jobs.seal_clawhub_transactions?.steps?.find(
59+
(step) => step.env?.TARGET_SHA,
60+
)?.env?.TARGET_SHA;
61+
expect(candidate).toBe("${{ needs.preview_plugins_clawhub.outputs.ref_revision }}");
62+
// ClawHub compares both source fields with the candidate SHA in the publish token.
63+
expect(workflow.jobs.publish_plugins_clawhub?.with).toMatchObject({
64+
source_commit: candidate,
65+
source_ref: candidate,
66+
});
67+
});
68+
4769
it("binds the full release roster beyond 8 KiB without mixing parent and child refs", () => {
4870
const sealed = transactions(89);
4971
const receipt = createClawHubParentAuthorization(sealed, "automated-awaited");

0 commit comments

Comments
 (0)