From a7465b665af7e9d773ca4d9cad6017fa8d13808e 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 | 31 +++++++++++++++-------------- XamarinFormSample/Gemfile | 3 +++ XamarinFormSample/fastlane/Fastfile | 17 ++++++++++++++++ flutter-example/Gemfile | 3 +++ flutter-example/fastlane/Fastfile | 17 ++++++++++++++++ 5 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 XamarinFormSample/Gemfile 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..1e67058 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -128,11 +128,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 +168,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"] 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 +221,14 @@ 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 - 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" + - name: Setup App Store Connect + run: | + ASC_KEY_PATH=$RUNNER_TEMP/app_store_connect_key.json + echo -n "$IOS_FASTLANE_APP_STORE_CONNECT_API_KEY_JSON_BASE64" | base64 --decode -o $ASC_KEY_PATH + echo "APP_STORE_CONNECT_API_KEY_FILE=$RUNNER_TEMP/app_store_connect_key.json" >> $GITHUB_ENV + - name: Distribute to App Store Connect + working-directory: XamarinFormSample + run: 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/Fastfile b/XamarinFormSample/fastlane/Fastfile new file mode 100644 index 0000000..481db32 --- /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_path: 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