diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 27502f66c87..f1007d4fdc7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -28,3 +28,7 @@ jobs: app-name: photocraft manual-actors: '[]' craft-fonts-ref: cc9269cd8d8258785dac603fba3122e5d2556795 + # One producer run builds every listed platform for one all-or-nothing release. The pinned + # shared revision has no `platforms` input or Linux leg; re-pin only to a reviewed commit + # that defines both before any activation. + platforms: '["windows-x86_64","linux-x86_64"]' diff --git a/.github/workflows/packaging-lint.yml b/.github/workflows/packaging-lint.yml index 3ed2d5e0ddc..0f1013b0085 100644 --- a/.github/workflows/packaging-lint.yml +++ b/.github/workflows/packaging-lint.yml @@ -5,9 +5,9 @@ name: Packaging lint on: push: branches: [main, release] - paths: [".github/workflows/**", ".github/actionlint.yaml", "packaging/**", "assets/app-icon/**", "docs/mcp.md", "docs/control-protocol.md"] + paths: [".github/workflows/**", ".github/actionlint.yaml", "packaging/**", "assets/app-icon/**", "docs/mcp.md", "docs/control-protocol.md", "docs/nightly-signing-policy.example.json", ".github/nightly-signing-policy.json", ".github/nightly-linux-signing-key.asc", "sonar-project.properties"] pull_request: - paths: [".github/workflows/**", ".github/actionlint.yaml", "packaging/**", "assets/app-icon/**", "docs/mcp.md", "docs/control-protocol.md"] + paths: [".github/workflows/**", ".github/actionlint.yaml", "packaging/**", "assets/app-icon/**", "docs/mcp.md", "docs/control-protocol.md", "docs/nightly-signing-policy.example.json", ".github/nightly-signing-policy.json", ".github/nightly-linux-signing-key.asc", "sonar-project.properties"] workflow_dispatch: permissions: diff --git a/docs/nightly-release-preparation.md b/docs/nightly-release-preparation.md index 2d5598cb64e..8faf7477d0c 100644 --- a/docs/nightly-release-preparation.md +++ b/docs/nightly-release-preparation.md @@ -1,4 +1,4 @@ -# Windows release-ref nightly: source preparation +# Windows and Linux release-ref nightly: source preparation **Not activated or qualified.** No production signing policy is installed. The producer and signer workflows are dormant `.yml` registrations, not an activated signing pipeline. @@ -10,6 +10,18 @@ Shared tooling is pinned to `077d4657f71527141717a0dfbc908a217460eabf`, the craf main commit that merged [#330](https://github.com/storytold/craft-common-actions/pull/330); this is reviewed source availability, not provider, queue, native signing or crypto qualification. Existing stable workflows are unchanged. + +**Linux x86_64 row (dormant).** The producer caller lists `platforms: '["windows-x86_64","linux-x86_64"]'` +on its single, still literally-off job: one producer run builds every listed platform for one +all-or-nothing release, and the release-ref signer admits platforms only from the protected policy, +so there is no separate Linux caller job. The pinned `077d4657` shared revision has **no +`platforms` input and no Linux leg**, and its release validator admits only `windows-x86_64`. +The agreed shared interface (`platforms` on `nightly-unsigned.yml`, policy v3 below) must land in a +reviewed public commit and the callers must be re-pinned to it before any activation; dispatching +against the current pin would be refused as an undefined input. The shared Linux leg runs the app's +unchanged `packaging/linux/nightly.sh --arch x86_64` (GUI-only `photocraft--linux-x86_64-nightly.tar.gz`). +A local build of that script is not a native launch: launch, profile isolation beside stable and +the Launcher install still need Linux desktop QA. This is not a hosted no-key test, a native signing result or a working nightly feed. ## Ownership and interface @@ -49,7 +61,8 @@ This is not a hosted no-key test, a native signing result or a working nightly f empty debt set, invented workflow ID or guessed publisher subject. The adjacent [`nightly-signing-policy.example.json`](nightly-signing-policy.example.json) is intentionally invalid (`null` unresolved values), not installable configuration. Install only independently -read, reviewed real values under explicit schema `craft-nightly-release-policy/v2`: +read, reviewed real values under explicit schema `craft-nightly-release-policy/v3` (v2 top-level fields +without `platform`, `unsigned_artifact_name` and `windows_publisher_subject`, plus a `platforms` map): | Field | Required source of authority | |---|---| @@ -57,14 +70,16 @@ read, reviewed real values under explicit schema `craft-nightly-release-policy/v | `producer_workflow_id`, `producer_workflow_path` | Real default-branch registration ID and `.github/workflows/nightly.yml` | | `producer_tooling_revision`, `producer_workflow_ref` | Approved shared unsigned producer/attester commit and exact reusable path at that commit | | `signer_workflow_path`, `signer_tooling_revision` | `.github/workflows/nightly-sign.yml` and reviewed public shared signer commit | -| `release_branch`, `platform` | `release`, `windows-x86_64` only | +| `release_branch`, `platforms` keys | `release`; exactly the producer's `platforms` list and the targets admitted in the shared registry (`windows-x86_64`, `linux-x86_64`) | | `manual_actors` | Empty by default; reviewed manual producer/signer and rerun authority only | | `automatic_signer_actors` | Empty by default; separate reviewed automatic-only authority for signer attempt 1 after authenticating a scheduled producer attempt 1; no manual producer or rerun grant | -| `max_age_seconds`, `max_artifact_bytes`, `unsigned_artifact_name` | Reviewed bounded age/size and fixed unsigned artifact kind/prefix; actual upload/discovery name is that prefix + `-` + authenticated producer run ID + `-` + authenticated producer attempt, never a caller pattern or substitution | +| `max_age_seconds`, `max_artifact_bytes`, `platforms..unsigned_artifact_name` | Reviewed bounded age/size and each platform's fixed unsigned artifact kind/prefix; actual upload/discovery name is that prefix + `-` + authenticated producer run ID + `-` + authenticated producer attempt, never a caller pattern or substitution | | `candidate_policy` | Full reviewed `craft-nightly-candidate-policy/v3` with real required workflow/job/check/app IDs, Sonar organization/project/issue types/conditions and exact approved debt fingerprints; provider configuration is trusted as resolved, not a pinned scan inventory | -| `windows_publisher_subject` | Exact independently reviewed protected policy string used by both signer and fresh credentialless Windows publisher; nonempty, at most 2048 characters, no CR/LF/NUL; verified native subject must match exactly, never an artifact/caller input | +| `platforms.linux-x86_64.trust.fingerprint` | Full primary fingerprint of the stable Linux release key, independently reviewed; the release checkout must also hold exactly that one public key at `.github/nightly-linux-signing-key.asc`, and the existing `LINUX_SIGNING_KEY` must be in the `release` environment only | +| `platforms.windows-x86_64.trust.publisher_subject` | Exact independently reviewed protected policy string used by both signer and fresh credentialless Windows publisher; nonempty, at most 2048 characters, no CR/LF/NUL; verified native subject must match exactly, never an artifact/caller input | -Live admission requires explicit policy v2; historical v1 retains its exact old fields and +Live admission requires explicit policy v3 once the shared parser lands it; v2 is single-platform +Windows only and is not silently migrated. Historical v1 retains its exact old fields and broad manual-list semantics, and is not silently migrated or accepted for live admission. The v2 actor lists are separate, bounded and case-normalized; overlaps refuse. An automatic-only actor may authorize **only signer attempt 1**, after the validator authenticates a **scheduled diff --git a/docs/nightly-signing-policy.example.json b/docs/nightly-signing-policy.example.json index 8157e7fb5ec..40e3720aa4a 100644 --- a/docs/nightly-signing-policy.example.json +++ b/docs/nightly-signing-policy.example.json @@ -1,5 +1,5 @@ { - "schema": "craft-nightly-release-policy/v2", + "schema": "craft-nightly-release-policy/v3", "repository": "storytold/photocraft", "repository_id": null, "producer_workflow_id": null, @@ -10,7 +10,6 @@ "signer_tooling_revision": null, "release_branch": "release", "manual_actors": [], - "platform": "windows-x86_64", "max_age_seconds": null, "candidate_policy": { "schema": "craft-nightly-candidate-policy/v3", @@ -30,8 +29,20 @@ "debt": null } }, - "unsigned_artifact_name": null, "max_artifact_bytes": null, - "windows_publisher_subject": null, - "automatic_signer_actors": [] + "automatic_signer_actors": [], + "platforms": { + "windows-x86_64": { + "unsigned_artifact_name": null, + "trust": { + "publisher_subject": null + } + }, + "linux-x86_64": { + "unsigned_artifact_name": null, + "trust": { + "fingerprint": null + } + } + } } diff --git a/packaging/nightly-release-tests.py b/packaging/nightly-release-tests.py index e20a3f67757..70a472031e7 100644 --- a/packaging/nightly-release-tests.py +++ b/packaging/nightly-release-tests.py @@ -71,6 +71,31 @@ def literal_off(condition): return depth == 0 +NIGHTLY_PLATFORMS = ("windows-x86_64", "linux-x86_64", "macos-aarch64") + + +def producer_platforms(source): + """Read the one producer job's literal platform list; a narrow source guard, not YAML. + + One producer run builds every listed platform for one all-or-nothing release, so the + list must be a compact JSON list of distinct known platforms that keeps Windows. + """ + rows = re.findall(r"(?m)^ platforms: (.*)$", source) + if len(rows) != 1: + raise ValueError("exactly one producer platform list is required") + literal = re.fullmatch(r"'(\[[^']*\])'", rows[0]) + if literal is None: + raise ValueError("the platform list must be one single-quoted literal") + platforms = json.loads(literal[1]) + if not isinstance(platforms, list) or json.dumps(platforms, separators=(",", ":")) != literal[1]: + raise ValueError("the platform list must be compact JSON") + if len(set(platforms)) != len(platforms) or not set(platforms) <= set(NIGHTLY_PLATFORMS): + raise ValueError("platforms must be distinct known nightly targets") + if "windows-x86_64" not in platforms: + raise ValueError("the Windows row stays in the producer") + return platforms + + class Response: status = 204 @@ -205,24 +230,39 @@ class TrustedSourcePreparation(unittest.TestCase): self.assertEqual(set(entries), expected, "classify exact fixtures, never production helpers or wildcard scope") self.assertEqual(len(entries), len(expected), "duplicate fixture classification") - def test_policy_example_keeps_explicit_v2_and_no_actor_authority(self): + def test_policy_example_keeps_explicit_v3_and_no_actor_authority(self): policy = json.loads((ROOT / "docs/nightly-signing-policy.example.json").read_text()) expected = {"schema", "repository", "repository_id", "producer_workflow_id", "producer_workflow_path", "producer_tooling_revision", "producer_workflow_ref", "signer_workflow_path", "signer_tooling_revision", "release_branch", "manual_actors", - "automatic_signer_actors", "platform", "max_age_seconds", "candidate_policy", - "unsigned_artifact_name", "max_artifact_bytes", "windows_publisher_subject"} - self.assertEqual(set(policy), expected, "no v1 fallback or implicit actor-field migration") - self.assertEqual(policy["schema"], "craft-nightly-release-policy/v2") + "automatic_signer_actors", "max_age_seconds", "candidate_policy", + "max_artifact_bytes", "platforms"} + self.assertEqual(set(policy), expected, "no single-platform v2 fields or implicit migration") + self.assertEqual(policy["schema"], "craft-nightly-release-policy/v3") self.assertEqual(policy["manual_actors"], []) self.assertEqual(policy["automatic_signer_actors"], []) for key in ("repository_id", "producer_workflow_id", "producer_tooling_revision", "producer_workflow_ref", "signer_tooling_revision", "max_age_seconds", - "unsigned_artifact_name", "max_artifact_bytes", "windows_publisher_subject"): + "max_artifact_bytes"): with self.subTest(unresolved=key): self.assertIsNone(policy[key], "the example must not invent production authority") - installed = ROOT / ".github/nightly-signing-policy.json" - self.assertFalse(installed.exists() or installed.is_symlink(), "activation is a separately reviewed change") + for installed in (".github/nightly-signing-policy.json", ".github/nightly-linux-signing-key.asc"): + path = ROOT / installed + with self.subTest(installed=installed): + self.assertFalse(path.exists() or path.is_symlink(), "activation is a separately reviewed change") + + def test_policy_platforms_are_exactly_what_the_producer_builds(self): + policy = json.loads((ROOT / "docs/nightly-signing-policy.example.json").read_text()) + built = producer_platforms((ROOT / ".github/workflows/nightly.yml").read_text()) + self.assertIn("linux-x86_64", built) + self.assertEqual(set(policy["platforms"]), set(built), "a built platform without policy, or the reverse") + trust = {"windows-x86_64": "publisher_subject", "linux-x86_64": "fingerprint"} + for platform, row in policy["platforms"].items(): + with self.subTest(platform=platform): + self.assertEqual(set(row), {"unsigned_artifact_name", "trust"}) + self.assertEqual(set(row["trust"]), {trust[platform]}, "each platform has only its own trust anchor") + self.assertIsNone(row["unsigned_artifact_name"]) + self.assertIsNone(row["trust"][trust[platform]], "the example must not invent a trust anchor") def test_candidate_example_has_exact_v3_fields_without_provider_scope_claim(self): candidate = json.loads((ROOT / "docs/nightly-signing-policy.example.json").read_text())["candidate_policy"] @@ -245,6 +285,32 @@ class TrustedSourcePreparation(unittest.TestCase): for scalar, folded in conditions: self.assertTrue(literal_off(folded if scalar == ">-" else scalar), "nightly activation requires reviewed test update") + def test_one_producer_and_one_signer_job_carry_every_platform(self): + for name, job in (("nightly.yml", "unsigned"), ("nightly-sign.yml", "release")): + jobs = (ROOT / ".github/workflows" / name).read_text().split("\njobs:\n", 1)[1] + with self.subTest(workflow=name): + self.assertEqual(re.findall(r"(?m)^ ([^\s#][^:]*):", jobs), [job], + "a platform is a list entry, not a separately activatable job") + signer = (ROOT / ".github/workflows/nightly-sign.yml").read_text() + self.assertNotRegex(signer, r"(?m)^\s*platforms?:", "the release policy, not the caller, admits platforms") + + def test_malformed_or_narrowed_platform_lists_are_rejected(self): + source = (ROOT / ".github/workflows/nightly.yml").read_text() + current = "platforms: '[\"windows-x86_64\",\"linux-x86_64\"]'" + self.assertIn(current, source) + for new in ("platforms: '[\"linux-x86_64\"]'", + "platforms: '[\"windows-x86_64\",\"linux-x86_64\",\"linux-x86_64\"]'", + "platforms: '[\"windows-x86_64\",\"linux-arm64\"]'", + "platforms: '[\"windows-x86_64\", \"linux-x86_64\"]'", + "platforms: [\"windows-x86_64\",\"linux-x86_64\"]", + "platforms: ${{ vars.NIGHTLY_PLATFORMS }}", + "platforms: '{\"windows-x86_64\":1}'", + current + "\n " + current): + with self.subTest(change=new), self.assertRaises(ValueError): + producer_platforms(source.replace(current, new)) + with self.assertRaises(ValueError): + producer_platforms(source.replace(" " + current + "\n", "")) + def test_dormancy_guard_rejects_activation_and_top_level_or(self): for condition in ("true", "vars.ENABLE_NIGHTLY", "false || true", "false && true || true", "false && (true || true", "false && true) || true"):