Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: Support CI build universal macOS package (#3124)

Lucas.Xuf724185f1c78
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d20122c7c8..790980c77d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -124,7 +124,7 @@ jobs:
asset_name: ${{ env.WINDOWS_INSTALLER_NAME }}.exe
asset_content_type: application/octet-stream
- build-for-macOS:
+ build-for-macOS-x86_64:
name: ${{ matrix.job.target }} (${{ matrix.job.os }}) [${{ matrix.job.extra-build-args }}]
runs-on: ${{ matrix.job.os }}
needs: create-release
@@ -212,6 +212,92 @@ jobs:
asset_name: ${{ env.MACOS_DMG_NAME }}.dmg
asset_content_type: application/octet-stream
+ build-for-macOS-universal:
+ name: ${{ matrix.job.target }} (${{ matrix.job.os }}) [${{ matrix.job.extra-build-args }}]
+ runs-on: ${{ matrix.job.os }}
+ needs: create-release
+ env:
+ MACOS_APP_RELEASE_PATH: frontend/appflowy_flutter/product/${{ github.ref_name }}/macos/Release
+ MACOS_AARCH64_ZIP_NAME: AppFlowy_${{ github.ref_name }}_macos-universal.zip
+ MACOS_DMG_NAME: AppFlowy_${{ github.ref_name }}_macos-universal
+ strategy:
+ fail-fast: false
+ matrix:
+ job:
+ - { targets: 'aarch64-apple-darwin,x86_64-apple-darwin', os: macos-11, extra-build-args: "" }
+ steps:
+ - name: Checkout source code
+ uses: actions/checkout@v3
+
+ - name: Install flutter
+ uses: subosito/flutter-action@v2
+ with:
+ channel: "stable"
+ flutter-version: ${{ env.FLUTTER_VERSION }}
+ cache: true
+
+ - name: Install Rust toolchain
+ uses: dtolnay/rust-toolchain@stable
+ with:
+ toolchain: ${{ env.RUST_TOOLCHAIN }}
+ targets: ${{ matrix.job.targets }}
+ components: rustfmt
+
+ - uses: Swatinem/rust-cache@v2
+ with:
+ prefix-key: appflowy-lib-cache
+ key: ${{ matrix.job.os }}-${{ matrix.job.target }}
+
+ - name: Install prerequisites
+ working-directory: frontend
+ run: |
+ cargo install --force cargo-make
+ cargo install --force duckscript_cli
+
+ - name: Build AppFlowy
+ working-directory: frontend
+ run: |
+ flutter config --enable-macos-desktop
+ sh scripts/flutter_release_build/build_universal_package_for_macos.sh
+
+ - name: Create macOS dmg
+ run: |
+ brew install create-dmg
+ create-dmg \
+ --volname ${{ env.MACOS_DMG_NAME }} \
+ --hide-extension "AppFlowy.app" \
+ --background frontend/scripts/dmg_assets/AppFlowyInstallerBackground.jpg \
+ --window-size 600 450 \
+ --icon-size 94 \
+ --icon "AppFlowy.app" 141 249 \
+ --app-drop-link 458 249 \
+ "${{ env.MACOS_APP_RELEASE_PATH }}/${{ env.MACOS_DMG_NAME }}.dmg" \
+ "${{ env.MACOS_APP_RELEASE_PATH }}/AppFlowy.app"
+
+ - name: Archive Asset
+ working-directory: ${{ env.MACOS_APP_RELEASE_PATH }}
+ run: zip --symlinks -qr ${{ env.MACOS_AARCH64_ZIP_NAME }} AppFlowy.app
+
+ - name: Upload Asset
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ needs.create-release.outputs.upload_url }}
+ asset_path: ${{ env.MACOS_APP_RELEASE_PATH }}/${{ env.MACOS_AARCH64_ZIP_NAME }}
+ asset_name: ${{ env.MACOS_AARCH64_ZIP_NAME }}
+ asset_content_type: application/octet-stream
+
+ - name: Upload DMG Asset
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ needs.create-release.outputs.upload_url }}
+ asset_path: ${{ env.MACOS_APP_RELEASE_PATH }}/${{ env.MACOS_DMG_NAME }}.dmg
+ asset_name: ${{ env.MACOS_DMG_NAME }}.dmg
+ asset_content_type: application/octet-stream
+
build-for-linux:
name: ${{ matrix.job.target }} (${{ matrix.job.os }}) [${{ matrix.job.extra-build-args }}]
runs-on: ${{ matrix.job.os }}
@@ -360,7 +446,7 @@ jobs:
notify-discord:
runs-on: ubuntu-latest
- needs: [build-for-linux, build-for-windows, build-for-macOS]
+ needs: [build-for-linux, build-for-windows, build-for-macOS-x86_64, build-for-macOS-universal]
steps:
- name: Notify Discord
run: |
diff --git a/frontend/Makefile.toml b/frontend/Makefile.toml
index ed8e90af04..e9d49ebadd 100644
--- a/frontend/Makefile.toml
+++ b/frontend/Makefile.toml
@@ -60,6 +60,7 @@ BUILD_FLAG = "debug"
FLUTTER_OUTPUT_DIR = "Debug"
PRODUCT_EXT = "app"
BUILD_ARCHS = "arm64"
+BUILD_ACTIVE_ARCHS_ONLY = true
CRATE_TYPE = "staticlib"
[env.development-mac-x86_64]
@@ -70,6 +71,7 @@ BUILD_FLAG = "debug"
FLUTTER_OUTPUT_DIR = "Debug"
PRODUCT_EXT = "app"
BUILD_ARCHS = "x86_64"
+BUILD_ACTIVE_ARCHS_ONLY = true
CRATE_TYPE = "staticlib"
[env.production-mac-arm64]
@@ -80,6 +82,7 @@ FLUTTER_OUTPUT_DIR = "Release"
PRODUCT_EXT = "app"
APP_ENVIRONMENT = "production"
BUILD_ARCHS = "arm64"
+BUILD_ACTIVE_ARCHS_ONLY = false
CRATE_TYPE = "staticlib"
[env.production-mac-x86_64]
@@ -90,8 +93,17 @@ FLUTTER_OUTPUT_DIR = "Release"
PRODUCT_EXT = "app"
APP_ENVIRONMENT = "production"
BUILD_ARCHS = "x86_64"
+BUILD_ACTIVE_ARCHS_ONLY = false
CRATE_TYPE = "staticlib"
+[env.production-mac-universal]
+BUILD_FLAG = "release"
+TARGET_OS = "macos"
+FLUTTER_OUTPUT_DIR = "Release"
+PRODUCT_EXT = "app"
+BUILD_ACTIVE_ARCHS_ONLY = false
+APP_ENVIRONMENT = "production"
+
[env.development-windows-x86]
TARGET_OS = "windows"
RUST_COMPILE_TARGET = "x86_64-pc-windows-msvc"
diff --git a/frontend/appflowy_flutter/macos/Podfile b/frontend/appflowy_flutter/macos/Podfile
index 715baa2d38..e22f3fddd7 100644
--- a/frontend/appflowy_flutter/macos/Podfile
+++ b/frontend/appflowy_flutter/macos/Podfile
@@ -27,18 +27,31 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe
flutter_macos_podfile_setup
def build_specify_archs_only
- # if ENV.has_key?('BUILD_ARCHS')
- # xcodeproj_path = File.dirname(__FILE__) + '/Runner.xcodeproj'
- # project = Xcodeproj::Project.open(xcodeproj_path)
- # project.targets.each do |target|
- # if target.name == 'Runner'
- # target.build_configurations.each do |config|
- # config.build_settings['ARCHS'] = ENV['BUILD_ARCHS']
- # end
- # end
- # end
- # project.save()
- # end
+ if ENV.has_key?('BUILD_ACTIVE_ARCHS_ONLY')
+ xcodeproj_path = File.dirname(__FILE__) + '/Runner.xcodeproj'
+ project = Xcodeproj::Project.open(xcodeproj_path)
+ project.targets.each do |target|
+ if target.name == 'Runner'
+ target.build_configurations.each do |config|
+ config.build_settings['ONLY_ACTIVE_ARCH'] = ENV['BUILD_ACTIVE_ARCHS_ONLY']
+ end
+ end
+ end
+ project.save()
+ end
+
+ if ENV.has_key?('BUILD_ARCHS')
+ xcodeproj_path = File.dirname(__FILE__) + '/Runner.xcodeproj'
+ project = Xcodeproj::Project.open(xcodeproj_path)
+ project.targets.each do |target|
+ if target.name == 'Runner'
+ target.build_configurations.each do |config|
+ config.build_settings['ARCHS'] = ENV['BUILD_ARCHS']
+ end
+ end
+ end
+ project.save()
+ end
end
build_specify_archs_only()
diff --git a/frontend/scripts/flutter_release_build/build_universal_package_for_macos.sh b/frontend/scripts/flutter_release_build/build_universal_package_for_macos.sh
index fe073a1fe7..a5c90dc194 100644
--- a/frontend/scripts/flutter_release_build/build_universal_package_for_macos.sh
+++ b/frontend/scripts/flutter_release_build/build_universal_package_for_macos.sh
@@ -24,4 +24,4 @@ cp -rf rust-lib/target/libdart_ffi.a \
echo '🚀 ---------------------------------------------------'
echo '🚀 building the flutter application for macOS'
-flutter build macos --release
+cargo make --profile production-mac-universal appflowy-macos-unviersal
diff --git a/frontend/scripts/makefile/flutter.toml b/frontend/scripts/makefile/flutter.toml
index 9d56b0e564..8319d0d2bf 100644
--- a/frontend/scripts/makefile/flutter.toml
+++ b/frontend/scripts/makefile/flutter.toml
@@ -13,6 +13,15 @@ run_task = { name = [
] }
script_runner = "@shell"
+[tasks.appflowy-macos-universal]
+run_task = { name = [
+ "code_generation",
+ "set-app-version",
+ "flutter-build",
+ "copy-to-product",
+] }
+script_runner = "@shell"
+
[tasks.appflowy-windows]
dependencies = ["appflowy-core-release"]
run_task = { name = [