개발/최적화

firebase app distribution + fastlane을 이용한 앱 배포 자동화(window)

이도일 2022. 8. 26. 16:11

안쓸라그랬는데말이지

 

아무리 구글링해도

윈도우 기반으로 FASTLANE 써먹는 자료가 부족해서 쓴다.

까먹기전에 기록한다.

 

CI / CD의 필요성은 알지만 난 지식이 부족해서....

일단 감이라도 잡기 위해 테스트 앱 배포 자동화를 WINDOW기반으로 해봤다.

 

귀찮으니까;;핵심만 쓴다.

 

 

 

 

 

1. 루비부터 설치한다.

 

Downloads

Which version to download? If you don’t know what version to install and you’re getting started with Ruby, we recommend that you use the Ruby+Devkit 3.1.X (x64) installer. It provides the biggest number of compatible gems and installs the MSYS2 Devkit

rubyinstaller.org

맥은 그냥 홈브루,,,쓰면 된다는데 윈도우는 그런거 없다.

알아서 다운받자ㅠ

 

 

그 다음은 cmd 열고 fastlane 공식 문서가 시키는대로 세팅한다.

 

fastlane docs

fastlane fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. 🚀 It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application. You can start by creati

docs.fastlane.tools


2. 번들러 깔아준다

gem install bundler

 

3. fastlane도 깔아준다

gem install fastlane

 

4. 안드로이드 스튜디오에서(프로젝트 루트 디렉토리에서) fastlane init 해준다

 fastlane init

(그전에 미리 file / settings / tools / terminal 에서 gitbash로 세팅한다. 맥과 비슷하게 환경 맞춰두기 위해서)

 

5. 패키지 이름 입력하라고 뜨면 입력해준다(Package Name (com.krausefx.app)

 

6. 구글 클라우드 콘솔 에서 서비스 계정을 만들고, 키 파일 생성해서 받는다. 순서는 아래와 같다.

 

Google 클라우드 플랫폼

로그인 Google 클라우드 플랫폼으로 이동

accounts.google.com

더보기
요기서 서비스 계정을 먼저 만들고

 

 

역할은 대충...서비스 계정 사용자로 쓰자.

 

그리고 서비스 계정의 키 관리에서 키를 추가해준다.

 

JSON으로 만들어준다

 

7. 그 다음, 다운된 키파일을 프로젝트 루트 디렉토리에 넣고, 경로를 안스 콘솔의 Path to the json secret file 에 입력해준다.

 

8. 그 다음, firebase 문서 를 따라서 프로젝트를 인증하고(아래와 같다), 프로젝트 루트의 fastlane / fastfile 을 작성해준다.

 

fastlane을 사용하여 테스터에 Android 앱 배포  |  Firebase

Google은 흑인 공동체를 위한 인종적 평등을 추구하기 위해 노력하고 있습니다. 자세히 알아보기 의견 보내기 fastlane을 사용하여 테스터에 Android 앱 배포 iOS 및 Android 앱의 빌드와 출시를 자동화하

firebase.google.com

더보기

1. 루트cmd에서 이거 써준다.

fastlane add_plugin firebase_app_distribution

 

2. firebase CLI 다운로드해서 로그인 해준다. 문서 참고

 

Firebase CLI 참조  |  Firebase 문서

FirebaseVisionOnDeviceAutoMLImageLabelerOptions

firebase.google.com

 

 

 

9. fastfile에 들어갈 내용은 위의 docs의 명령어들을 꼼꼼히 보고 작성하자. 루비 기반이다. 

# 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 "Lane for distribution"
    lane :distribute do // distribute 라는 lane을 만든다(실행할때 명령어로 써먹을거임)
        gradle(
          task: "assemble",
          build_type: "Release"
        )
        firebase_app_distribution(
            app: "파이어베이스 콘솔/일반 설정/프로젝트 설정의 앱 ID",
	    testers: "테스터 이메일(중복 가능)", //그룹 변수 넣으면 테스터 그룹 지정 가능
            firebase_cli_token: "fb cli 로그인 할때 받은 토큰 넣기",
            release_notes: "fast lane test"
        )
    end
end

 

 

 

 

 

 

 

이후부터는 터미널에 fastlane distribute 라고 치면

요렇게 fb콘솔에 자동으로 올라간다.

 

 

 

기타 옵션들 많으니까 공식 문서 찬찬히 보면서 적용하면 될 것 같다.