1515# --version The version number (e.g. 0.8.2)
1616# --skip-code-generation Skip the code generation step
1717# --skip-rebuild-core Skip the core rebuild step
18+ # --apple-id The apple id to use for the notary service
19+ # --team-id The team id to use for the notary service
20+ # --password The password to use for the notary service
1821
1922show_help () {
2023 echo " Usage: ./scripts/flutter_release_build/build_macos.sh --build_type <type> --build_arch <arch> --version <version> [--skip-code-generation] [--skip-rebuild-core]"
@@ -38,6 +41,9 @@ show_help() {
3841 echo " --version The version number (e.g. 0.8.2)"
3942 echo " --skip-code-generation Skip the code generation step. It may save time if you have already generated the code."
4043 echo " --skip-rebuild-core Skip the core rebuild step. It may save time if you have already built the core."
44+ echo " --apple-id The apple id to use for the notary service"
45+ echo " --team-id The team id to use for the notary service"
46+ echo " --password The password to use for the notary service"
4147 exit 0
4248}
4349
@@ -69,6 +75,18 @@ while [ $# -gt 0 ]; do
6975 SKIP_REBUILD_CORE=true
7076 shift
7177 ;;
78+ --apple-id)
79+ APPLE_ID=" $2 "
80+ shift 2
81+ ;;
82+ --team-id)
83+ TEAM_ID=" $2 "
84+ shift 2
85+ ;;
86+ --password)
87+ PASSWORD=" $2 "
88+ shift 2
89+ ;;
7290 * )
7391 echo " Unknown parameter: $1 "
7492 show_help
@@ -100,29 +118,43 @@ if [ "$BUILD_TYPE" != "all" ] && [ "$BUILD_TYPE" != "zip" ] && [ "$BUILD_TYPE" !
100118 exit 1
101119fi
102120
121+ clear_cache () {
122+ echo " Clearing the cache..."
123+ rm -rf appflowy_flutter/build/$VERSION /
124+ }
125+
126+ info () {
127+ echo " 🚀 \033[32m$1 \033[0m"
128+ }
129+
130+ error () {
131+ echo " 🚨 \033[31m$1 \033[0m"
132+ }
133+
103134prepare_build () {
104- echo " Preparing build..."
135+ info " Preparing build..."
105136
106137 # step 1: build the appflowy-core (rust-lib) based on the build arch
107138 if [ " $SKIP_REBUILD_CORE " != " true" ]; then
108139 if [ " $BUILD_ARCH " = " x86_64" ] || [ " $BUILD_ARCH " = " universal" ]; then
109- echo " Building appflowy-core for x86_64...(This may take a while)"
140+ info " Building appflowy-core for x86_64...(This may take a while)"
110141 cargo make --profile production-mac-x86_64 appflowy-core-release
111142 fi
112143
113144 if [ " $BUILD_ARCH " = " arm64" ] || [ " $BUILD_ARCH " = " universal" ]; then
114- echo " Building appflowy-core for arm64...(This may take a while)"
145+ info " Building appflowy-core for arm64...(This may take a while)"
115146 cargo make --profile production-mac-arm64 appflowy-core-release
116147 fi
117148
118149 # step 2 (optional): combine these two libdart_ffi.a into one libdart_ffi.a if the build arch is universal
119150 if [ " $BUILD_ARCH " = " universal" ]; then
120- echo " Combining libdart_ffi.a for universal..."
151+ info " Combining libdart_ffi.a for universal..."
121152 lipo -create \
122153 rust-lib/target/x86_64-apple-darwin/release/libdart_ffi.a \
123154 rust-lib/target/aarch64-apple-darwin/release/libdart_ffi.a \
124155 -output rust-lib/target/libdart_ffi.a
125156
157+ info " Checking the libdart_ffi.a for universal..."
126158 lipo -archs rust-lib/target/libdart_ffi.a
127159
128160 cp -rf rust-lib/target/libdart_ffi.a \
@@ -132,55 +164,61 @@ prepare_build() {
132164
133165 # step 3 (optional): generate the flutter code: languages, icons and freezed files.
134166 if [ " $SKIP_CODE_GENERATION " != " true" ]; then
135- echo " Generating the flutter code...(This may take a while)"
167+ info " Generating the flutter code...(This may take a while)"
136168 cargo make code_generation
137169 fi
138170
139171 # step 4: build the zip package
140- echo " Building the zip package..."
172+ info " Building the zip package..."
141173 cd appflowy_flutter
142174 flutter_distributor release --name=prod --jobs=release-prod-macos-zip --skip-clean
143175 cd ..
144176}
145177
146178build_zip () {
147- echo " Building zip package version $VERSION ..."
179+ info " Building zip package version $VERSION ..."
148180
149181 # step 1: check if the macos zip package is built, if not, build the zip package
150182 if [ ! -f " appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .zip" ]; then
151- echo " Macos zip package is not built. Building the zip package..."
183+ info " macOS zip package is not built. Building the zip package..."
152184 prepare_build
153185
154186 # step 1.1: move the zip package to the build directory
155187 mv appflowy_flutter/build/$VERSION /appflowy-$VERSION +$VERSION -macos.zip appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .zip
156188 fi
157189
158190 # step 2: unzip the zip package and codesign the app
159- unzip appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .zip
191+ unzip -o appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .zip > /dev/null 2>&1
160192
161193 # step 3: codesign the app
162194 # note: You must install the certificate to the system before codesigning
163195 codesign --force --options runtime --deep --sign " Developer ID Application: APPFLOWY PTE. LTD" --deep --verbose AppFlowy.app -v
164196
165197 # step 4: zip the app again
166- 7z a appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .zip AppFlowy.app
198+ 7z a appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .zip AppFlowy.app > /dev/null 2>&1
167199
168- echo " Zip package built successfully"
200+ info " Zip package built successfully"
169201}
170202
171203build_dmg () {
172- echo " Building DMG package version $VERSION ..."
204+ info " Building DMG package version $VERSION ..."
173205
174206 # step 1: check if the macos zip package is built, if not, build the zip package
175207 if [ ! -f " appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .zip" ]; then
176- echo " Macos zip package is not built. Building the zip package..."
208+ info " macOS zip package is not built. Building the zip package..."
177209 build_zip
178210 fi
179211
180212 # step 2: unzip the zip package and copy the make_config.json file to the build directory
181- unzip appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .zip -d appflowy_flutter/build/$VERSION /
213+ unzip appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .zip -d appflowy_flutter/build/$VERSION / > /dev/null 2>&1
182214 cp appflowy_flutter/macos/packaging/dmg/make_config.json appflowy_flutter/build/$VERSION /
183215
216+ # check if the AppFlowy.app doesn't exist, exit the script
217+ if [ ! -d " appflowy_flutter/build/$VERSION /AppFlowy.app" ]; then
218+ error " AppFlowy.app doesn't exist. Please check the zip package."
219+ exit 1
220+ fi
221+
184222 # step 3: build the dmg package using appdmg
185223 # note: You must install the appdmg to the system before building the dmg package
186224 appdmg appflowy_flutter/build/$VERSION /make_config.json appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .dmg
@@ -189,10 +227,19 @@ build_dmg() {
189227 rm -rf appflowy_flutter/build/$VERSION /AppFlowy.app
190228 rm -rf appflowy_flutter/build/$VERSION /make_config.json
191229
192- echo " DMG package built successfully. Please use the following command to submit the dmg package to the notary service:"
193- echo " xcrun notarytool submit appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .dmg --apple-id <your-apple-id> --team-id <your-team-id> --password <your-password> -v -f \" json\" --wait"
230+ info " DMG package built successfully. The dmg package is located at appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .dmg"
231+
232+ if [ -z " $APPLE_ID " ] || [ -z " $TEAM_ID " ] || [ -z " $PASSWORD " ]; then
233+ error " The apple id, team id and password are not specified. Please notarize the dmg package manually."
234+ error " xcrun notarytool submit appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .dmg --apple-id <your-apple-id> --team-id <your-team-id> --password <your-password> -v -f \" json\" --wait"
235+ else
236+ xcrun notarytool submit appflowy_flutter/build/$VERSION /appflowy-$VERSION -macos-$BUILD_ARCH .dmg --apple-id $APPLE_ID --team-id $TEAM_ID --password $PASSWORD -v -f " json" --wait
237+ info " Notarization is completed. Please check the notarization status"
238+ fi
194239}
195240
241+ clear_cache
242+
196243# Build packages based on build type
197244case $BUILD_TYPE in
198245" all" )
0 commit comments