Skip to content

Commit 7cc0658

Browse files
authored
Merge pull request #334 from gitx/feature/Apple-Notary-Submission
Notarizate the GitX app
2 parents c1a8608 + ef79590 commit 7cc0658

5 files changed

Lines changed: 123 additions & 14 deletions

File tree

‎.github/workflows/BuildPR.yml‎

100644100755
Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,84 @@ jobs:
3030
submodules: recursive
3131
- name: Set XCode Version
3232
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app
33+
- name: Install the Apple certificate and provisioning profile
34+
env:
35+
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
36+
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
37+
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
38+
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
39+
run: |
40+
# create variables
41+
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
42+
PP_PATH=$RUNNER_TEMP/build_pp.provisionprofile
43+
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
44+
45+
# import certificate and provisioning profile from secrets
46+
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
47+
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH
48+
49+
# create temporary keychain
50+
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
51+
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
52+
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
53+
54+
# import certificate to keychain
55+
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
56+
security list-keychain -d user -s $KEYCHAIN_PATH
57+
58+
# apply provisioning profile
59+
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
60+
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
3361
- name: pre build
3462
run: cd External/objective-git && script/bootstrap && script/update_libgit2 && cd ../..
3563
- name: Build project
36-
run: xcodebuild -workspace GitX.xcworkspace -scheme GitX -archivePath ./GitX archive ARCHS="${{ matrix.abi }}"
64+
run: xcodebuild -workspace GitX.xcworkspace -scheme GitX -archivePath ./GitX archive ARCHS="${{ matrix.abi }}" PRODUCT_BUNDLE_IDENTIFIER=${{ secrets.NOTARY_BUNDLE_IDENTIFIER}}
3765
- name: Prepare artifact
66+
env:
67+
EXPORT_OPTIONS: ${{ secrets.NOTARY_EXPORT_OPTIONS }}
3868
run: |
39-
mv GitX.xcarchive/Products/Applications/GitX.app .
69+
EXPORT_OPTIONS_PATH=$RUNNER_TEMP/ExportOptions.plist
70+
71+
echo -n "$EXPORT_OPTIONS" > EXPORT_OPTIONS_PATH
72+
73+
xcodebuild -exportArchive -archivePath GitX.xcarchive -exportPath . -exportOptionsPlist EXPORT_OPTIONS_PATH
74+
4075
hdiutil create -fs HFS+ -srcfolder GitX.app -volname GitX GitX-${{ matrix.abi }}.dmg
4176
zip -r GitX-${{ matrix.abi }}.zip GitX.app
77+
- name: Notarize App
78+
env:
79+
APPLE_ID: ${{ secrets.APPLE_ID }}
80+
TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
81+
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
82+
KEY_ID: ${{ secrets.APPLE_KEY_ID }}
83+
run: |
84+
APP_PATH="GitX.app"
85+
ZIP_PATH="GitX.zip"
86+
NOTARY_LOG="notary.log"
87+
ID_FILE="id.txt"
88+
89+
ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH"
90+
91+
xcrun notarytool submit "$ZIP_PATH" --key-id $KEY_ID --apple-id $APPLE_ID --team-id $TEAM_ID --password $APPLE_PASSWORD --wait | tee "$NOTARY_LOG" echo "print log output"
92+
cat "$NOTARY_LOG"
93+
94+
ID=$(cat "$NOTARY_LOG" | tail -3 | cut -d':' -f2 | head -n 1)
95+
echo "Id is: $ID"
96+
97+
xcrun notarytool log $ID --apple-id $APPLE_ID --team-id $TEAM_ID --password $APPLE_PASSWORD
98+
- name: Staple Notarization
99+
run: |
100+
# While you can notarize a ZIP archive, you can’t staple to it directly.
101+
# Instead, run stapler against each item that you added to the archive.
102+
# Then create a new ZIP file containing the stapled items for distribution.
103+
# Reference: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow
104+
APP_PATH="GitX.app"
105+
ZIP_PATH="GitX.zip"
106+
107+
xcrun stapler staple "$APP_PATH"
108+
ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH"
109+
- name: Check Notarization
110+
run: spctl -a -vv GitX.app
42111
- name: Upload artifact
43112
uses: actions/upload-artifact@v3
44113
if: ${{ success() }}
@@ -51,3 +120,8 @@ jobs:
51120
with:
52121
name: GitX-${{ matrix.abi }}.zip
53122
path: GitX-${{ matrix.abi }}.zip
123+
- name: Clean up keychain and provisioning profile
124+
if: ${{ always() }}
125+
run: |
126+
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
127+
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.provisionprofile

‎GitX.entitlements‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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+
<plist version="1.0">
4+
<dict/>
5+
</plist>

‎GitX.xcodeproj/project.pbxproj‎

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,9 @@
650650
50DCC65820111E4000999D3D /* PBGitRevisionRow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PBGitRevisionRow.h; sourceTree = "<group>"; };
651651
50DCC65920111E4000999D3D /* PBGitRevisionRow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PBGitRevisionRow.m; sourceTree = "<group>"; };
652652
551BF111112F371800265053 /* gitx_askpasswd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = gitx_askpasswd; sourceTree = BUILT_PRODUCTS_DIR; };
653+
62E3BAA728D5104C00DCD7B2 /* GitX.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GitX.entitlements; sourceTree = "<group>"; };
654+
62E3BAC428D5105200DCD7B2 /* cli tool.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "cli tool.entitlements"; sourceTree = SOURCE_ROOT; };
655+
62E3BAC528D5105600DCD7B2 /* gitx_askpasswd.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = gitx_askpasswd.entitlements; sourceTree = SOURCE_ROOT; };
653656
643952751603EF9B00BB7AFF /* PBSourceViewGitSubmoduleItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBSourceViewGitSubmoduleItem.h; sourceTree = "<group>"; };
654657
643952761603EF9B00BB7AFF /* PBSourceViewGitSubmoduleItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBSourceViewGitSubmoduleItem.m; sourceTree = "<group>"; };
655658
6C2581091C2720E60080A89A /* GitXCommitCopier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitXCommitCopier.h; sourceTree = "<group>"; };
@@ -756,6 +759,7 @@
756759
29B97314FDCFA39411CA2CEA /* GitTest */ = {
757760
isa = PBXGroup;
758761
children = (
762+
62E3BAA728D5104C00DCD7B2 /* GitX.entitlements */,
759763
4A90A72B14A9C12F00D0DA02 /* README.markdown */,
760764
4A5D762114A9A9CC00DF6C68 /* Classes */,
761765
4A5D773E14A9AB3A00DF6C68 /* External Sources */,
@@ -793,6 +797,7 @@
793797
37A5656C1EAD077400CA0332 /* cli tool */ = {
794798
isa = PBXGroup;
795799
children = (
800+
62E3BAC428D5105200DCD7B2 /* cli tool.entitlements */,
796801
4A5D768614A9A9CC00DF6C68 /* gitx.m */,
797802
4A90A73314A9D1E800D0DA02 /* GitX.h */,
798803
4DC1853818E6F93200E8DB8F /* Info-gitx.plist */,
@@ -804,6 +809,7 @@
804809
37A5656D1EAD07C200CA0332 /* gitx_askpasswd */ = {
805810
isa = PBXGroup;
806811
children = (
812+
62E3BAC528D5105600DCD7B2 /* gitx_askpasswd.entitlements */,
807813
4A5D768714A9A9CC00DF6C68 /* gitx_askpasswd_main.m */,
808814
);
809815
name = gitx_askpasswd;
@@ -1157,10 +1163,10 @@
11571163
children = (
11581164
4A68AD6714A0050F006DE321 /* Sparkle.framework */,
11591165
D19D706227B8DA2A00A5C740 /* Autoupdate */,
1160-
D19D706427B8DA2A00A5C740 /* org.sparkle-project.InstallerLauncher.xpc */,
1161-
D19D706627B8DA2A00A5C740 /* org.sparkle-project.InstallerConnection.xpc */,
1162-
D19D706827B8DA2A00A5C740 /* org.sparkle-project.InstallerStatus.xpc */,
1163-
D19D706A27B8DA2A00A5C740 /* org.sparkle-project.Downloader.xpc */,
1166+
D19D706427B8DA2A00A5C740 /* Installer.xpc */,
1167+
D19D706627B8DA2A00A5C740 /* InstallerConnection.xpc */,
1168+
D19D706827B8DA2A00A5C740 /* InstallerStatus.xpc */,
1169+
D19D706A27B8DA2A00A5C740 /* Downloader.xpc */,
11641170
4A68AD6914A0050F006DE321 /* Sparkle Test App.app */,
11651171
D19D706C27B8DA2A00A5C740 /* TestAppHelper.xpc */,
11661172
4A68AD6B14A0050F006DE321 /* Sparkle Unit Tests.xctest */,
@@ -1423,31 +1429,31 @@
14231429
remoteRef = D19D706127B8DA2A00A5C740 /* PBXContainerItemProxy */;
14241430
sourceTree = BUILT_PRODUCTS_DIR;
14251431
};
1426-
D19D706427B8DA2A00A5C740 /* org.sparkle-project.InstallerLauncher.xpc */ = {
1432+
D19D706427B8DA2A00A5C740 /* Installer.xpc */ = {
14271433
isa = PBXReferenceProxy;
14281434
fileType = "wrapper.xpc-service";
1429-
path = "org.sparkle-project.InstallerLauncher.xpc";
1435+
path = Installer.xpc;
14301436
remoteRef = D19D706327B8DA2A00A5C740 /* PBXContainerItemProxy */;
14311437
sourceTree = BUILT_PRODUCTS_DIR;
14321438
};
1433-
D19D706627B8DA2A00A5C740 /* org.sparkle-project.InstallerConnection.xpc */ = {
1439+
D19D706627B8DA2A00A5C740 /* InstallerConnection.xpc */ = {
14341440
isa = PBXReferenceProxy;
14351441
fileType = "wrapper.xpc-service";
1436-
path = "org.sparkle-project.InstallerConnection.xpc";
1442+
path = InstallerConnection.xpc;
14371443
remoteRef = D19D706527B8DA2A00A5C740 /* PBXContainerItemProxy */;
14381444
sourceTree = BUILT_PRODUCTS_DIR;
14391445
};
1440-
D19D706827B8DA2A00A5C740 /* org.sparkle-project.InstallerStatus.xpc */ = {
1446+
D19D706827B8DA2A00A5C740 /* InstallerStatus.xpc */ = {
14411447
isa = PBXReferenceProxy;
14421448
fileType = "wrapper.xpc-service";
1443-
path = "org.sparkle-project.InstallerStatus.xpc";
1449+
path = InstallerStatus.xpc;
14441450
remoteRef = D19D706727B8DA2A00A5C740 /* PBXContainerItemProxy */;
14451451
sourceTree = BUILT_PRODUCTS_DIR;
14461452
};
1447-
D19D706A27B8DA2A00A5C740 /* org.sparkle-project.Downloader.xpc */ = {
1453+
D19D706A27B8DA2A00A5C740 /* Downloader.xpc */ = {
14481454
isa = PBXReferenceProxy;
14491455
fileType = "wrapper.xpc-service";
1450-
path = "org.sparkle-project.Downloader.xpc";
1456+
path = Downloader.xpc;
14511457
remoteRef = D19D706927B8DA2A00A5C740 /* PBXContainerItemProxy */;
14521458
sourceTree = BUILT_PRODUCTS_DIR;
14531459
};
@@ -1827,8 +1833,10 @@
18271833
isa = XCBuildConfiguration;
18281834
buildSettings = {
18291835
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-gitx";
1836+
CODE_SIGN_ENTITLEMENTS = GitX.entitlements;
18301837
CODE_SIGN_IDENTITY = "-";
18311838
COMBINE_HIDPI_IMAGES = YES;
1839+
ENABLE_HARDENED_RUNTIME = YES;
18321840
FRAMEWORK_SEARCH_PATHS = "\"$(PROJECT_DIR)\"";
18331841
GCC_DYNAMIC_NO_PIC = NO;
18341842
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -1849,8 +1857,10 @@
18491857
isa = XCBuildConfiguration;
18501858
buildSettings = {
18511859
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-gitx";
1860+
CODE_SIGN_ENTITLEMENTS = GitX.entitlements;
18521861
CODE_SIGN_IDENTITY = "-";
18531862
COMBINE_HIDPI_IMAGES = YES;
1863+
ENABLE_HARDENED_RUNTIME = YES;
18541864
FRAMEWORK_SEARCH_PATHS = "\"$(PROJECT_DIR)\"";
18551865
GCC_PRECOMPILE_PREFIX_HEADER = YES;
18561866
GCC_PREFIX_HEADER = Resources/GitX_Prefix.pch;
@@ -1985,7 +1995,9 @@
19851995
551BF113112F371800265053 /* Debug */ = {
19861996
isa = XCBuildConfiguration;
19871997
buildSettings = {
1998+
CODE_SIGN_ENTITLEMENTS = gitx_askpasswd.entitlements;
19881999
CODE_SIGN_IDENTITY = "-";
2000+
ENABLE_HARDENED_RUNTIME = YES;
19892001
INSTALL_PATH = /usr/local/bin;
19902002
PRODUCT_NAME = gitx_askpasswd;
19912003
SKIP_INSTALL = YES;
@@ -1995,7 +2007,9 @@
19952007
551BF114112F371800265053 /* Release */ = {
19962008
isa = XCBuildConfiguration;
19972009
buildSettings = {
2010+
CODE_SIGN_ENTITLEMENTS = gitx_askpasswd.entitlements;
19982011
CODE_SIGN_IDENTITY = "-";
2012+
ENABLE_HARDENED_RUNTIME = YES;
19992013
INFOPLIST_PREFIX_HEADER = $PROJECT_TEMP_DIR/revision;
20002014
INFOPLIST_PREPROCESS = YES;
20012015
INSTALL_PATH = /usr/local/bin;
@@ -2007,7 +2021,9 @@
20072021
551BF115112F371800265053 /* Install */ = {
20082022
isa = XCBuildConfiguration;
20092023
buildSettings = {
2024+
CODE_SIGN_ENTITLEMENTS = gitx_askpasswd.entitlements;
20102025
CODE_SIGN_IDENTITY = "-";
2026+
ENABLE_HARDENED_RUNTIME = YES;
20112027
INSTALL_PATH = /usr/local/bin;
20122028
PRODUCT_NAME = gitx_askpasswd;
20132029
SKIP_INSTALL = YES;
@@ -2017,8 +2033,10 @@
20172033
913D5E4B0E55644600CECEA2 /* Debug */ = {
20182034
isa = XCBuildConfiguration;
20192035
buildSettings = {
2036+
CODE_SIGN_ENTITLEMENTS = "cli tool.entitlements";
20202037
CODE_SIGN_IDENTITY = "-";
20212038
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
2039+
ENABLE_HARDENED_RUNTIME = YES;
20222040
GCC_PRECOMPILE_PREFIX_HEADER = YES;
20232041
GCC_PREFIX_HEADER = Resources/GitX_Prefix.pch;
20242042
INFOPLIST_FILE = "Resources/Info-gitx.plist";
@@ -2032,8 +2050,10 @@
20322050
913D5E4C0E55644600CECEA2 /* Release */ = {
20332051
isa = XCBuildConfiguration;
20342052
buildSettings = {
2053+
CODE_SIGN_ENTITLEMENTS = "cli tool.entitlements";
20352054
CODE_SIGN_IDENTITY = "-";
20362055
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
2056+
ENABLE_HARDENED_RUNTIME = YES;
20372057
GCC_PRECOMPILE_PREFIX_HEADER = YES;
20382058
GCC_PREFIX_HEADER = Resources/GitX_Prefix.pch;
20392059
INFOPLIST_FILE = "Resources/Info-gitx.plist";

‎cli tool.entitlements‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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+
<plist version="1.0">
4+
<dict/>
5+
</plist>

‎gitx_askpasswd.entitlements‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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+
<plist version="1.0">
4+
<dict/>
5+
</plist>

0 commit comments

Comments
 (0)