|
| 1 | +# MacOS Artifact Signing |
| 2 | + |
| 3 | +> since 0.22.0 |
| 4 | +
|
| 5 | +cargo-dist can automatically codesign Mac executables using Apple's builtin tooling. |
| 6 | + |
| 7 | +## Quickstart |
| 8 | + |
| 9 | +### Part 1: Provision a certificate and set up your repository with it |
| 10 | + |
| 11 | +<!-- TODO: Document the process of obtaining and exporting the signature. --> |
| 12 | + |
| 13 | +3. **Export the certificate to disk** |
| 14 | + |
| 15 | + Locate your certificate within Keychain, then right-click and select "Export". Ensure that you've selected the "Personal Information Exchange (.p12)" format at the bottom of the export window. Once you've selected a filename, Keychain will prompt you for a password to protect the exported item. Select a secure password, *and ensure remember it* - you'll need this for the next step. |
| 16 | + |
| 17 | +4. **Encode the certificate via base64** |
| 18 | + |
| 19 | + In order to add the certificate to your GitHub secrets in a future step, we'll need to convert it to a text-based format. To do that, we'll use base64. In your terminal, run the following: |
| 20 | + |
| 21 | + ```sh |
| 22 | + base64 < PATH_TO_YOUR_CERT |
| 23 | + ``` |
| 24 | + |
| 25 | + (Instead of typing the path to your certificate, you can also drag and drop it onto your terminal after typing `base64 <`.) |
| 26 | + |
| 27 | + Copy *the full text* that was generated; you'll need it in the next step. |
| 28 | +
|
| 29 | +5. **Add [GitHub Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) to your repository** |
| 30 | +
|
| 31 | + You'll need the following three secrets: |
| 32 | + |
| 33 | + - `CODESIGN_IDENTITY`: the identity in the certificate |
| 34 | + - `CODESIGN_CERTIFICATE_PASSWORD`: this is the base64-encoded certificate from Step 4 |
| 35 | + - `CODESIGN_CERTIFICATE_PASSWORD`: this is the password from Step 3 |
| 36 | + |
| 37 | +### Part 2: Enable macOS signing with cargo-dist |
| 38 | + |
| 39 | +1. **Configure cargo-dist to codesign** |
| 40 | + |
| 41 | + Add the following to your `Cargo.toml` or `dist.toml`: |
| 42 | + |
| 43 | + ```toml |
| 44 | + [workspace.metadata.dist] |
| 45 | + macos-sign = true |
| 46 | + ``` |
| 47 | + |
| 48 | +2. **Run `cargo dist init` on your project** |
| 49 | + |
| 50 | + You've already fully configured the feature, we're just ensuring your config changes are applied and checked. |
0 commit comments