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 a Flutter IOS app.
#
# Nothing is stored in Github storage.
#
# Create a `CertificateSigningRequest.certSigningRequest` with `katana app csr` in advance and download the Apple Development Certificate.
#
# Create an AuthKey in AppStoreConnect and put the Issuer ID and Team ID in katana.yaml.
#
# Also, please make sure you have created your app in AppStoreConnect.
#
# FlutterのIOSアプリをビルドしアップロードします。
#
# Githubのストレージにはなにも保管されません。
#
# AppStoreConnectへアプリがアップロードされます。
#
# 事前に`katana app csr`で`CertificateSigningRequest.certSigningRequest`を作成し、Apple DevelopmentのCertificateをダウンロードしてください。
#
# AppStoreConnectでAuthKeyを作成し、Issuer IDとチームIDをkatana.yamlに記載しておきます。
#
# また、AppStoreConnectでアプリを作成しておいてください。
name: IOSProductionWorkflow
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 IOS
# ----------------------------------------------------------------- #
build_ios:
runs-on: macos-latest
needs: status_check
timeout-minutes: 90
defaults:
run:
working-directory: ${workingPath.isEmpty ? "." : workingPath}
steps:
# Check-out.
# チェックアウト。
- name: Checks-out my repository
timeout-minutes: 10
uses: actions/checkout@v4
# 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
# Certificate settings.
# Certificateの設定。
- name: Import Apple Development Certificate
env:
IOS_KEYCHAIN_PASSWORD: \${{ secrets.IOS_KEYCHAIN_PASSWORD_#### REPLACE_APP_NAME #### }}
IOS_CERTIFICATES_P12: \${{ secrets.IOS_CERTIFICATES_P12_#### REPLACE_APP_NAME #### }}
IOS_CERTIFICATE_PASSWORD: \${{ secrets.IOS_CERTIFICATE_PASSWORD_#### REPLACE_APP_NAME #### }}
run: |
APPLE_DEVELOPMENT_CERTIFICATE=\$RUNNER_TEMP/development_certificate.p12
KEYCHAIN_PATH=\$RUNNER_TEMP/app-signing.keychain-db
# import certificate from secrets
echo -n "\$IOS_CERTIFICATES_P12" | base64 --decode --output \$APPLE_DEVELOPMENT_CERTIFICATE
# create temporary keychain
security create-keychain -p "\$IOS_KEYCHAIN_PASSWORD" \$KEYCHAIN_PATH
security set-keychain-settings -lut 21600 \$KEYCHAIN_PATH
security unlock-keychain -p "\$IOS_KEYCHAIN_PASSWORD" \$KEYCHAIN_PATH
# import certificate to keychain
security import \$APPLE_DEVELOPMENT_CERTIFICATE -P "\$IOS_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k \$KEYCHAIN_PATH
security list-keychain -d user -s \$KEYCHAIN_PATH
timeout-minutes: 3
# Create AppStoreConnectAPI key.
# AppStoreConnectAPIキーを作成。
- name: Create App Store Connect API Private Key in `pwd`/private_keys
env:
IOS_API_KEY_ID: \${{ secrets.IOS_API_KEY_ID_#### REPLACE_APP_NAME #### }}
IOS_API_AUTHKEY_P8: \${{ secrets.IOS_API_AUTHKEY_P8_#### REPLACE_APP_NAME #### }}
run: |
mkdir `pwd`/private_keys
echo -n "\$IOS_API_AUTHKEY_P8" | base64 --decode --output `pwd`/private_keys/AuthKey_\$IOS_API_KEY_ID.p8
timeout-minutes: 3
# Flutter build.
# Flutterのビルド。
- name: Run flutter build
id: build
run: flutter build ios --release --no-codesign --release --dart-define=FLAVOR=prod --build-number \$((\$GITHUB_RUN_NUMBER+$defaultIncrementNumber))
timeout-minutes: 60
# Archive of built data.
# ビルドされたデータのアーカイブ。
- name: Archive by xcodebuild
env:
IOS_API_ISSUER_ID: \${{ secrets.IOS_API_ISSUER_ID_#### REPLACE_APP_NAME #### }}
IOS_API_KEY_ID: \${{ secrets.IOS_API_KEY_ID_#### REPLACE_APP_NAME #### }}
run: xcodebuild archive -workspace ./ios/Runner.xcworkspace -scheme Runner -configuration Release -destination generic/platform=iOS -archivePath ./build/ios/Runner.xcarchive -allowProvisioningUpdates -authenticationKeyIssuerID \$IOS_API_ISSUER_ID -authenticationKeyID \$IOS_API_KEY_ID -authenticationKeyPath `pwd`/private_keys/AuthKey_\$IOS_API_KEY_ID.p8
timeout-minutes: 60
# Export of built archives.
# ビルドされたアーカイブのエクスポート。
- name: Export by xcodebuild
env:
IOS_API_ISSUER_ID: \${{ secrets.IOS_API_ISSUER_ID_#### REPLACE_APP_NAME #### }}
IOS_API_KEY_ID: \${{ secrets.IOS_API_KEY_ID_#### REPLACE_APP_NAME #### }}
run: xcodebuild -exportArchive -archivePath ./build/ios/Runner.xcarchive -exportPath ./build/ios/ipa -exportOptionsPlist ./ios/ExportOptions.plist -allowProvisioningUpdates -authenticationKeyIssuerID \$IOS_API_ISSUER_ID -authenticationKeyID \$IOS_API_KEY_ID -authenticationKeyPath `pwd`/private_keys/AuthKey_\$IOS_API_KEY_ID.p8
timeout-minutes: 60
# IPA file detection.
# IPAファイルの検出。
- name: Detect path for ipa file
run: |
echo "IPA_PATH=\$(find build/ios/ipa -type f -name '*.ipa')" >> \$GITHUB_ENV
timeout-minutes: 3
# Upload IPA files to AppStoreConnect.
# IPAファイルのAppStoreConnectへのアップロード。
- name: Upload to App Store Connect
env:
IOS_API_ISSUER_ID: \${{ secrets.IOS_API_ISSUER_ID_#### REPLACE_APP_NAME #### }}
IOS_API_KEY_ID: \${{ secrets.IOS_API_KEY_ID_#### REPLACE_APP_NAME #### }}
run: xcrun altool --upload-app --type ios -f \$IPA_PATH --apiKey \$IOS_API_KEY_ID --apiIssuer \$IOS_API_ISSUER_ID
timeout-minutes: 30
# Delete cache.
# キャッシュの削除。
- name: Clean up keychain and provisioning profile
run: security delete-keychain \$RUNNER_TEMP/app-signing.keychain-db
timeout-minutes: 3
""";
}