Skip to content

Commit 4d4a47e

Browse files
szokeasaurusrexBYK
andauthored
build(macos): Sign macOS binaries (#2401)
Closes #1882 --------- Co-authored-by: Burak Yigit Kaya <[email protected]>
1 parent a21d57d commit 4d4a47e

File tree

2 files changed

+85
-6
lines changed

2 files changed

+85
-6
lines changed

.github/workflows/build.yml

+76-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979

8080
- uses: actions/upload-artifact@v4
8181
with:
82-
name: artifact-bin-macos-${{ matrix.arch }}
82+
name: unsigned-bin-macos-${{ matrix.arch }}
8383
path: sentry-cli-Darwin-${{ matrix.arch }}
8484
if-no-files-found: 'error'
8585

@@ -91,18 +91,88 @@ jobs:
9191
steps:
9292
- uses: actions/download-artifact@v4
9393
with:
94-
pattern: artifact-bin-macos-*
94+
pattern: unsigned-bin-macos-*
9595
merge-multiple: true
9696

9797
- name: Link universal binary
9898
run: lipo -create -output sentry-cli-Darwin-universal sentry-cli-Darwin-x86_64 sentry-cli-Darwin-arm64
9999

100100
- uses: actions/upload-artifact@v4
101101
with:
102-
name: artifact-bin-macos-universal
102+
name: unsigned-bin-macos-universal
103103
path: sentry-cli-Darwin-universal
104104
if-no-files-found: 'error'
105105

106+
sign-macos-binaries:
107+
strategy:
108+
fail-fast: false
109+
matrix:
110+
include:
111+
- arch: universal
112+
- arch: x86_64
113+
- arch: arm64
114+
115+
needs: [macos, macos_universal]
116+
name: Sign & Notarize macOS Binary (${{ matrix.arch }})
117+
runs-on: ubuntu-24.04
118+
119+
env:
120+
APPLE_CERT_PATH: /tmp/certs.p12
121+
APPLE_API_KEY_PATH: /tmp/apple_key.json
122+
123+
steps:
124+
- name: Checkout repository
125+
uses: actions/checkout@v4
126+
127+
- name: Install `rcodesign`
128+
run: |
129+
curl -L https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.29.0/apple-codesign-0.29.0-x86_64-unknown-linux-musl.tar.gz \
130+
-o rcodesign.tar.gz
131+
echo "dbe85cedd8ee4217b64e9a0e4c2aef92ab8bcaaa41f20bde99781ff02e600002 rcodesign.tar.gz" | sha256sum -c -
132+
tar -xz --strip-components=1 -f rcodesign.tar.gz
133+
mv rcodesign /usr/local/bin/rcodesign
134+
rm rcodesign.tar.gz
135+
136+
- name: Decode Apple signing certificate and API key
137+
env:
138+
APPLE_CERT_DATA: ${{ secrets.APPLE_CERT_DATA }}
139+
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
140+
run: |
141+
echo "$APPLE_CERT_DATA" | base64 --decode > ${{ env.APPLE_CERT_PATH }}
142+
echo "$APPLE_API_KEY" | base64 --decode > ${{ env.APPLE_API_KEY_PATH }}
143+
144+
- name: Download unsigned binary
145+
uses: actions/download-artifact@v4
146+
with:
147+
name: unsigned-bin-macos-${{ matrix.arch }}
148+
149+
- name: Sign binary
150+
run: |
151+
rcodesign sign \
152+
--for-notarization \
153+
--entitlements-xml-path entitlements.plist \
154+
--p12-file ${{ env.APPLE_CERT_PATH }} \
155+
--p12-password ${{ secrets.APPLE_CERT_PASSWORD }} \
156+
sentry-cli-Darwin-${{ matrix.arch }}
157+
158+
- name: Zip signed binary
159+
run: |
160+
zip sentry-cli-Darwin-${{ matrix.arch }}.zip sentry-cli-Darwin-${{ matrix.arch }}
161+
162+
- name: Notarize binary
163+
run: |
164+
rcodesign notary-submit \
165+
--api-key-file ${{ env.APPLE_API_KEY_PATH }} \
166+
--wait \
167+
sentry-cli-Darwin-${{ matrix.arch }}.zip
168+
169+
- name: Upload signed binary
170+
uses: actions/upload-artifact@v4
171+
with:
172+
name: artifact-bin-macos-${{ matrix.arch }}
173+
path: sentry-cli-Darwin-${{ matrix.arch }}
174+
if-no-files-found: 'error'
175+
106176
windows:
107177
strategy:
108178
fail-fast: false
@@ -198,7 +268,7 @@ jobs:
198268
python:
199269
name: python
200270
runs-on: ubuntu-24.04
201-
needs: [linux, macos, macos_universal, windows, python-base]
271+
needs: [linux, sign-macos-binaries, windows, python-base]
202272
steps:
203273
- uses: actions/checkout@v3
204274
- uses: actions/setup-python@v4
@@ -224,7 +294,7 @@ jobs:
224294
npm-distributions:
225295
name: 'Build NPM distributions'
226296
runs-on: ubuntu-24.04
227-
needs: [linux, macos, macos_universal, windows]
297+
needs: [linux, sign-macos-binaries, windows]
228298
steps:
229299
- uses: actions/checkout@v3
230300
- uses: actions/setup-node@v4
@@ -322,7 +392,7 @@ jobs:
322392
merge:
323393
name: Create Release Artifact
324394
runs-on: ubuntu-24.04
325-
needs: [linux, macos, macos_universal, windows, npm-distributions, node, python]
395+
needs: [linux, sign-macos-binaries, windows, npm-distributions, node, python]
326396
steps:
327397
- uses: actions/upload-artifact/merge@v4
328398
with:

entitlements.plist

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
4+
<!-- Entitlements for macOS -->
5+
6+
<plist version="1.0">
7+
<dict>
8+
</dict>
9+
</plist>

0 commit comments

Comments
 (0)