Skip to content

Provide signed macOS artifacts - #115169

Merged
thevar1able merged 13 commits into
masterfrom
macos-signing-public
Aug 18, 2026
Merged

thevar1able merged 13 commits into
masterfrom
macos-signing-public

Conversation

@thevar1able

@thevar1able thevar1able commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Provide signed artifacts for macOS.


Workflow [PR]
Sync PR [sync-upstream/pr/115169]

Version info

  • Merged into: 26.8.1.1640 (included in 26.8 and later)
  • Backported to: 26.7.4.57

@thevar1able thevar1able changed the title Macos signing public Provide signed macOS artifacts Aug 17, 2026
@thevar1able
thevar1able force-pushed the macos-signing-public branch from 8d6af43 to 04edf4a Compare August 17, 2026 17:55
@clickhouse-gh

clickhouse-gh Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7eda646]

Summary: ✅


AI Review

Summary

This PR adds Linux-based signing and notarization for the release-branch macOS binaries, then teaches CreateRelease to attach the resulting signed zips to GitHub releases. The overall direction is sound, but I do not think the release path is ready to merge yet: it still lacks any macOS-side proof that the hardened-runtime binary actually launches after signing, and the new "does this commit produce signed assets?" contract can still silently drop those assets instead of failing closed.

Findings

⚠️ Majors

  • [ci/workflows/release_branches.py:31] The PR now makes patch releases depend on sign_macos_binary_*_darwin, but nothing in ReleaseBranchCI ever consumes the signed zip on a macOS runner before CreateRelease ships it. The Linux-side rcodesign verify and notary submission only prove that Apple accepted the archive; they do not prove that the hardened-runtime binary still starts on macOS or that com.apple.security.cs.allow-unsigned-executable-memory is sufficient for ClickHouse's JIT-heavy paths. Suggested fix: add a minimal macOS smoke job that downloads the signed zip and runs at least clickhouse local --query 'SELECT 1' plus a regexp/JIT query.
  • [ci/jobs/scripts/create_release.py:758; ci/jobs/scripts/release_packages.py:95-121] The new signed-asset contract is still inferred from the presence of ci/jobs/sign_macos_binary.py in the release commit, which is an implementation detail rather than a stable capability marker. On top of that, commit_has_macos_signing treats any git cat-file <commit>:path failure as False; in CreateRelease that probe runs inside the treeless partial clone set up by release_job.py, so a transient tree-lookup failure can silently omit clickhouse-macos.zip / clickhouse-macos-aarch64.zip instead of failing the release. Suggested fix: introduce an explicit signed-assets marker/version in the release contract and make the probe raise on any lookup error other than a positively proven "path absent" case.
Final Verdict

Needs changes before merge.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 17, 2026
Comment thread ci/defs/job_configs.py Resolved
Comment thread ci/workflows/pull_request.py Resolved
Comment thread ci/workflows/pull_request.py Resolved
thevar1able added a commit that referenced this pull request Aug 17, 2026
The probe answered the question that was blocking this: public CI *can* sign,
on `amd-release-maker`. Its instances assume `ec2_admin` - the same identity as
the private fleet - and a real `kms:Sign` against the Developer ID key succeeded
there, so no IAM grant is needed after all.

https://github.com/ClickHouse/ClickHouse/actions/runs/32055437965

```
arn:aws:sts::542516086801:assumed-role/ec2_admin/i-0fac39d5fd7d64ba3
kms:DescribeKey -> Enabled, RSA_2048, SIGN_VERIFY
kms:Sign        -> RSASSA_PKCS1_V1_5_SHA_256
```

That pool exists to serve `CreateRelease`, so point the sign jobs at it and take
them out of `MasterCI`. Signing every master commit would put dozens of runs a
day on a pool sized for releases, and nothing consumes a signed master binary:
the only consumer that needs a signature is a release asset, which is what the
Homebrew cask installs. `ReleaseBranchCI` already carries the jobs, and its
cadence matches the pool.

The default pools stay unable to sign - they assume `untrusted_runner`, which
has no KMS access, and it must stay that way because the same role serves pull
request pools.

Related: #115169

Co-Authored-By: Claude Opus 5 <[email protected]>
thevar1able added a commit that referenced this pull request Aug 17, 2026
The validation workflow signed `arm_darwin` only. The Homebrew cask ships intel
as well, and Apple issues a notarization ticket per `cdhash` per architecture, so
`amd_darwin` needs its own signature and its own submission. Build and sign both.

The identity assertions were weaker than they looked.
`rcodesign print-signature-info` emits an `apple_team_id` line per certificate in
the chain - the intermediate reports `G2`, the root `Apple Certification
Authority` - so a grep over the whole output would have accepted a signature made
with a foreign leaf. Assert the first line instead, the chain being embedded leaf
first, and check the leaf subject of the committed chain file alongside the
existing public-key comparison against KMS.

Related: #115169

Co-Authored-By: Claude Opus 5 <[email protected]>
Comment thread ci/defs/job_configs.py Resolved
@thevar1able
thevar1able force-pushed the macos-signing-public branch from c3e6b83 to 7bcd2f3 Compare August 17, 2026 21:57
thevar1able and others added 4 commits August 17, 2026 23:59
The image provides tooling to sign and notarize macOS binaries from Linux:
`rcodesign` built with the `pkcs11` feature, the `aws-kms-pkcs11` module
pinned by release tag and `sha256`, and `p11-kit`. The signing key stays in
AWS KMS.

It derives from `clickhouse/fasttest`, like `clickhouse/binary-builder` and
`clickhouse/cctools`. AMD only. No job uses the image yet.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`clickhouse/macos-signer` does not exist on Docker Hub and the CI robot lacks the
scope to create it on push, so the manifest merge failed with:

    ERROR: pull access denied, repository does not exist or may require
           authorization: server message: insufficient_scope: authorization failed

`clickhouse/utils` already exists and is empty, so it needs no new repository. A
general-purpose name also suits an image that carries standalone tooling rather
than only the signing tools.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The published macOS binaries are unsigned, so a browser download is quarantined and Gatekeeper refuses to run it. The Homebrew cask disables itself on 2026-09-01 for exactly this reason.

The darwin builds now also provide the plain (not self-extracting) Mach-O, because a self-extracting archive cannot carry a signature - signing it would discard the payload. A job then signs that binary with `rcodesign`, using a Developer ID certificate whose key lives in AWS KMS and is used for one RSA operation, so no key material ever reaches the runner, and submits the result to Apple's Notary API from Linux - no macOS runner is involved anywhere.

The hardened runtime is mandatory for notarization and kills unsigned executable memory, which ClickHouse's regexp JIT allocates, hence `com.apple.security.cs.allow-unsigned-executable-memory` in the entitlements.

Signing runs on `amd-release-maker` in `ReleaseBranchCI` only: that pool's identity is the only one that can reach the key, and a release asset is the sole consumer of a signature.

Nothing is published yet - the signed zip is a CI artifact.

Co-Authored-By: Claude Opus 5 <[email protected]>
@thevar1able
thevar1able force-pushed the macos-signing-public branch from 7bcd2f3 to 6b1caac Compare August 17, 2026 22:03
thevar1able and others added 5 commits August 18, 2026 00:11
`CreateRelease` now also downloads the signed, notarized zip each sign job uploads and attaches it to the GitHub release as `clickhouse-macos.zip` and `clickhouse-macos-aarch64.zip`, alongside the existing self-extracting binaries rather than replacing them.

Two knock-on changes. The sign jobs lose `allow_failure`, because a release now needs their output. And their cache digest gains the build digest paths: it previously hashed only the signing script and certificate, so on a release branch every commit after the first would hit the cache, upload nothing under its own SHA, and leave every commit unreleasable - `release_build_artifacts_ready` requires the exact object key per commit.

Co-Authored-By: Claude Opus 5 <[email protected]>
One consumer, and `ci/workflows/create_release.py` already writes the label list literally.

Co-Authored-By: Claude Opus 5 <[email protected]>
Tools, then committed inputs, then working files, then KMS, then the Apple identity, then the notary credentials. Pure reordering.

Co-Authored-By: Claude Opus 5 <[email protected]>
Job assets live in `ci/jobs/scripts/<area>/` - `clickbench/create.sql`, `fuzzer/fuzz-server-settings.xml`, `docker_server/config.sh`. `ci/signing` was the only asset directory at the top of `ci/`, where everything else is infrastructure.

Co-Authored-By: Claude Opus 5 <[email protected]>
Access is settled, and the `sign` step reports the same permission error on its own. The probe also issued a real `kms:Sign` of a dummy message on every run, doubling the signature count in CloudTrail.

Co-Authored-By: Claude Opus 5 <[email protected]>
Comment thread ci/jobs/scripts/release_packages.py Resolved
for job in JobConfigs.special_build_jobs
if any(t in job.name for t in ("darwin",))
],
*JobConfigs.sign_macos_binary_jobs,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow now publishes CH_*_DARWIN_SIGNED, but nothing in ReleaseBranchCI ever consumes those artifacts on a macOS runner before CreateRelease ships them. The Linux-side checks in sign_macos_binary.py prove that rcodesign and the notary service accept the archive, but they do not prove the hardened-runtime binary still starts on macOS or that the allow-unsigned-executable-memory entitlement is sufficient for ClickHouse's JIT paths.

Please add a minimal macOS smoke job that downloads the signed zip and runs at least clickhouse local --query 'SELECT 1' plus a regexp/JIT query before making patch releases depend on this output.

thevar1able and others added 2 commits August 18, 2026 00:44
`ReleaseBranchCI` is a `push` workflow, so a release branch runs its own workflow definition, while `AutoReleases` and `CreateRelease` run from `master`. Release branches cut before signing existed never upload the zips, so demanding them unconditionally would reject every candidate commit on 25.8, 26.3, 26.5, 26.6 and 26.7 and block their patch releases.

Read the requirement off the release commit instead: `commit_has_macos_signing` asks git whether that commit's tree carries the signing job. It raises when the commit is not present locally rather than assuming no signing, which would silently publish a release without its signed assets.

Co-Authored-By: Claude Opus 5 <[email protected]>
@thevar1able
thevar1able requested a review from maxknv August 17, 2026 22:46
@thevar1able
thevar1able marked this pull request as ready for review August 17, 2026 22:46
@clickhouse-gh clickhouse-gh Bot added pr-build Pull request with build/testing/packaging improvement and removed pr-ci labels Aug 17, 2026
yield package_arch, sign_macos_job_name(package_arch)


def commit_has_macos_signing(commit_sha: str) -> bool:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit_has_macos_signing is using the presence of ci/jobs/sign_macos_binary.py as the proxy for "this release commit uploads sign_macos_binary_*_darwin/clickhouse-macos.zip". That is an implementation detail, not the contract.

Because AutoReleases and CreateRelease run from master against older release-branch commits, a selective backport or a later master-only rename/move of this helper makes the gate return the wrong answer: false positives block patch releases waiting for artifacts that can never exist, and false negatives silently stop publishing the signed macOS assets.

This needs an explicit, stable marker for the release-asset contract (or another direct proof of signed-zip production), not a helper-script path.

`ci/tests/` runs where the workspace is not a usable git repository - `git rev-parse HEAD` exits 128 - so the test cannot read a real commit's tree. Patch `commit_has_macos_signing` instead and drive both shapes, with and without the signed zips.

Co-Authored-By: Claude Opus 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 7eda646bd with master 91e236145 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 48e35ab80; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 702.05 MiB 699.03 MiB -3.02 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

7 translation units recompiled, 14 s compile time in total, 7 of them have a recent master baseline.

Job report

Comment thread ci/defs/job_configs.py Outdated

sign_macos_binary_jobs = Job.Config(
name=JobNames.SIGN_MACOS,
runs_on=["self-hosted", "amd-release-maker"],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a standard runner? style-cheker-aarch64?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread ci/workflows/kms_probe.py Outdated

PROBE_BRANCH = "macos-signing-public"

workflow = Workflow.Config(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leaves a permanent push workflow in master that mounts SECRETS and performs real kms:Sign probes against the production macOS-signing key on a fixed branch name. That widens the signing-key surface beyond the actual release path: any future push to macos-signing-public will re-enable it.

The current head already shows this is not hypothetical: the KMSProbe report for 18709c2e has amd-small, amd-medium, amd-large, and style-checker all OK. If this workflow is only temporary runner telemetry, it should not merge as a normal push trigger. Please drop it before merge, or convert it to a maintainer-only workflow_dispatch path with non-production credentials.

Every unprefixed amd pool assumes `ec2_admin` and completed a real `kms:Sign`: `amd-small`, `amd-medium`, `amd-large` and `style-checker`. Only pull request pools carry `untrusted_runner`, which is why yesterday's `pr-amd-small` probe reported no access.

https://github.com/ClickHouse/ClickHouse/actions/runs/32141517638

Signing is light - fetch an artifact, one KMS signature, then wait on Apple - so it belongs on the cheapest pool, and the release pool stays clear for releases.

Co-Authored-By: Claude Opus 5 <[email protected]>
@thevar1able
thevar1able force-pushed the macos-signing-public branch from 18709c2 to 7eda646 Compare August 18, 2026 13:32
@ClickHouse ClickHouse deleted a comment from clickhouse-gh Bot Aug 18, 2026

def __init__(self, release, commit_sha, version):
assert version.startswith(release), "Invalid release branch or version"
with_signed_macos = release_packages.commit_has_macos_signing(commit_sha)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateRelease is treating commit_has_macos_signing as a plain boolean, but in the actual release pipeline that helper runs after release_job.py has converted the checkout into a treeless partial clone. git cat-file <commit>:ci/jobs/sign_macos_binary.py may therefore need a lazy fetch of the commit's tree, and any transient fetch/auth failure currently becomes False here.

That means this step can publish a release without clickhouse-macos.zip / clickhouse-macos-aarch64.zip instead of failing closed. Please make the probe raise on lookup errors and return False only when it can positively prove the path is absent, or replace it with an explicit signed-assets contract marker.

@thevar1able
thevar1able enabled auto-merge August 18, 2026 14:18
@thevar1able
thevar1able added this pull request to the merge queue Aug 18, 2026
Merged via the queue into master with commit e595641 Aug 18, 2026
181 checks passed
@thevar1able
thevar1able deleted the macos-signing-public branch August 18, 2026 15:18
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 18, 2026
thevar1able added a commit that referenced this pull request Aug 18, 2026
Keep only the producing side: the sign jobs, the plain darwin artifact, the `clickhouse/utils` image and the signing assets. 26.7 has none of the release tooling this PR also touched - `release_packages.py`, `auto_release_job.py` and its test do not exist there - and `CreateRelease` runs from `master` anyway, so publishing needs nothing on this branch. Left `create_release.py` at the 26.7 version too: the auto-merge had inserted calls to `release_packages`, which would have raised `NameError` on every 26.7 release.

Co-Authored-By: Claude Opus 5 <[email protected]>
robot-ch-test-poll added a commit that referenced this pull request Aug 18, 2026
Cherry pick #115169 to 26.7: Provide signed macOS artifacts
clickhouse-gh Bot added a commit that referenced this pull request Aug 18, 2026
Backport #115169 to 26.7: Provide signed macOS artifacts
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 18, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-build Pull request with build/testing/packaging improvement pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.7-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants