body method
Defines the actual body code. path
is passed relative to lib
, baseName
is the filename, and className
is the filename converted to Pascal case.
実際の本体コードを定義します。path
にlib
からの相対パス、baseName
にファイル名が渡され、className
にファイル名をパスカルケースに変換した値が渡されます。
Implementation
@override
String body(String path, String baseName, String className) {
final workingPath = workingDirectory?.difference(Directory.current);
return """
# Build and upload your Flutter Android app.
#
# apk and aab files will be stored in Github storage. (Storage period is 1 day)
#
# The app is uploaded to GooglePlayConsole in an internal test draft.
#
# Please create a keystore for your app in advance with `katana app keystore`.
#
# Also, please create your app in Google PlayConsole, upload the aab file for the first time, and complete the app settings except for the store listing information settings.
#
# FlutterのAndroidアプリをビルドしアップロードします。
#
# apkファイルとaabファイルがGithubのストレージに保管されます。(保管期限1日)
#
# GooglePlayConsoleへアプリが内部テストのドラフトでアップロードされます。
#
# 事前に`katana app keystore`でアプリ用のキーストアを作成しておいてください。
#
# また、GooglePlayConsoleでアプリを作成し、aabファイルの初回アップロード、アプリの設定でストア掲載情報設定以外を済ませておいてください。
name: AndroidProductionWorkflow
on:
${buildOnClaudeCode ? """
# This workflow runs when there is a pull_request on the main, master, develop branch.
# main, master, develop branch に pull_request があったらこの workflow が走る。
pull_request:
branches:
- main
- master
- develop
types:
- opened
- reopened
- synchronize
""" : ""}
# This workflow runs when there is a push on the publish branch.
# publish branch に push があったらこの workflow が走る。
push:
branches:
- publish
jobs:
# ----------------------------------------------------------------- #
# Status check
# ----------------------------------------------------------------- #
status_check:
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
working-directory: ${workingPath.isEmpty ? "." : workingPath}
steps:
# Check-out.
# チェックアウト。
- name: Checks-out my repository
timeout-minutes: 10
uses: actions/checkout@v4
# Flutter status check.
# Flutterのステータスチェックを行います。
- name: Flutter status check
timeout-minutes: 30
uses: ./.github/actions/status_check
# ----------------------------------------------------------------- #
# Build for Android
# ----------------------------------------------------------------- #
build_android:
runs-on: ubuntu-latest
needs: status_check
timeout-minutes: 60
defaults:
run:
working-directory: ${workingPath.isEmpty ? "." : workingPath}
steps:
# Check-out.
# チェックアウト。
- name: Checks-out my repository
timeout-minutes: 10
uses: actions/checkout@v4
# Set up JDK 17.
# JDK 17のセットアップ
- name: Set up JDK 17
timeout-minutes: 10
uses: actions/setup-java@v4
with:
distribution: microsoft
java-version: "17.0.10"
# Install flutter.
# Flutterのインストール。
- name: Install flutter
timeout-minutes: 10
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
# Check flutter version.
# Flutterのバージョン確認。
- name: Run flutter version
run: flutter --version
timeout-minutes: 3
# Download package.
# パッケージのダウンロード。
- name: Download flutter packages
run: flutter pub get
timeout-minutes: 3
# Creation of the Assets folder.
# Assetsフォルダの作成。
- name: Create assets folder
run: mkdir -p assets
timeout-minutes: 3
# Generate appkey.keystore from Secrets.
# Secretsからappkey.keystoreを生成。
- name: Create appkey.keystore
run: echo -n \${{ secrets.ANDROID_KEYSTORE_#### REPLACE_APP_NAME #### }} | base64 -d > android/app/appkey.keystore
timeout-minutes: 3
# Generate service_account_key.json from Secrets.
# Secretsからservice_account_key.jsonを生成。
- name: Create service_account_key.json
run: echo -n \${{ secrets.ANDROID_SERVICE_ACCOUNT_KEY_JSON_#### REPLACE_APP_NAME #### }} | base64 -d > android/service_account_key.json
timeout-minutes: 3
# Generate key.properties from Secrets.
# Secretsからkey.propertiesを生成。
- name: Create key.properties
run: echo \${{ secrets.ANDROID_KEY_PROPERTIES_#### REPLACE_APP_NAME #### }} | base64 -d > android/key.properties
timeout-minutes: 3
# Generate app bundle.
# App Bundleを生成。
- name: Building Android AppBundle
run: flutter build appbundle --build-number \$((\$GITHUB_RUN_NUMBER+$defaultIncrementNumber)) --release --dart-define=FLAVOR=prod
timeout-minutes: 30
# Upload the generated files.
# 生成されたファイルのアップロード。
- name: Upload aab artifacts
timeout-minutes: 5
uses: actions/upload-artifact@v4
with:
name: andoroid_aab_release
path: ${workingPath.isEmpty ? "." : workingPath}/build/app/outputs/bundle/release
retention-days: 1
# Upload to Google Play Store.
# Google Play Storeにアップロード。
- name: Deploy to Google Play Store
timeout-minutes: 10
id: deploy
uses: r0adkll/upload-google-play@v1
with:
track: internal
# Change to completed after the app is released.
# アプリをリリースした後は completed に変更してください。
status: $status
serviceAccountJson: ${workingPath.isEmpty ? "." : workingPath}/android/service_account_key.json
${changesNotSentForReview != null ? "changesNotSentForReview: ${changesNotSentForReview! ? "true" : "false"}" : "# changesNotSentForReview: true"}
packageName: #### REPLACE_ANDROID_PACKAGE_NAME ####
releaseFiles: ${workingPath.isEmpty ? "." : workingPath}/build/app/outputs/bundle/release/*.aab
""";
}