Fastlane

원장·2025년 8월 27일

플러터 기초

목록 보기
36/36

Fastlane

bundle exec fastlane release

Fastlane만 있으면 안드로이드, ios 배포 과정이 명령어 1줄로 끝남.

app distribution, test flight, 앱 심사 제출

Fastlane 코드 예시

# Fastfile - iOS 앱 배포 자동화 예시

default_platform(:ios)

platform :ios do
  # 환경 변수 설정
  before_all do
    ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "120"
    ENV["FASTLANE_XCODEBUILD_SETTINGS_RETRIES"] = "6"
  end

  # 테스트 실행 레인
  desc "테스트 실행"
  lane :test do
    run_tests(
      scheme: "MyApp",
      devices: ["iPhone 14", "iPhone 14 Pro"],
      code_coverage: true
    )
  end

  # 개발용 빌드 및 배포 (TestFlight)
  desc "개발 빌드를 TestFlight에 업로드"
  lane :beta do
    # 인증서 및 프로비저닝 프로필 동기화
    match(type: "appstore", readonly: true)
    
    # 빌드 번호 자동 증가
    increment_build_number(xcodeproj: "MyApp.xcodeproj")
    
    # 앱 빌드
    build_app(
      scheme: "MyApp",
      export_method: "app-store",
      output_directory: "./builds"
    )
    
    # TestFlight에 업로드
    upload_to_testflight(
      skip_waiting_for_build_processing: true,
      notify_external_testers: false
    )
    
    # Slack 알림
    slack(
      message: "새 베타 빌드가 TestFlight에 업로드되었습니다! 🚀",
      channel: "#ios-team",
      success: true
    )
  end

  # 프로덕션 배포 레인
  desc "App Store에 배포"
  lane :release do
    # 인증서 설정
    match(type: "appstore", readonly: true)
    
    # 메타데이터 업데이트 (App Store Connect)
    deliver(
      submit_for_review: false,
      automatic_release: false,
      force: true,
      metadata_path: "./fastlane/metadata",
      screenshots_path: "./fastlane/screenshots"
    )
    
    # 앱 빌드
    build_app(
      scheme: "MyApp",
      export_method: "app-store"
    )
    
    # App Store Connect에 업로드
    upload_to_app_store(
      submit_for_review: true,
      automatic_release: true,
      force: true,
      submission_information: {
        add_id_info_limits_tracking: true,
        add_id_info_serves_ads: false,
        add_id_info_tracks_action: true,
        add_id_info_tracks_install: true,
        add_id_info_uses_idfa: true,
        content_rights_has_rights: true,
        content_rights_contains_third_party_content: true,
        export_compliance_platform: 'ios',
        export_compliance_compliance_required: false,
        export_compliance_encryption_updated: false,
        export_compliance_app_type: nil,
        export_compliance_uses_encryption: false
      }
    )
    
    # 성공 알림
    slack(
      message: "🎉 앱이 App Store 심사에 제출되었습니다!",
      channel: "#releases"
    )
  end

  # 스크린샷 자동 생성
  desc "스크린샷 생성"
  lane :screenshots do
    capture_screenshots(
      scheme: "MyAppUITests",
      output_directory: "./fastlane/screenshots",
      clear_previous_screenshots: true,
      override_status_bar: true,
      devices: [
        "iPhone 14 Pro Max",
        "iPhone 14 Pro",
        "iPhone 14",
        "iPhone SE (3rd generation)",
        "iPad Pro (12.9-inch) (6th generation)",
        "iPad Pro (12.9-inch) (2nd generation)"
      ]
    )
  end

  # 코드 사이닝 설정
  desc "코드 사이닝 인증서 설정"
  lane :certificates do
    match(
      type: "development",
      force_for_new_devices: true
    )
    match(
      type: "appstore",
      force_for_new_devices: true
    )
  end

  # 에러 발생시 처리
  error do |lane, exception, options|
    slack(
      message: "❌ #{lane} 레인에서 에러 발생: #{exception}",
      success: false,
      channel: "#ios-team"
    )
  end
end

# Android 플랫폼 설정
platform :android do
  desc "Android 테스트 실행"
  lane :test do
    gradle(task: "test")
  end

  desc "Google Play Console에 베타 업로드"
  lane :beta do
    gradle(
      task: "bundle",
      build_type: "Release"
    )
    
    upload_to_play_store(
      track: "internal",
      aab: "./app/build/outputs/bundle/release/app-release.aab",
      skip_upload_metadata: true,
      skip_upload_changelogs: true,
      skip_upload_images: true,
      skip_upload_screenshots: true
    )
    
    slack(
      message: "Android 베타 빌드가 Google Play Console에 업로드되었습니다! 🤖",
      channel: "#android-team"
    )
  end

  desc "Google Play Store에 배포"
  lane :deploy do
    gradle(
      task: "bundle",
      build_type: "Release"
    )
    
    upload_to_play_store(
      track: "production",
      aab: "./app/build/outputs/bundle/release/app-release.aab"
    )
    
    slack(
      message: "🚀 Android 앱이 Google Play Store에 배포되었습니다!",
      channel: "#releases"
    )
  end
end

테스트도 되는 것 같고, 슬랙 알림도 되는 것 같음! 스크린샷을 자동으로 찍고, 올리는 것도 되는 것 같음. 굿..

버전 릴리즈

1.2.3

1 major - 이전 버전과 호환이 되지 않을 정도로 큰 업데이트 시
2 minor - 신규 기능의 추가나 삭제 시
3 patch - 사소한 변경이나 버그 수정 시

profile
나 원장이 아니다

0개의 댓글