Skip to content

Commit

Permalink
test: distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
Heonbyeong committed Aug 1, 2024
1 parent 714d844 commit 422a747
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 63 deletions.
158 changes: 101 additions & 57 deletions .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,106 @@ name: Android CI
on:
push:
branches:
- 'release/release'
- 'release/**'
- 'feature/**'

jobs:
build:

runs-on: macos-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Create API Certificate
run: |
echo "sdk.dir=$ANDROID_SDK_ROOT" > ./local.properties
echo "native_app_key=\"${{ secrets.NATIVE_APP_KEY }}\"" >> ./local.properties
echo "CLOVA_OCR_DOCUMENT_SECRET=\"${{ secrets.CLOVA_OCR_DOCUMENT_SECRET }}\"" >> ./local.properties
echo "CLOVA_OCR_DOCUMENT_BASEURL=\"${{ secrets.CLOVA_OCR_DOCUMENT_BASEURL }}\"" >> ./local.properties
- name: Clean Build
run: ./gradlew clean

- name: Decode Service Account Key
run: |
echo "${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_KEY }}" | base64 --decode > ./app/service_account_key.json
- name: Decode Keystore File
run: |
echo "${{ secrets.KEYSTORE_FILE }}" | base64 --decode > ./app/moneymong_keystore.jks
- name: Install Dependencies
run: |
gem install bundler
bundle install
- name: Build & Deploy Android release
env:
SERVICE_ACCOUNT_KEY: ${{ github.workspace }}/app/service_account_key.json
KEYSTORE_FILE: ${{ github.workspace }}/app/moneymong_keystore.jks
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEYSTORE_KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
CWD: ${{ github.workspace }}
run: bundle exec fastlane deploy

- name: Remove Credential
run: |
rm ./app/service_account_key.json
rm ./app/moneymong_keystore.jks
rm ./local.properties
release_deploy_job:
if: github.ref == 'refs/heads/release/release'
runs-on: macos-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Create API Certificate
run: |
echo "sdk.dir=$ANDROID_SDK_ROOT" > ./local.properties
echo "native_app_key=\"${{ secrets.NATIVE_APP_KEY }}\"" >> ./local.properties
echo "CLOVA_OCR_DOCUMENT_SECRET=\"${{ secrets.CLOVA_OCR_DOCUMENT_SECRET }}\"" >> ./local.properties
echo "CLOVA_OCR_DOCUMENT_BASEURL=\"${{ secrets.CLOVA_OCR_DOCUMENT_BASEURL }}\"" >> ./local.properties
- name: Clean Build
run: ./gradlew clean

- name: Decode Service Account Key
run: |
echo "${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_KEY }}" | base64 --decode > ./app/service_account_key.json
- name: Decode Keystore File
run: |
echo "${{ secrets.KEYSTORE_FILE }}" | base64 --decode > ./app/moneymong_keystore.jks
- name: Install Dependencies
run: |
gem install bundler
bundle install
- name: Build & Deploy Android release
env:
SERVICE_ACCOUNT_KEY: ${{ github.workspace }}/app/service_account_key.json
KEYSTORE_FILE: ${{ github.workspace }}/app/moneymong_keystore.jks
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEYSTORE_KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
CWD: ${{ github.workspace }}
run: bundle exec fastlane deploy

- name: Remove Credential
run: |
rm ./app/service_account_key.json
rm ./app/moneymong_keystore.jks
rm ./local.properties
dev_deploy_job:
if: startWith(github.ref, 'refs/heads/feature/moneymong-')
runs-on: macos-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Create API Certificate
run: |
echo "sdk.dir=$ANDROID_SDK_ROOT" > ./local.properties
echo "native_app_key=\"${{ secrets.NATIVE_APP_KEY }}\"" >> ./local.properties
echo "CLOVA_OCR_DOCUMENT_SECRET=\"${{ secrets.CLOVA_OCR_DOCUMENT_SECRET }}\"" >> ./local.properties
echo "CLOVA_OCR_DOCUMENT_BASEURL=\"${{ secrets.CLOVA_OCR_DOCUMENT_BASEURL }}\"" >> ./local.properties
- name: Clean Build
run: ./gradlew clean

- name: Decode Service Account Key
run: |
echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}" | base64 --decode > ./app/firebase_credentials.json
- name: Build & Deploy Distribute
env:
FIREBASE_CREDENTIALS: ${{ github.workspace }}/app/firebase_credentials.json
APP_ID: ${{ secrets.FIREBASE_TB_APP_ID }}
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
CWD: ${{ github.workspace }}
run: bundle exec fastlane distribute

- name: Remove Credential
run: rm ./local.properties
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-firebase_app_distribution (0.9.1)
google-apis-firebaseappdistribution_v1 (~> 0.3.0)
google-apis-firebaseappdistribution_v1alpha (~> 0.2.0)
fastlane-plugin-increment_version_code (0.4.3)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.54.0)
Expand All @@ -121,6 +124,10 @@ GEM
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
google-apis-firebaseappdistribution_v1 (0.3.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-firebaseappdistribution_v1alpha (0.2.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
Expand Down Expand Up @@ -216,6 +223,7 @@ PLATFORMS

DEPENDENCIES
fastlane
fastlane-plugin-firebase_app_distribution
fastlane-plugin-increment_version_code

BUNDLED WITH
Expand Down
47 changes: 42 additions & 5 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ default_platform(:android)
platform :android do
desc "Increment the Version Code"
lane :increment_code do
latest_release = google_play_track_version_codes()[0]
new_release = latest_release + 1
latest_release = firebase_app_distribution_get_latest_release(
app: "#{ENV["APP_ID"]}"
)

increment_version_code(
gradle_file_path: './app/build.gradle.kts',
version_code: new_release
version_code: latest_release[:buildVersion].to_i + 1
)

git_add(
path: ["./app/build.gradle.kts"]
)
git_commit(
path: ["./app/build.gradle.kts"],
message: "RELEASE INCREMENT VERSION CODE"
message: "INCREMENT VERSION CODE"
)

push_to_git_remote
Expand All @@ -51,9 +52,17 @@ platform :android do
# You can also use other beta testing services here
end

desc "Send Slack Message when Deploy to the Firebase Distribution"
lane :send_slack_message do |options|
slack(
message: options[:msg],
slack_url: options[:webhook_url]
)
end

desc "Deploy a new version to the Google Play"
lane :deploy do
increment_code
# increment_code

gradle(
task: 'bundle',
Expand All @@ -73,4 +82,32 @@ platform :android do
skip_upload_apk: true
)
end

desc "Deploy a new version to the Firebase Distribution"
lane :distribute do
# increment_code
latest_release = firebase_app_distribution_get_latest_release(
app: "#{ENV["APP_ID"]}"
)
release_note = "머니몽 Android TB [#{latest_release[:displayVersion]} (#{latest_release[:buildVersion]})]"

# gradle(
# task: 'clean assemble',
# flavor: "tb",
# build_type: 'Release'
# )
# firebase_app_distribution(
# service_credentials_file: "#{ENV["FIREBASE_CREDENTIALS"]}",
# app: "#{ENV["APP_ID"]}",
# groups: "fastlane/testers-groups.txt",
# release_notes: release_note
# )

send_slack_message(
msg: "#{release_note} 배포 완료",
webhook_url: "#{ENV["WEBHOOK_URL"]}"
)
end


end
1 change: 1 addition & 0 deletions fastlane/Pluginfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-increment_version_code'
gem 'fastlane-plugin-firebase_app_distribution'
16 changes: 16 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ Runs all the tests

Submit a new Beta Build to Crashlytics Beta

### android send_slack_message

```sh
[bundle exec] fastlane android send_slack_message
```

Send Slack Message when Deploy to the Firebase Distribution

### android deploy

```sh
Expand All @@ -47,6 +55,14 @@ Submit a new Beta Build to Crashlytics Beta

Deploy a new version to the Google Play

### android distribute

```sh
[bundle exec] fastlane android distribute
```

Deploy a new version to the Firebase Distribution

----

This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
Expand Down
9 changes: 8 additions & 1 deletion fastlane/report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@



<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000143">
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000145">

</testcase>


<testcase classname="fastlane.lanes" name="1: firebase_app_distribution_get_latest_release" time="1.554382">

<failure message="/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/actions/actions_helper.rb:67:in `execute_action&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/runner.rb:255:in `block in execute_action&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/runner.rb:229:in `chdir&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/runner.rb:229:in `execute_action&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing&apos;&#10;Fastfile:89:in `block (2 levels) in parsing_binding&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/lane.rb:41:in `call&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/runner.rb:49:in `block in execute&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/runner.rb:45:in `chdir&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/runner.rb:45:in `execute&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/lane_manager.rb:46:in `cruise_lane&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/command_line_handler.rb:34:in `handle&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/commands_generator.rb:110:in `block (2 levels) in run&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/commander-4.6.0/lib/commander/command.rb:187:in `call&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/commander-4.6.0/lib/commander/command.rb:157:in `run&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in `run!&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/commands_generator.rb:363:in `run&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/commands_generator.rb:43:in `start&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/fastlane/lib/fastlane/cli_tools_distributor.rb:123:in `take_off&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/fastlane-2.221.1/bin/fastlane:23:in `&lt;top (required)&gt;&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/bin/fastlane:25:in `load&apos;&#10;/Users/byeongheon/.rbenv/versions/3.3.0/bin/fastlane:25:in `&lt;main&gt;&apos;&#10;&#10;Invalid request" />

</testcase>

Expand Down
1 change: 1 addition & 0 deletions fastlane/tester-groups.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
테스터

0 comments on commit 422a747

Please sign in to comment.