Skip to content

Commit 1d84138

Browse files
authored
feat: Publish on Mac App Store via GitHub Actions (#139)
* build(mac): App Store flavor. * ci: Mac App Store build & upload. * fix(macos,appstore): build version * Revert "build(mac): App Store flavor." This reverts commit 32e6f32. * build(mac, appstore): patch pbxproj instead of creating flutter flavor * ci(macos): Add provisioning profile * fix(mac): Include team id and bundle id in entitlements. * fix(macos, appstore): Build-time provisioning profile * build(macos): Encryption compliance declaration. * fix(macos): Sign the app properly.
1 parent 8a6e6d7 commit 1d84138

9 files changed

+271
-52
lines changed

.github/workflows/build.yml

+149-42
Large diffs are not rendered by default.

Justfile

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ macos-ci-all: macos-ci-clean macos-ci-install
55
./scripts/macos_5_codesign_and_notarize.sh
66
./scripts/macos_6_create_dmg.sh
77

8+
macos-ci-all-appstore: macos-ci-clean macos-ci-install
9+
./scripts/macos_2_appstore_build.sh
10+
./scripts/macos_3_prepare_before_sign.sh
11+
./scripts/macos_4_replace_dylib.sh
12+
./scripts/macos_5_codesign_and_submit_to_appstore.sh
13+
814
macos-ci-clean:
915
./scripts/macos_7_clean.sh
1016

@@ -23,4 +29,3 @@ macos-build:
2329
./scripts/macos_2_build.sh
2430

2531
macos-build-all: macos-install macos-build
26-

macos/Runner.xcodeproj/project.pbxproj

+15-4
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@
289289
33CC10EC2044A3C60003C045 = {
290290
CreatedOnToolsVersion = 9.2;
291291
LastSwiftMigration = 1100;
292-
ProvisioningStyle = Automatic;
293292
SystemCapabilities = {
294293
com.apple.Sandbox = {
295294
enabled = 1;
@@ -590,9 +589,13 @@
590589
buildSettings = {
591590
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
592591
CLANG_ENABLE_MODULES = YES;
593-
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
594-
CODE_SIGN_STYLE = Automatic;
592+
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
593+
CODE_SIGN_IDENTITY = "Apple Development";
594+
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "3rd Party Mac Developer Application";
595+
CODE_SIGN_STYLE = Manual;
595596
COMBINE_HIDPI_IMAGES = YES;
597+
DEVELOPMENT_TEAM = "";
598+
"DEVELOPMENT_TEAM[sdk=macosx*]" = LG57TUQ726;
596599
ENABLE_HARDENED_RUNTIME = YES;
597600
INFOPLIST_FILE = Runner/Info.plist;
598601
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
@@ -609,6 +612,7 @@
609612
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
610613
PRODUCT_BUNDLE_IDENTIFIER = ci.not.rune;
611614
PROVISIONING_PROFILE_SPECIFIER = "";
615+
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "Rune App Store";
612616
SWIFT_VERSION = 5.0;
613617
};
614618
name = Profile;
@@ -733,8 +737,10 @@
733737
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
734738
CLANG_ENABLE_MODULES = YES;
735739
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
740+
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
736741
CODE_SIGN_STYLE = Automatic;
737742
COMBINE_HIDPI_IMAGES = YES;
743+
DEVELOPMENT_TEAM = LG57TUQ726;
738744
ENABLE_HARDENED_RUNTIME = YES;
739745
INFOPLIST_FILE = Runner/Info.plist;
740746
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
@@ -763,8 +769,12 @@
763769
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
764770
CLANG_ENABLE_MODULES = YES;
765771
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
766-
CODE_SIGN_STYLE = Automatic;
772+
CODE_SIGN_IDENTITY = "Apple Development";
773+
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "3rd Party Mac Developer Application";
774+
CODE_SIGN_STYLE = Manual;
767775
COMBINE_HIDPI_IMAGES = YES;
776+
DEVELOPMENT_TEAM = "";
777+
"DEVELOPMENT_TEAM[sdk=macosx*]" = LG57TUQ726;
768778
ENABLE_HARDENED_RUNTIME = YES;
769779
INFOPLIST_FILE = Runner/Info.plist;
770780
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
@@ -781,6 +791,7 @@
781791
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
782792
PRODUCT_BUNDLE_IDENTIFIER = ci.not.rune;
783793
PROVISIONING_PROFILE_SPECIFIER = "";
794+
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "Rune App Store";
784795
SWIFT_VERSION = 5.0;
785796
};
786797
name = Release;

macos/Runner/Info.plist

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
<string>$(FLUTTER_BUILD_NAME)</string>
2121
<key>CFBundleVersion</key>
2222
<string>$(FLUTTER_BUILD_NUMBER)</string>
23+
<key>ITSAppUsesNonExemptEncryption</key>
24+
<false/>
25+
<key>LSApplicationCategoryType</key>
26+
<string>public.app-category.music</string>
2327
<key>LSMinimumSystemVersion</key>
2428
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
2529
<key>NSHumanReadableCopyright</key>
@@ -28,7 +32,5 @@
2832
<string>MainMenu</string>
2933
<key>NSPrincipalClass</key>
3034
<string>NSApplication</string>
31-
<key>LSApplicationCategoryType</key>
32-
<string>public.app-category.music</string>
3335
</dict>
3436
</plist>

macos/Runner/Release.entitlements

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>keychain-access-groups</key>
6+
<array/>
7+
<key>com.apple.developer.team-identifier</key>
8+
<string>LG57TUQ726</string>
9+
<key>com.apple.application-identifier</key>
10+
<string>LG57TUQ726.ci.not.rune</string>
511
<key>com.apple.security.app-sandbox</key>
612
<true/>
713
<key>com.apple.security.automation.apple-events</key>

scripts/macos_2_appstore_build.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
cd "$(dirname "$0")"
6+
cd ..
7+
8+
# Create backup of project.pbxproj
9+
cp macos/Runner.xcodeproj/project.pbxproj macos/Runner.xcodeproj/project.pbxproj.backup
10+
11+
# Patch macos/Runner.xcodeproj/project.pbxproj and macos/Runner/Release.entitlements to replace bundle ID
12+
sed -i '' 's/PRODUCT_BUNDLE_IDENTIFIER = ci.not.rune;/PRODUCT_BUNDLE_IDENTIFIER = ci.not.rune.appstore;/g' macos/Runner.xcodeproj/project.pbxproj
13+
sed -i '' 's/<string>LG57TUQ726.ci.not.rune<\/string>/<string>LG57TUQ726.ci.not.rune.appstore<\/string>/g' macos/Runner/Release.entitlements
14+
15+
flutter pub get
16+
rinf message
17+
cd macos
18+
pod update
19+
cd ..
20+
flutter build macos --build-number $RUNE_APPSTORE_BUILD_NUMBER --build-name $RUNE_APPSTORE_BUILD_VERSION --release
21+
chmod -R +x build/macos/Build/Products/Release/Rune.app
22+
xattr -cr build/macos/Build/Products/Release/Rune.app
23+
24+
# Restore original project.pbxproj
25+
mv macos/Runner.xcodeproj/project.pbxproj.backup macos/Runner.xcodeproj/project.pbxproj

scripts/macos_3_prepare_before_sign.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ cd ..
88
rm -rf temp_macos
99
mkdir temp_macos
1010

11-
cp -R build/macos/Build/Products/Release/Rune.app temp_macos
12-
cp macos/Runner/Release.entitlements temp_macos
11+
ditto build/macos/Build/Products/Release/Rune.app temp_macos/Rune.app
12+
cp macos/Runner/Release.entitlements temp_macos
13+
cp ~/Library/MobileDevice/Provisioning\ Profiles/*.provisionprofile temp_macos/Rune.app/Contents/embedded.provisionprofile

scripts/macos_5_codesign_and_notarize.sh

+15-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,21 @@ echo "Codesign: ----------------------------"
1111
# DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY must use Developer ID Application certificate, or app cannot be notarized
1212
# /usr/bin/codesign --deep --force -s "$DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY" --options runtime player.app -v
1313

14-
/usr/bin/codesign --deep --force -s "$DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY" --entitlements Release.entitlements --options runtime Rune.app -v
14+
/usr/bin/codesign \
15+
--deep \
16+
--force \
17+
-s "$DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY" \
18+
--options runtime \
19+
-v \
20+
Rune.app
21+
22+
/usr/bin/codesign \
23+
--force \
24+
-s "$DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY" \
25+
--entitlements Release.entitlements \
26+
--options runtime \
27+
-v \
28+
Rune.app
1529

1630
echo "Notarize: ----------------------------"
1731

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
cd "$(dirname "$0")"
6+
cd ..
7+
cd temp_macos
8+
9+
echo "Codesign: ----------------------------"
10+
11+
/usr/bin/codesign \
12+
--deep \
13+
--force \
14+
-s "$APPLE_DISTRIBUTION_SIGNING_IDENTITY" \
15+
--options runtime \
16+
-v \
17+
Rune.app
18+
19+
/usr/bin/codesign \
20+
--force \
21+
-s "$APPLE_DISTRIBUTION_SIGNING_IDENTITY" \
22+
--entitlements Release.entitlements \
23+
--options runtime \
24+
-v \
25+
Rune.app
26+
27+
echo "Package: ----------------------------"
28+
29+
xcrun productbuild \
30+
--sign "$MAC_DEVELOPER_INSTALLER_SIGNING_IDENTITY" \
31+
--component Rune.app \
32+
/Applications \
33+
Rune.pkg
34+
35+
echo "Upload to App Store Connect: ----------------------------"
36+
37+
API_PRIVATE_KEYS_DIR=$RUNNER_TEMP \
38+
xcrun altool \
39+
--upload-package Rune.pkg \
40+
--type osx \
41+
--apiKey "$APP_STORE_CONNECT_KEYID" \
42+
--apiIssuer "$APP_STORE_CONNECT_ISSUER" \
43+
--asc-public-id "$APP_STORE_CONNECT_PUBLIC_ID" \
44+
--apple-id "$APP_STORE_CONNECT_APP_APPLE_ID" \
45+
--bundle-id "ci.not.rune.appstore" \
46+
--bundle-short-version-string "$RUNE_APPSTORE_BUILD_VERSION" \
47+
--bundle-version "$RUNE_APPSTORE_BUILD_NUMBER" \
48+
--verbose

0 commit comments

Comments
 (0)