Created
March 21, 2025 13:32
-
-
Save AndrewDongminYoo/6fdeb4fa006b17fbe3bb5fd651582628 to your computer and use it in GitHub Desktop.
android용 Fastfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| File: android/fastlane/Fastfile | |
| # This file contains the fastlane.tools configuration | |
| # You can find the documentation at https://docs.fastlane.tools | |
| # | |
| # For a list of all available actions, check out | |
| # | |
| # https://docs.fastlane.tools/actions | |
| # | |
| # For a list of all available plugins, check out | |
| # | |
| # https://docs.fastlane.tools/plugins/available-plugins | |
| # | |
| # Uncomment the line if you want fastlane to automatically update itself | |
| # update_fastlane | |
| default_platform(:android) | |
| platform :android do | |
| desc "Build and share release version of the app (separate for firebase and play store)" | |
| lane :release do |options| | |
| # Fastfile이 위치한 디렉토리 (android/fastlane) | |
| fastfile_dir = File.expand_path(File.dirname(__FILE__)) | |
| # 프로젝트 루트 디렉토리 (Fastfile 기준 2단계 상위) | |
| project_root = File.join(fastfile_dir, "..", "..") | |
| # 빌드 산출물이 생성되는 디렉토리 (프로젝트 루트 기준) | |
| build_dir = File.join(project_root, "build", "app", "outputs") | |
| # 현재 시간을 기반으로 빌드 넘버 생성 | |
| build_number = Time.now.strftime('%y%m%d%H') | |
| # 마지막 Git Tag 가져오기 (없으면 "origin/main"으로 대체) | |
| last_tag = last_git_tag | |
| last_tag = "origin/main" if last_tag.nil? || last_tag.to_s.empty? | |
| # 마지막 태그부터 HEAD까지의 커밋 메시지를 CHANGELOG 형식으로 생성 (짧은 포맷) | |
| changelog = changelog_from_git_commits( | |
| between: [last_tag, "HEAD"], | |
| pretty: "- %s" | |
| ) | |
| # changelog를 임시 파일에 저장 (Fastfile 기준 상대경로 사용) | |
| changelog_file = File.join(fastfile_dir, "temp", "CHANGELOG") | |
| require 'fileutils' | |
| FileUtils.mkdir_p(File.dirname(changelog_file)) | |
| File.write(changelog_file, changelog) | |
| ### Firebase App Distribution 용 빌드 (개발 서버 사용) | |
| sh "flutter build apk --flavor production --dart-define=APP_DISTRIBUTION=true --release --tree-shake-icons --build-number #{options[:build_number] || build_number}" | |
| created_release_app = File.join(build_dir, "flutter-apk", "app-production-release.apk") | |
| # Firebase 전용 파일로 복사 (예: app-firebase-release.apk) | |
| firebase_apk_copied = File.join(build_dir, "flutter-apk", "app-firebase-release.apk") | |
| if File.exist?(created_release_app) | |
| FileUtils.cp(created_release_app, firebase_apk_copied) | |
| else | |
| UI.user_error!("File not found: #{created_release_app}") | |
| end | |
| # https://github.com/firebase/fastlane-plugin-firebase_app_distribution | |
| firebase_app_distribution( | |
| app: "1:251440978508:android:ec712cfc633cf925b5f2e9", # Firebase Console 앱 ID | |
| groups: "내부", # Firebase Console의 테스트 그룹 | |
| release_notes_file: changelog_file, # 생성된 changelog 사용 | |
| android_artifact_path: firebase_apk_copied, | |
| android_artifact_type: "APK" | |
| ) | |
| ### Google Play용 프로덕션 빌드 (기본 서버 사용) | |
| sh "flutter build appbundle --flavor production --release --tree-shake-icons --build-number #{options[:build_number] || build_number}" | |
| production_aab = File.join(build_dir, "bundle", "productionRelease", "app-production-release.aab") | |
| upload_to_play_store( | |
| track: "internal", # 내부 앱 공유 트랙 | |
| aab: production_aab, | |
| release_status: "completed" | |
| ) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment