|
| 1 | +# Apple Notarization TODO |
| 2 | + |
| 3 | +To distribute the CreateOS CLI on macOS without Gatekeeper warnings, complete the following steps. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- [ ] Enroll in the Apple Developer Program at https://developer.apple.com — $99/year |
| 8 | +- [ ] Generate a **Developer ID Application** certificate in Xcode or at developer.apple.com/account |
| 9 | +- [ ] Export the certificate as a `.p12` file and note the password |
| 10 | + |
| 11 | +## Steps |
| 12 | + |
| 13 | +### 1. Install GoReleaser |
| 14 | + |
| 15 | +```bash |
| 16 | +brew install goreleaser |
| 17 | +``` |
| 18 | + |
| 19 | +### 2. Create `.goreleaser.yaml` |
| 20 | + |
| 21 | +```yaml |
| 22 | +builds: |
| 23 | + - env: [CGO_ENABLED=0] |
| 24 | + goos: [darwin, linux, windows] |
| 25 | + goarch: [amd64, arm64] |
| 26 | + ldflags: |
| 27 | + - -s -w -X github.com/NodeOps-app/createos-cli/internal/pkg/version.Version={{.Version}} |
| 28 | + |
| 29 | +archives: |
| 30 | + - format: tar.gz |
| 31 | + name_template: "createos_{{ .Os }}_{{ .Arch }}" |
| 32 | + format_overrides: |
| 33 | + - goos: windows |
| 34 | + format: zip |
| 35 | + |
| 36 | +signs: |
| 37 | + - cmd: codesign |
| 38 | + args: |
| 39 | + - "--sign" |
| 40 | + - "Developer ID Application: Your Name (TEAMID)" |
| 41 | + - "--options" |
| 42 | + - "runtime" |
| 43 | + - "--timestamp" |
| 44 | + - "${artifact}" |
| 45 | + artifacts: macos |
| 46 | + |
| 47 | +notarize: |
| 48 | + macos: |
| 49 | + - enabled: true |
| 50 | + sign: |
| 51 | + certificate: "{{.Env.APPLE_CERT_BASE64}}" |
| 52 | + password: "{{.Env.APPLE_CERT_PASSWORD}}" |
| 53 | + notarize: |
| 54 | + issuer_id: "{{.Env.APPLE_ISSUER_ID}}" |
| 55 | + key_id: "{{.Env.APPLE_KEY_ID}}" |
| 56 | + key: "{{.Env.APPLE_KEY}}" |
| 57 | +``` |
| 58 | +
|
| 59 | +### 3. Set environment variables (CI or local) |
| 60 | +
|
| 61 | +| Variable | Description | |
| 62 | +|----------|-------------| |
| 63 | +| `APPLE_CERT_BASE64` | Base64-encoded `.p12` certificate (`base64 -i cert.p12`) | |
| 64 | +| `APPLE_CERT_PASSWORD` | Password for the `.p12` file | |
| 65 | +| `APPLE_ISSUER_ID` | Found in App Store Connect → Keys → Issuer ID | |
| 66 | +| `APPLE_KEY_ID` | Found in App Store Connect → Keys | |
| 67 | +| `APPLE_KEY` | Contents of the `.p8` API key file | |
| 68 | + |
| 69 | +### 4. Manual signing (without GoReleaser) |
| 70 | + |
| 71 | +```bash |
| 72 | +# Sign |
| 73 | +codesign --sign "Developer ID Application: Your Name (TEAMID)" \ |
| 74 | + --options runtime \ |
| 75 | + --timestamp \ |
| 76 | + createos |
| 77 | +
|
| 78 | +# Zip for notarization submission |
| 79 | +zip createos.zip createos |
| 80 | +
|
| 81 | +# Submit to Apple |
| 82 | +xcrun notarytool submit createos.zip \ |
| 83 | + --apple-id "you@email.com" \ |
| 84 | + --team-id "YOURTEAMID" \ |
| 85 | + --password "app-specific-password" \ |
| 86 | + --wait |
| 87 | +
|
| 88 | +# Staple the notarization ticket to the binary |
| 89 | +xcrun stapler staple createos |
| 90 | +``` |
| 91 | + |
| 92 | +### 5. Verify |
| 93 | + |
| 94 | +```bash |
| 95 | +# Check signature |
| 96 | +codesign --verify --verbose createos |
| 97 | +
|
| 98 | +# Check notarization |
| 99 | +spctl --assess --verbose createos |
| 100 | +# Expected: createos: accepted |
| 101 | +``` |
| 102 | + |
| 103 | +## Notes |
| 104 | + |
| 105 | +- `--options runtime` (hardened runtime) is required for notarization |
| 106 | +- `--timestamp` uses Apple's secure timestamp server — required for notarization |
| 107 | +- Stapling embeds the ticket so the binary works offline without calling Apple |
| 108 | +- Without notarization, users see "Apple cannot verify this app" and must manually allow it in System Settings → Privacy & Security |
| 109 | +- ARM (Apple Silicon) and AMD64 builds must both be signed separately |
0 commit comments