Merge branch 'develop' into fix/android-build #82
Workflow file for this run
This file contains 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
name: Deploy | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: false | |
on: | |
push: | |
branches: | |
- '**' | |
workflow_dispatch: | |
inputs: | |
ios: | |
description: "Build iOS app" | |
required: false | |
default: true | |
type: boolean | |
android: | |
description: "Build Android app" | |
required: false | |
default: true | |
type: boolean | |
jobs: | |
define-matrix: | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 1 | |
outputs: | |
deploy-ios: ${{ steps.define-environment-matrix.outputs.deploy-ios }} | |
deploy-android: ${{ steps.define-environment-matrix.outputs.deploy-android }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Decide which app to deploy | |
id: define-environment-matrix | |
run: | | |
platforms=() | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
if [ "${{ inputs.ios }}" = "true" ]; then | |
platforms+=("ios") | |
fi | |
if [ "${{ inputs.android }}" = "true" ]; then | |
platforms+=("android") | |
fi | |
elif [ "${{ github.event_name }}" = "push" ]; then | |
# コミットメッセージに [release only $platform] を含む場合は、 | |
# そのプラットフォームのみデプロイする | |
if [[ github.event.head_commit.message =~ \[release[[:space:]]+only[[:space:]]+([a-z,[:space:]]+)\] ]]; then | |
# [release only platform1,platform2] の形式からプラットフォームを抽出 | |
IFS=',' read -ra selected_platforms <<< "${BASH_REMATCH[1]}" | |
# 空白を削除して配列に追加 | |
for platform in "${selected_platforms[@]}"; do | |
platform=$(echo "$platform" | tr -d '[:space:]') | |
if [[ " ios android" =~ " $platform " ]]; then | |
platforms+=("$platform") | |
fi | |
echo "platform: $platform" | |
done | |
else | |
# [release only] タグがない場合は全プラットフォームをデプロイ | |
echo "commit message does not contain [release only platform], deploy all platforms" | |
platforms+=("ios" "android") | |
fi | |
else | |
echo "Unknown event name: ${{ github.event_name }}" | |
exit 1 | |
fi | |
echo "デプロイするプラットフォーム: ${platforms[@]}" | |
for platform in "${platforms[@]}"; do | |
echo "deploy-${platform}=true" >> $GITHUB_OUTPUT | |
done | |
build-ios: | |
needs: define-matrix | |
if: ${{ needs.define-matrix.outputs.deploy-ios }} | |
runs-on: macos-latest | |
timeout-minutes: 30 | |
steps: | |
# https://github.com/actions/checkout | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Setup application runtime & Resolve dependencies | |
uses: ./.github/actions/setup-application-runtime | |
- name: Setup macOS Environment | |
uses: ./.github/actions/setup-macos-environment | |
- name: Extract Dotenv | |
run: | | |
echo "${{ secrets.DOTENV }}" | base64 -d > environment.tar.gz | |
tar -xzf environment.tar.gz | |
rm environment.tar.gz | |
ls -l environment/ | |
- name: Build iOS | |
working-directory: app | |
run: | | |
flutter build ipa \ | |
--no-codesign \ | |
--dart-define-from-file=../environment/.env.prod | |
- name: Extract App Store Connect API Key | |
working-directory: app/ios | |
run: | | |
echo "${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}" | base64 -d \ | |
> AuthKey_${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}.p8 | |
ls -l AuthKey_${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}.p8 | |
- name: Archive | |
working-directory: app | |
run: | | |
xcodebuild -workspace ios/Runner.xcworkspace \ | |
-scheme Runner \ | |
-sdk iphoneos \ | |
-configuration Release archive \ | |
-archivePath build/ios/Runner.xcarchive \ | |
CODE_SIGNING_REQUIRED=NO \ | |
CODE_SIGNING_ALLOWED=NO | xcbeautify | |
xcodebuild -exportArchive \ | |
-archivePath build/ios/Runner.xcarchive \ | |
-exportOptionsPlist ios/ExportOptions.plist \ | |
-exportPath . \ | |
-allowProvisioningUpdates \ | |
-authenticationKeyIssuerID ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }} \ | |
-authenticationKeyID ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }} \ | |
-authenticationKeyPath ${{ github.workspace }}/app/ios/AuthKey_${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}.p8 \ | |
| xcbeautify | |
- name: List files | |
run: | | |
ls -lah app/ | |
echo "---" | |
ls -lah app/build/ | |
- name: Upload ipa as artifact | |
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 | |
with: | |
name: EQMonitor-ios.ipa | |
path: app/eqmonitor.ipa | |
if-no-files-found: error | |
deploy-ios: | |
needs: build-ios | |
runs-on: macos-latest | |
timeout-minutes: 10 | |
steps: | |
# https://github.com/actions/checkout | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
# https://github.com/actions/download-artifact | |
- name: Download ipa | |
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 | |
with: | |
name: EQMonitor-ios.ipa | |
path: build | |
- name: List files | |
run: ls -lah build/ | |
- name: Setup macOS Environment | |
uses: ./.github/actions/setup-macos-environment | |
- name: Extract App Store Connect API Key | |
run: | | |
mkdir ~/.private_keys | |
echo "${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}" | base64 -d \ | |
> ~/.private_keys/AuthKey_${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}.p8 | |
ls -l ~/.private_keys/AuthKey_${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}.p8 | |
- name: Upload Ipa to App Store Connect | |
run: | | |
xcrun altool \ | |
--upload-app \ | |
-f build/eqmonitor.ipa \ | |
--type ios \ | |
--apiIssuer ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }} \ | |
--apiKey ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }} | |
build-android: | |
needs: define-matrix | |
if: ${{ needs.define-matrix.outputs.deploy-android }} | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Setup application runtime & Resolve dependencies | |
uses: ./.github/actions/setup-application-runtime | |
# Java 17を明示的に設定 | |
- name: Setup Java | |
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Accept Android License | |
run: yes | flutter doctor --android-licenses || true | |
- name: Extract keystore | |
run: | | |
echo '${{ secrets.SIGNING_KEY }}' | base64 -d > app/android/app/key.jks | |
echo '${{ secrets.FIREBASE_ANDROID }}' | base64 -d > app/android/app/google-services.json | |
echo '${{ secrets.KEY_PROPERTIES }}' | base64 -d > app/android/key.properties | |
- name: Extract Dotenv | |
run: | | |
echo "${{ secrets.DOTENV }}" | base64 -d > environment.tar.gz | |
tar -xzf environment.tar.gz | |
rm environment.tar.gz | |
ls -l environment/ | |
- name: Install Codemagic CLI Tools | |
run: | | |
pip3 install codemagic-cli-tools | |
- name: Fetch latest build number from Google Play Store | |
id: fetch-latest-build-number | |
run: | | |
echo "${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}" > service-account.json | |
LATEST_BUILD_NUMBER=$(google-play get-latest-build-number \ | |
--credentials="@file:service-account.json" \ | |
--package-name="net.yumnumm.eqmonitor" || echo "0") | |
BUILD_NUMBER=$((LATEST_BUILD_NUMBER + 1)) | |
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_OUTPUT | |
echo "Build Number set to ${BUILD_NUMBER}." | |
rm service-account.json | |
# Flutterのキャッシュをクリア | |
- name: Clean Flutter cache | |
run: | | |
flutter clean | |
flutter pub get | |
- name: Build Android (AAB) | |
working-directory: app | |
env: | |
BUILD_NUMBER: ${{ steps.fetch-latest-build-number.outputs.BUILD_NUMBER }} | |
run: | | |
flutter build appbundle \ | |
--release \ | |
--build-number=${BUILD_NUMBER} \ | |
--dart-define-from-file=../environment/.env.prod | |
- name: Build Android (APK) | |
working-directory: app | |
env: | |
BUILD_NUMBER: ${{ steps.fetch-latest-build-number.outputs.BUILD_NUMBER }} | |
run: | | |
flutter build apk \ | |
--release \ | |
--build-number=${BUILD_NUMBER} \ | |
--dart-define-from-file=../environment/.env.prod | |
- name: Upload aab as artifact | |
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 | |
with: | |
name: EQMonitor-android.aab | |
path: app/build/app/outputs/bundle/release/app-release.aab | |
if-no-files-found: error | |
- name: Upload apk as artifact | |
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 | |
with: | |
name: EQMonitor-android.apk | |
path: app/build/app/outputs/flutter-apk/app-release.apk | |
if-no-files-found: error | |
deploy-android: | |
needs: build-android | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 10 | |
steps: | |
- name: Download artifact aab | |
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 | |
with: | |
name: EQMonitor-android.aab | |
path: build | |
- name: Upload to Google Play | |
uses: r0adkll/upload-google-play@935ef9c68bb393a8e6116b1575626a7f5be3a7fb #v1.1.3 | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }} | |
packageName: net.yumnumm.eqmonitor | |
releaseFiles: build/app-release.aab | |
track: internal | |
status: completed | |
# 既存ユーザーへのアップデートを許可 | |
changesNotSentForReview: false |