From 96d9aa20524f8984aed0eccd8cbabc41c981f8a6 Mon Sep 17 00:00:00 2001 From: Roxk Date: Mon, 9 Sep 2024 17:22:03 +0800 Subject: [PATCH] ci-cd: Setup fastlane --- .github/workflows/ci.yaml | 38 +++++++++++++++++------------ XamarinFormSample/Gemfile | 3 +++ XamarinFormSample/fastlane/Appfile | 6 +++++ XamarinFormSample/fastlane/Fastfile | 17 +++++++++++++ flutter-example/Gemfile | 3 +++ flutter-example/fastlane/Fastfile | 17 +++++++++++++ 6 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 XamarinFormSample/Gemfile create mode 100644 XamarinFormSample/fastlane/Appfile create mode 100644 XamarinFormSample/fastlane/Fastfile create mode 100644 flutter-example/Gemfile create mode 100644 flutter-example/fastlane/Fastfile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0c0c3e3..3026090 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,5 +1,9 @@ name: CI +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: branches: @@ -128,11 +132,10 @@ jobs: working-directory: "./flutter-example" steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 16 - run: sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer - - run: npm install -g appcenter-cli + - run: gem install bundler + - working-directory: flutter-example + run: bundler install - uses: subosito/flutter-action@v2 with: # Do _NOT_ use the latest stable as those contain breaking changes @@ -169,19 +172,17 @@ jobs: run: | BUILD_NUMBER=$(date +%s) flutter build ipa --export-options-plist ./exportOptions.plist --build-number $BUILD_NUMBER - - name: Distribute to App Center - env: - APPCENTER_ACCESS_TOKEN: ${{ secrets.IOS_APPCENTER_ACCESS_TOKEN }} - run: appcenter distribute release --debug --silent --file "./build/ios/ipa/Authgear Flutter.ipa" --group "Collaborators" --app "Oursky/Authgear-Migrate-Tool-Xamarin-To-Flutter-Sample" --release-notes "flutter ios" + - name: Distribute to App Store Connect + run: bundle exec fastlane app_testflight xamarin-ios: runs-on: macos-12 - needs: ["test-xamarin", "test-flutter"] + # needs: ["test-xamarin", "test-flutter"] if: ${{ github.ref == 'refs/heads/main' }} steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: "18.x" + - run: gem install bundler + - working-directory: flutter-example + run: bundler install - uses: actions/setup-dotnet@v3 with: global-json-file: ./global.json @@ -224,10 +225,17 @@ jobs: /usr/libexec/Plistbuddy -c "Set CFBundleVersion $BUILD_NUMBER" ./XamarinFormSample/XamarinFormSample.iOS/Info.plist - name: msbuild run: msbuild ./XamarinFormSample/XamarinFormSample.iOS/XamarinFormSample.iOS.csproj /p:Configuration=Release /p:Platform=iPhone /p:BuildIpa=true /t:Rebuild /p:IpaPackageDir="$RUNNER_TEMP" - - name: Distribute to App Center + - name: Distribute to App Store Connect + working-directory: XamarinFormSample env: - APPCENTER_ACCESS_TOKEN: ${{ secrets.IOS_APPCENTER_ACCESS_TOKEN }} - run: appcenter distribute release --debug --silent --file "$RUNNER_TEMP/XamarinFormSample.iOS.ipa" --group "Collaborators" --app "Oursky/Authgear-Migrate-Tool-Xamarin-To-Flutter-Sample" --release-notes "xamarin ios" + IOS_FASTLANE_APP_STORE_CONNECT_API_KEY_JSON_BASE64: ${{ secrets.IOS_FASTLANE_APP_STORE_CONNECT_API_KEY_JSON_BASE64 }} + run: | + APP_STORE_CONNECT_API_KEY_FILE=$RUNNER_TEMP/app_store_connect_key.json + echo -n "$IOS_FASTLANE_APP_STORE_CONNECT_API_KEY_JSON_BASE64" | base64 --decode -o $APP_STORE_CONNECT_API_KEY_FILE + APP_IPA_FILE_PATH=$RUNNER_TEMP/XamarinFormSample.iOS.ipa + ls -la $RUNNER_TEMP + echo $APP_STORE_CONNECT_API_KEY_FILE + bundle exec fastlane app_testflight - name: Clean up keychain and provisioning profile if: ${{ always() }} run: | diff --git a/XamarinFormSample/Gemfile b/XamarinFormSample/Gemfile new file mode 100644 index 0000000..7a118b4 --- /dev/null +++ b/XamarinFormSample/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gem "fastlane" diff --git a/XamarinFormSample/fastlane/Appfile b/XamarinFormSample/fastlane/Appfile new file mode 100644 index 0000000..4282947 --- /dev/null +++ b/XamarinFormSample/fastlane/Appfile @@ -0,0 +1,6 @@ +# app_identifier("[[APP_IDENTIFIER]]") # The bundle identifier of your app +# apple_id("[[APPLE_ID]]") # Your Apple Developer Portal username + + +# For more information about the Appfile, see: +# https://docs.fastlane.tools/advanced/#appfile diff --git a/XamarinFormSample/fastlane/Fastfile b/XamarinFormSample/fastlane/Fastfile new file mode 100644 index 0000000..9c993f5 --- /dev/null +++ b/XamarinFormSample/fastlane/Fastfile @@ -0,0 +1,17 @@ + +default_platform(:ios) + +platform :ios do + desc "Deploy app" + lane :app_deploy do |options| + app_testflight options + end + + desc "Upload app to testflight" + lane :app_testflight do |options| + upload_to_testflight( + api_key_pat: ENV['APP_STORE_CONNECT_API_KEY_FILE'], + skip_waiting_for_build_processing: true + ) + end +end diff --git a/flutter-example/Gemfile b/flutter-example/Gemfile new file mode 100644 index 0000000..7a118b4 --- /dev/null +++ b/flutter-example/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gem "fastlane" diff --git a/flutter-example/fastlane/Fastfile b/flutter-example/fastlane/Fastfile new file mode 100644 index 0000000..481db32 --- /dev/null +++ b/flutter-example/fastlane/Fastfile @@ -0,0 +1,17 @@ + +default_platform(:ios) + +platform :ios do + desc "Deploy app" + lane :app_deploy do |options| + app_testflight options + end + + desc "Upload app to testflight" + lane :app_testflight do |options| + upload_to_testflight( + api_key_path: ENV['APP_STORE_CONNECT_API_KEY_FILE'], + skip_waiting_for_build_processing: true + ) + end +end