From 6cccf0aea43dfe7324fcc9f17b57883084e21608 Mon Sep 17 00:00:00 2001 From: bekroz Date: Fri, 26 Apr 2024 19:48:54 +0400 Subject: [PATCH] upd: ci --- .github/workflows/ios.yml | 73 ++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 6493507..4cfc154 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -1,44 +1,45 @@ -name: iOS starter workflow +name: iOS CI on: push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + branches: [ main ] jobs: build: - name: Build and Test default scheme using any available iPhone simulator - runs-on: macos-latest + runs-on: macOS-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set Default Scheme - run: | - scheme_list=$(xcodebuild -list -json | tr -d "\n") - default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]") - echo $default | cat >default - echo Using default scheme: $default - - name: Build - env: - scheme: ${{ 'default' }} - platform: ${{ 'iOS Simulator' }} - run: | - # xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) - device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"` - if [ $scheme = default ]; then scheme=$(cat default); fi - if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi - file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` - xcodebuild build-for-testing -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,name=$device" - - name: Test - env: - scheme: ${{ 'default' }} - platform: ${{ 'iOS Simulator' }} - run: | - # xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) - device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"` - if [ $scheme = default ]; then scheme=$(cat default); fi - if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi - file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` - xcodebuild test-without-building -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,name=$device" + - name: Checkout Repo + uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + bundler-cache: true + + - name: Cache Fastlane + uses: actions/cache@v2 + with: + path: ~/.gem + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gem- + - name: Install dependencies + run: | + gem install bundler + bundle install --without=documentation + + - name: Build and Test + run: | + xcodebuild -workspace YourWorkspace.xcworkspace -scheme YourScheme -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/YourApp.xcarchive + + - name: Export .ipa + run: | + xcodebuild -exportArchive -archivePath $PWD/build/YourApp.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath $PWD/build + + - name: Install Fastlane + run: bundle exec fastlane init + + - name: Upload to TestFlight + run: bundle exec fastlane pilot upload \ No newline at end of file