From 352c42a176078942e58c1796a2cfd5abbec01fdf Mon Sep 17 00:00:00 2001 From: Jagandeep Brar Date: Sun, 3 Apr 2022 21:14:25 -0400 Subject: [PATCH] chore(ci): build and deploy notarized macOS disk image --- .github/actions/prepare_for_build/action.yml | 7 ++- .github/workflows/build_android.yml | 2 +- .github/workflows/build_ios.yml | 4 +- .github/workflows/build_linux.yml | 6 +- .github/workflows/build_macos.yml | 58 ++++++++++++++++--- .github/workflows/publish.yml | 16 ++++-- .github/workflows/release.yml | 1 + .gitignore | 1 + macos/fastlane/Fastfile | 59 ++++++++++++++++---- macos/fastlane/README.md | 26 +++++++-- 10 files changed, 145 insertions(+), 35 deletions(-) diff --git a/.github/actions/prepare_for_build/action.yml b/.github/actions/prepare_for_build/action.yml index 8dbb23af73..9b4a233567 100644 --- a/.github/actions/prepare_for_build/action.yml +++ b/.github/actions/prepare_for_build/action.yml @@ -106,7 +106,12 @@ runs: run: | npm install -g firebase-tools dart pub global activate flutterfire_cli - flutterfire configure -y + + flutterfire configure \ + --android-app-id=app.lunasea.lunasea \ + --ios-bundle-id=app.lunasea.lunasea \ + --macos-bundle-id=app.lunasea.lunasea \ + --yes - name: Setup Android Platform if: ${{ inputs.platform == 'android' }} diff --git a/.github/workflows/build_android.yml b/.github/workflows/build_android.yml index dab5e5bbb6..1823b906c6 100644 --- a/.github/workflows/build_android.yml +++ b/.github/workflows/build_android.yml @@ -17,7 +17,7 @@ on: jobs: build-playstore-package: - name: Play Store Package + name: Play Store runs-on: ubuntu-latest steps: - name: Setup Environment diff --git a/.github/workflows/build_ios.yml b/.github/workflows/build_ios.yml index b366d82ebf..b447f061ec 100644 --- a/.github/workflows/build_ios.yml +++ b/.github/workflows/build_ios.yml @@ -28,8 +28,8 @@ on: required: true jobs: - build-appstore-package: - name: App Store Package + build-app-store: + name: App Store runs-on: macos-latest steps: - name: Setup Environment diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index a7e05e20f4..70e8548e26 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -12,8 +12,8 @@ on: required: true jobs: - build-snap: - name: Snap + build-snapcraft: + name: Snapcraft runs-on: ubuntu-latest steps: - name: Setup Environment @@ -32,5 +32,5 @@ jobs: - name: Upload Artifact uses: actions/upload-artifact@v3 with: - name: linux-snap + name: linux-snapcraft path: ${{ github.workspace }}/output diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 1430849711..a2478d581d 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -6,6 +6,9 @@ on: build-number: required: true type: string + build-version: + required: true + type: string secrets: APPLE_ID: @@ -36,8 +39,8 @@ on: required: true jobs: - build-appstore-package: - name: App Store Package + build-app-store: + name: App Store runs-on: macos-latest steps: - name: Setup Environment @@ -52,12 +55,15 @@ jobs: env: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} + APPLE_STORE_CONNECT_ISSUER_ID: ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} + APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ github.workspace }}/keys/appstore.p8 + APPLE_STORE_CONNECT_KEY_ID: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} MACOS_INSTALLER_CERT_APP_STORE: ${{ secrets.MACOS_INSTALLER_CERT_APP_STORE }} MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }} MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - run: bundle exec fastlane build_appstore build_number:${{ inputs.build-number }} + run: bundle exec fastlane build_app_store build_number:${{ inputs.build-number }} - name: Upload Artifact uses: actions/upload-artifact@v3 @@ -65,8 +71,8 @@ jobs: name: macos-appstore-package path: ${{ github.workspace }}/output - build-noatized-package: - name: Notarized Package + build-app-package: + name: App Package runs-on: macos-latest steps: - name: Setup Environment @@ -90,10 +96,48 @@ jobs: MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }} MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - run: bundle exec fastlane build_direct build_number:${{ inputs.build-number }} + run: bundle exec fastlane build_app_package build_number:${{ inputs.build-number }} + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: macos-app-package + path: ${{ github.workspace }}/output + + build-disk-image: + name: Disk Image + runs-on: macos-latest + steps: + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master + with: + firebase-token: ${{ secrets.FIREBASE_TOKEN }} + platform: macos + appstore-connect-key: ${{ secrets.APPLE_STORE_CONNECT_KEY }} + match-ssh-private-key: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} + + - name: Setup Disk Image Creator + run: | + npm install -g create-dmg + brew install graphicsmagick imagemagick + + - name: Build LunaSea + working-directory: ${{ github.workspace }}/macos + env: + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} + APPLE_STORE_CONNECT_ISSUER_ID: ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} + APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ github.workspace }}/keys/appstore.p8 + APPLE_STORE_CONNECT_KEY_ID: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + MACOS_INSTALLER_CERT_DIRECT: ${{ secrets.MACOS_INSTALLER_CERT_DIRECT }} + MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }} + MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + run: bundle exec fastlane build_disk_image build_number:${{ inputs.build-number }} build_version:${{ inputs.build-version }} - name: Upload Artifact uses: actions/upload-artifact@v3 with: - name: macos-notarized-package + name: macos-disk-image path: ${{ github.workspace }}/output diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b418150c01..713d2af23a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -128,13 +128,13 @@ jobs: - name: Download Snap uses: actions/download-artifact@v3 with: - name: linux-snap + name: linux-snapcraft path: ${{ github.workspace }}/output - name: Deploy to Snapcraft run: snapcraft upload --release=${{ inputs.flavor }} ${{ github.workspace }}/output/LunaSea-Linux-amd64.snap - macos-app-store: + macos-appstore: name: App Store (macOS) runs-on: macos-latest steps: @@ -227,13 +227,19 @@ jobs: - name: Download Linux Snap uses: actions/download-artifact@v3 with: - name: linux-snap + name: linux-snapcraft path: ${{ github.workspace }}/output - - name: Download macOS Notarized Package + - name: Download macOS App Package uses: actions/download-artifact@v3 with: - name: macos-notarized-package + name: macos-app-package + path: ${{ github.workspace }}/output + + - name: Download macOS Disk Image + uses: actions/download-artifact@v3 + with: + name: macos-disk-image path: ${{ github.workspace }}/output - name: Upload to S3 Bucket diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e37a076dfc..aebe4c0615 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,6 +86,7 @@ jobs: uses: JagandeepBrar/LunaSea/.github/workflows/build_macos.yml@master with: build-number: ${{ needs.prepare.outputs.build-number }} + build-version: ${{ needs.prepare.outputs.build-version }} secrets: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} diff --git a/.gitignore b/.gitignore index 33a5c11d1f..d092be16a5 100644 --- a/.gitignore +++ b/.gitignore @@ -76,5 +76,6 @@ output/ *.apk *.aab *.ipa +*.dmg *.pkg *.snap diff --git a/macos/fastlane/Fastfile b/macos/fastlane/Fastfile index 3146fcda7e..5345c5f30c 100644 --- a/macos/fastlane/Fastfile +++ b/macos/fastlane/Fastfile @@ -56,10 +56,48 @@ platform :mac do ) end + desc "Build App Package for Direct Deployment" + lane :build_app_package do |options| + keychain_create + keychain_setup + connect_appstore_connect + + sh( + "flutter", "build", "macos", + "--release", + "--build-number=#{options[:build_number]}", + ) + build_mac_app( + scheme: "Runner", + workspace: "Runner.xcworkspace", + installer_cert_name: ENV["MACOS_INSTALLER_CERT_DIRECT"], + export_method: "developer-id", + export_options: { + provisioningProfiles: { + "app.lunasea.lunasea" => "match Direct app.lunasea.lunasea macos", + } + } + ) + + notarize( + package: "LunaSea.app", + use_notarytool: true, + ) + sh("mkdir", "-p", "../../output") + sh("mv", "../LunaSea.app", "../../output/LunaSea.app") + Dir.chdir("../../output") do + sh("zip", "-r", "-y", "LunaSea-macOS.zip", "LunaSea.app") + sh("rm", "-rf", "LunaSea.app") + end + + keychain_delete + end + desc "Build App Package for App Store" - lane :build_appstore do |options| + lane :build_app_store do |options| keychain_create keychain_setup + connect_appstore_connect sh( "flutter", "build", "macos", @@ -83,8 +121,8 @@ platform :mac do keychain_delete end - desc "Build App Package for Direct Deployment" - lane :build_direct do |options| + desc "Build Disk Image for Direct Deployment" + lane :build_disk_image do |options| keychain_create keychain_setup connect_appstore_connect @@ -105,17 +143,16 @@ platform :mac do } } ) + + Dir.chdir("../") do + sh("create-dmg", "LunaSea.app", "--overwrite") + end notarize( - package: "LunaSea.app", + package: "LunaSea #{options[:build_version]}.dmg", + bundle_id: "app.lunasea.lunasea.DiskImage", use_notarytool: true, ) - - sh("mkdir", "-p", "../../output") - sh("cp", "-R", "../LunaSea.app", "../../output/LunaSea.app") - Dir.chdir("../../output") do - sh("zip", "-r", "-y", "LunaSea-macOS.zip", "LunaSea.app") - sh("rm", "-rf", "LunaSea.app") - end + sh("mv", "../LunaSea #{options[:build_version]}.dmg", "../../output/LunaSea-macOS.dmg") keychain_delete end diff --git a/macos/fastlane/README.md b/macos/fastlane/README.md index 7333cee959..08032dd97c 100644 --- a/macos/fastlane/README.md +++ b/macos/fastlane/README.md @@ -47,22 +47,38 @@ Setup the Keychain Connect to App Store Connect -### mac build_appstore +### mac build_app_installer ```sh -[bundle exec] fastlane mac build_appstore +[bundle exec] fastlane mac build_app_installer ``` -Build App Package for App Store +Build App Installer for Direct Deployment -### mac build_direct +### mac build_app_package ```sh -[bundle exec] fastlane mac build_direct +[bundle exec] fastlane mac build_app_package ``` Build App Package for Direct Deployment +### mac build_app_store + +```sh +[bundle exec] fastlane mac build_app_store +``` + +Build App Package for App Store + +### mac build_disk_image + +```sh +[bundle exec] fastlane mac build_disk_image +``` + +Build Disk Image for Direct Deployment + ### mac deploy_appstore ```sh