diff --git a/.github/workflows/release_to_dev.yaml b/.github/workflows/release_to_dev.yaml index fe36e6c0..8a6b2092 100644 --- a/.github/workflows/release_to_dev.yaml +++ b/.github/workflows/release_to_dev.yaml @@ -1,4 +1,4 @@ -name: Flutter CI/CD +name: Release to Dev on: push: @@ -10,7 +10,7 @@ jobs: runs-on: macOS-latest steps: - - name: Checkout Repository + - name: Checkout repository uses: actions/checkout@v2 - name: Read Flutter SDK version @@ -31,30 +31,100 @@ jobs: - name: flutter pub get (mottai_flutter_app) run: cd packages/mottai_flutter_app && flutter pub get - - name: Flutter Build IPA + - name: Create dev-dart-define.json from GitHub secret + run: | + cd packages/mottai_flutter_app + echo '${{ secrets.DEV_DART_DEFINE_JSON_STRING }}' > dev-dart-define.json + + - name: Prepare Xcode build settings + run: | + # dev-dart-define.json から各値を読み込む + cd packages/mottai_flutter_app + FLAVOR=$(jq -r '.flavor' dev-dart-define.json) + APP_NAME=$(jq -r '.appName' dev-dart-define.json) + APP_ID_SUFFIX=$(jq -r '.appIdSuffix' dev-dart-define.json) + + # DartDefines.xcconfig ファイルに書き込む + echo "flavor = dev" > DartDefines.xcconfig + echo "appName = mottai_dev" >> DartDefines.xcconfig + echo "appIdSuffix = .dev" >> DartDefines.xcconfig + + # このファイルを Xcode が参照できるように ios ディレクトリに移動する + mv DartDefines.xcconfig ios/ + + - name: Decode and install provisioning profile + run: | + echo ${{ secrets.DEV_APPLE_DISTRIBUTION_PROVISIONING_PROFILE_BASE64_STRING }} | base64 --decode > profile.mobileprovision + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + cp profile.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/ + + - name: Run import-codesign-certs + uses: Apple-Actions/import-codesign-certs@v2 + with: + p12-file-base64: ${{ secrets.DEV_APPLE_DISTRIBUTION_CERTIFICATE_P12_BASE64_STRING }} + p12-password: ${{ secrets.DEV_APPLE_DISTRIBUTION_CERTIFICATE_P12_PASSWORD }} + + - name: Prepare Xcode build settings for Distribution + run: | + # 適切なプロビジョニングプロファイルの名前を指定する + echo "PROVISIONING_PROFILE_SPECIFIER = Mottai Flutter App Dev" >> DartDefines.xcconfig + # 手動署名を選択する + echo "CODE_SIGN_STYLE = Manual" >> DartDefines.xcconfig + + - name: Create Environment.swift + run: | + echo "import Foundation" > packages/mottai_flutter_app/ios/Runner/Environment.swift + echo "struct Env {" >> packages/mottai_flutter_app/ios/Runner/Environment.swift + echo " static let googleMapApiKey = \"${{ secrets.DEV_GOOGLE_MAP_API_KEY }}\"" >> packages/mottai_flutter_app/ios/Runner/Environment.swift + echo "}" >> packages/mottai_flutter_app/ios/Runner/Environment.swift + + - name: flutter build ipa run: | cd packages/mottai_flutter_app flutter build ipa --release \ - --dart-define-from-file="dart_defines/dev-dart-define.json" \ + --dart-define-from-file="dev-dart-define.json" \ -t "lib/main.dart" \ --build-name=$(grep 'version:' pubspec.yaml | cut -d ' ' -f 2 | cut -d '+' -f 1) \ --build-number=$GITHUB_RUN_NUMBER \ --export-options-plist="ios/ExportOptions.plist" - - name: Validate IPA + - name: Detect ipa file path + run: | + cd packages/mottai_flutter_app + if [ ! -d "build/ios/ipa" ]; then + echo "build/ios/ipa directory does not exist." + exit 1 + fi + IPA_PATH=$(find build/ios/ipa -type f -name '*.ipa') + if [ -z "$IPA_PATH" ]; then + echo "No .ipa file found." + exit 1 + fi + echo "IPA_PATH=$IPA_PATH" >> $GITHUB_ENV + echo $IPA_PATH + + - name: Save AuthKey_${DEV_IOS_API_KEY}.p8 file + run: | + cd packages/mottai_flutter_app + mkdir private_keys + echo "${{ secrets.DEV_IOS_AUTH_KEY }}" > private_keys/AuthKey_${{ secrets.DEV_IOS_API_KEY }}.p8 + + - name: Validate ipa run: | + cd packages/mottai_flutter_app xcrun altool --validate-app \ - -f "./packages/mottai_flutter_app/build/ios/ipa/mottai_dev.ipa" \ + -f "./build/ios/ipa/mottai_dev.ipa" \ -t ios \ --apiKey ${{ secrets.DEV_IOS_API_KEY }} \ --apiIssuer ${{ secrets.DEV_IOS_API_ISSUER }} \ - --private-key ${{ secrets.DEV_IOS_AUTH_KEY }} + --private-key "./private_keys/AuthKey_${{ secrets.DEV_IOS_API_KEY }}.p8" - - name: Upload IPA to TestFlight + - name: Upload ipa to TestFlight run: | + cd packages/mottai_flutter_app xcrun altool --upload-app \ - -f "./packages/mottai_flutter_app/build/ios/ipa/mottai_dev.ipa" \ + -f "./build/ios/ipa/mottai_dev.ipa" \ -t ios \ --apiKey ${{ secrets.DEV_IOS_API_KEY }} \ --apiIssuer ${{ secrets.DEV_IOS_API_ISSUER }} \ - --private-key ${{ secrets.DEV_IOS_AUTH_KEY }} + --private-key "./private_keys/AuthKey_${{ secrets.DEV_IOS_API_KEY }}.p8" diff --git a/packages/mottai_flutter_app/ios/ExportOptions.plist b/packages/mottai_flutter_app/ios/ExportOptions.plist index 0e98380b..cd491a2a 100644 --- a/packages/mottai_flutter_app/ios/ExportOptions.plist +++ b/packages/mottai_flutter_app/ios/ExportOptions.plist @@ -6,8 +6,16 @@ export method app-store + provisioningProfiles + + + com.kosukesaigusa.mottaiFlutterApp.dev + Mottai Flutter App Dev + + signingCertificate + Apple Distribution signingStyle - automatic + manual stripSwiftSymbols teamID diff --git a/packages/mottai_flutter_app/ios/Flutter/Debug.xcconfig b/packages/mottai_flutter_app/ios/Flutter/Debug.xcconfig index ec97fc6f..c31d4dc9 100644 --- a/packages/mottai_flutter_app/ios/Flutter/Debug.xcconfig +++ b/packages/mottai_flutter_app/ios/Flutter/Debug.xcconfig @@ -1,2 +1,3 @@ #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" +#include "DartDefines.xcconfig" diff --git a/packages/mottai_flutter_app/ios/Flutter/Release.xcconfig b/packages/mottai_flutter_app/ios/Flutter/Release.xcconfig index c4855bfe..ab827f46 100644 --- a/packages/mottai_flutter_app/ios/Flutter/Release.xcconfig +++ b/packages/mottai_flutter_app/ios/Flutter/Release.xcconfig @@ -1,2 +1,3 @@ #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" +#include "DartDefines.xcconfig" diff --git a/packages/mottai_flutter_app/ios/Runner.xcodeproj/project.pbxproj b/packages/mottai_flutter_app/ios/Runner.xcodeproj/project.pbxproj index 9bb3c2b2..55ebd6da 100644 --- a/packages/mottai_flutter_app/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/mottai_flutter_app/ios/Runner.xcodeproj/project.pbxproj @@ -406,6 +406,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-$(flavor)"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = M92JZ2K56V; ENABLE_BITCODE = NO; @@ -416,6 +418,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "com.kosukesaigusa.mottaiFlutterApp$(appIdSuffix)"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -536,6 +539,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-$(flavor)"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = M92JZ2K56V; ENABLE_BITCODE = NO; @@ -546,6 +551,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "com.kosukesaigusa.mottaiFlutterApp$(appIdSuffix)"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -560,8 +566,12 @@ ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-$(flavor)"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = M92JZ2K56V; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = M92JZ2K56V; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -570,6 +580,8 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "com.kosukesaigusa.mottaiFlutterApp$(appIdSuffix)"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Mottai Flutter App Dev"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; diff --git a/packages/mottai_flutter_app/ios/Runner/Info.plist b/packages/mottai_flutter_app/ios/Runner/Info.plist index 598a646a..38c71ae0 100644 --- a/packages/mottai_flutter_app/ios/Runner/Info.plist +++ b/packages/mottai_flutter_app/ios/Runner/Info.plist @@ -36,6 +36,8 @@ CFBundleVersion $(FLUTTER_BUILD_NUMBER) + ITSAppUsesNonExemptEncryption + LSApplicationQueriesSchemes https @@ -45,13 +47,11 @@ LSRequiresIPhoneOS NSCameraUsageDescription - プロフィール画像などを撮影するために端末のカメラを使用します。 + プロフィール画像や投稿する写真などを撮影するために端末のカメラを使用します。 + NSPhotoLibraryUsageDescription + プロフィール画像や投稿する写真などを選択するために端末の画像ライブラリを使用します。 NSLocationWhenInUseUsageDescription 現在地を取得するため位置情報サービスを使用します。 - NSMicrophoneUsageDescription - This app requires to add file to your photo library your microphone - NSPhotoLibraryUsageDescription - プロフィール画像などを選択するために端末の画像ライブラリを使用します。 UIApplicationSupportsIndirectInputEvents UIBackgroundModes