Skip to content

Commit 1a13876

Browse files
devsemihclaude
andcommitted
Add code signing and notarization to CI workflow
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5962977 commit 1a13876

2 files changed

Lines changed: 67 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,59 @@ jobs:
2727
sudo xcode-select -s "$XCODE_PATH"
2828
xcodebuild -version
2929
30+
- name: Import certificate
31+
env:
32+
CERTIFICATE_P12: ${{ secrets.CERTIFICATE_P12 }}
33+
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
34+
run: |
35+
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
36+
KEYCHAIN_PASS=$(openssl rand -hex 16)
37+
38+
# Create temporary keychain
39+
security create-keychain -p "$KEYCHAIN_PASS" "$KEYCHAIN_PATH"
40+
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
41+
security unlock-keychain -p "$KEYCHAIN_PASS" "$KEYCHAIN_PATH"
42+
43+
# Import certificate
44+
echo "$CERTIFICATE_P12" | base64 --decode > $RUNNER_TEMP/certificate.p12
45+
security import $RUNNER_TEMP/certificate.p12 \
46+
-P "$CERTIFICATE_PASSWORD" \
47+
-A -t cert -f pkcs12 \
48+
-k "$KEYCHAIN_PATH"
49+
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASS" "$KEYCHAIN_PATH"
50+
51+
# Add to search list
52+
security list-keychains -d user -s "$KEYCHAIN_PATH" $(security list-keychains -d user | tr -d '"')
53+
3054
- name: Build
3155
run: |
3256
xcodebuild -project appjail.xcodeproj \
3357
-scheme appjail \
3458
-configuration Release \
3559
-derivedDataPath build \
36-
CODE_SIGN_IDENTITY="-" \
37-
CODE_SIGNING_REQUIRED=NO \
38-
CODE_SIGNING_ALLOWED=NO
60+
CODE_SIGN_IDENTITY="Developer ID Application" \
61+
DEVELOPMENT_TEAM=${{ secrets.APPLE_TEAM_ID }}
62+
63+
- name: Notarize
64+
env:
65+
APPLE_ID: ${{ secrets.APPLE_ID }}
66+
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
67+
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
68+
run: |
69+
APP_PATH="build/Build/Products/Release/appjail.app"
70+
71+
# Create zip for notarization
72+
ditto -c -k --keepParent "$APP_PATH" appjail.zip
73+
74+
# Submit for notarization
75+
xcrun notarytool submit appjail.zip \
76+
--apple-id "$APPLE_ID" \
77+
--password "$APPLE_ID_PASSWORD" \
78+
--team-id "$APPLE_TEAM_ID" \
79+
--wait
80+
81+
# Staple the ticket
82+
xcrun stapler staple "$APP_PATH"
3983
4084
- name: Create DMG
4185
run: |
@@ -44,21 +88,37 @@ jobs:
4488
4589
mkdir -p dmg_staging
4690
cp -R "$APP_PATH" dmg_staging/
47-
48-
# Create a symlink to /Applications for drag-install
4991
ln -s /Applications dmg_staging/Applications
5092
5193
hdiutil create -volname "AppJail" \
5294
-srcfolder dmg_staging \
5395
-ov -format UDZO \
5496
"$DMG_NAME"
5597
98+
# Sign and notarize the DMG too
99+
codesign --sign "Developer ID Application" "$DMG_NAME"
100+
xcrun notarytool submit "$DMG_NAME" \
101+
--apple-id "$APPLE_ID" \
102+
--password "$APPLE_ID_PASSWORD" \
103+
--team-id "$APPLE_TEAM_ID" \
104+
--wait
105+
xcrun stapler staple "$DMG_NAME"
106+
env:
107+
APPLE_ID: ${{ secrets.APPLE_ID }}
108+
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
109+
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
110+
56111
- name: Upload DMG artifact
57112
uses: actions/upload-artifact@v4
58113
with:
59114
name: AppJail-DMG
60115
path: AppJail.dmg
61116

117+
- name: Cleanup keychain
118+
if: always()
119+
run: |
120+
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db 2>/dev/null || true
121+
62122
release:
63123
name: Create Release
64124
needs: build

appjail.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@
396396
CODE_SIGN_STYLE = Automatic;
397397
COMBINE_HIDPI_IMAGES = YES;
398398
CURRENT_PROJECT_VERSION = 1;
399+
DEVELOPMENT_TEAM = UP7GT9LZLZ;
399400
ENABLE_APP_SANDBOX = NO;
400401
ENABLE_HARDENED_RUNTIME = YES;
401402
ENABLE_PREVIEWS = YES;
@@ -429,6 +430,7 @@
429430
CODE_SIGN_STYLE = Automatic;
430431
COMBINE_HIDPI_IMAGES = YES;
431432
CURRENT_PROJECT_VERSION = 1;
433+
DEVELOPMENT_TEAM = UP7GT9LZLZ;
432434
ENABLE_APP_SANDBOX = NO;
433435
ENABLE_HARDENED_RUNTIME = YES;
434436
ENABLE_PREVIEWS = YES;

0 commit comments

Comments
 (0)