Skip to content

Commit

Permalink
Merge branch 'main' into firebase_core_non_update
Browse files Browse the repository at this point in the history
  • Loading branch information
boywithdv authored May 10, 2024
2 parents 24c5572 + 58a0704 commit 91de7b0
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 848 deletions.
100 changes: 100 additions & 0 deletions .github/actions/deploy_ios_app/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Deploy iOS App
description: "Deploy iOS App"
inputs:
working-directory:
description: "working-directory. example: ./packages/flutter_app"
required: false
default: "./"
flavor:
description: "Flavor name"
required: true
asc-key-id:
description: "App Store Connect Key ID"
required: true
asc-issuer-id:
description: "App Store Connect Issuer ID"
required: true
asc-key-base64:
description: "App Store Connect Key Base64"
required: true
certificates-p12-base64:
description: "Certificates p12 file base64"
required: true
certificates-p12-password:
description: "Certificates p12 file password"
required: true
runs:
using: "composite"
steps:
# Import developer certificates.
# NOTE: If `--no-codesign` is specified in flutter build, to correctly include Entitlement.
# Signing must be done at archive time, which requires importing the developer certificate into the keychain.
# because certificates registered in Secrets are automatically renewed,
# `CERTIFICATES_P12` and `CERTIFICATES_P12_PASSWORD` in Secrets need to be updated annually.
# Expect improvements on the Flutter side.
- name: Import Code Signing Certificate
uses: apple-actions/import-codesign-certs@v2
with:
p12-file-base64: ${{ inputs.certificates-p12-base64 }}
p12-password: ${{ inputs.certificates-p12-password }}

- name: Decode App Store Connect API Key
run: |
mkdir ./private_keys
echo "${{ inputs.asc-key-base64 }}" | base64 --decode > ./private_keys/AuthKey_${{ inputs.asc-key-id }}.p8
echo "API_KEY_PATH=$(pwd)/private_keys/AuthKey_${{ inputs.asc-key-id }}.p8" >> $GITHUB_ENV
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Build iOS by Flutter
# Specify `--no-codesign` as signing at this stage will result in an error.
run: |
flutter build ios --release --dart-define-from-file=dart_defines/${{ inputs.flavor }}.json --no-codesign
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Create Xcode-Archive
run: |
xcodebuild archive \
-workspace ./ios/Runner.xcworkspace \
-scheme Runner \
-configuration Release \
-archivePath build/ios/Runner.xcarchive \
-allowProvisioningUpdates \
-authenticationKeyIssuerID ${{ inputs.asc-issuer-id }} \
-authenticationKeyID ${{ inputs.asc-key-id }} \
-authenticationKeyPath ${{ env.API_KEY_PATH }}
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Export IPA
run: |
xcodebuild -exportArchive \
-archivePath ./build/ios/Runner.xcarchive \
-exportPath ./build/ios/ipa \
-exportOptionsPlist ./ios/${{ inputs.flavor }}/ExportOptions.plist \
-allowProvisioningUpdates \
-authenticationKeyIssuerID ${{ inputs.asc-issuer-id }} \
-authenticationKeyID ${{ inputs.asc-key-id }} \
-authenticationKeyPath ${{ env.API_KEY_PATH }}
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Set IPA file path
run: |
echo "IPA_PATH=$(find build/ios/ipa -type f -name '*.ipa')" >> "$GITHUB_ENV"
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Upload IPA file to App Store Connect
run: |
xcrun altool --upload-app -t ios -f "${IPA_PATH}" --apiKey ${{ inputs.asc-key-id }} --apiIssuer ${{ inputs.asc-issuer-id }}
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Remove App Store Connect API Key
if: ${{ always() }}
run: >
rm ./private_keys/AuthKey_${{ inputs.asc-key-id }}.p8
shell: bash
working-directory: ${{ inputs.working-directory }}
60 changes: 0 additions & 60 deletions .github/actions/upload_ios_app/action.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/deploy-ios-production-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy iOS Production App

on:
pull_request:
types: [closed]
branches:
- main
workflow_dispatch:

jobs:
deploy:
# macos-latest Specify macos-13 because an error occurs during archiving if it is macos-latest.
runs-on: macos-13
timeout-minutes: 40
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && contains(github.head_ref, 'release/'))
env:
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
ASC_KEY_BASE64: ${{ secrets.ASC_KEY_BASE64 }}
CERTIFICATES_P12: ${{ secrets.CERTIFICATES_P12 }}
CERTIFICATES_P12_PASSWORD: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
steps:
- uses: actions/checkout@v4

- name: Setup Flutter
uses: ./.github/actions/setup_flutter

- name: Deploy iOS app
uses: ./.github/actions/deploy_ios_app
with:
working-directory: ./packages/flutter_app_template
flavor: prod
asc-key-id: ${{ env.ASC_KEY_ID }}
asc-issuer-id: ${{ env.ASC_ISSUER_ID }}
asc-key-base64: ${{ env.ASC_KEY_BASE64 }}
certificates-p12-base64: ${{ env.CERTIFICATES_P12 }}
certificates-p12-password: ${{ env.CERTIFICATES_P12_PASSWORD }}
37 changes: 37 additions & 0 deletions .github/workflows/deploy-ios-staging-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy iOS Staging app

on:
pull_request:
types: [closed]
branches:
- main
workflow_dispatch:

jobs:
deploy:
# macos-latest Specify macos-13 because an error occurs during archiving if it is macos-latest.
runs-on: macos-13
timeout-minutes: 40
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && contains(github.head_ref, 'release/'))
env:
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
ASC_KEY_BASE64: ${{ secrets.ASC_KEY_BASE64 }}
CERTIFICATES_P12: ${{ secrets.CERTIFICATES_P12 }}
CERTIFICATES_P12_PASSWORD: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
steps:
- uses: actions/checkout@v4

- name: Setup Flutter
uses: ./.github/actions/setup_flutter

- name: Deploy iOS app
uses: ./.github/actions/deploy_ios_app
with:
working-directory: ./packages/flutter_app_template
flavor: stg
asc-key-id: ${{ env.ASC_KEY_ID }}
asc-issuer-id: ${{ env.ASC_ISSUER_ID }}
asc-key-base64: ${{ env.ASC_KEY_BASE64 }}
certificates-p12-base64: ${{ env.CERTIFICATES_P12 }}
certificates-p12-password: ${{ env.CERTIFICATES_P12_PASSWORD }}
108 changes: 75 additions & 33 deletions packages/flutter_app/lib/features/user_device/model/user_device.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'user_device.freezed.dart';

/// ユーザーの使用している実行デバイスの情報。
///
/// ```dart
Expand All @@ -13,32 +8,79 @@ part 'user_device.freezed.dart';
///
/// if (device is AndroidDevice) {}
/// ```
@freezed
sealed class UserDevice with _$UserDevice {
const factory UserDevice.android({
required String name,
required String model,
required String osName,
required String osVersionString,
}) = AndroidDevice;

const factory UserDevice.ios({
required String name,
required String model,
required String osName,
required String osVersionString,
}) = IosDevice;

const factory UserDevice.macos({
/// Altive's MacBook Air
required String name,

/// example: Mac14,2
required String model,

/// example: Version 14.2.1 (Build 23C71)
required String osVersionString,
}) = MacosDevice;

const UserDevice._();
sealed class UserDevice {
const UserDevice();

String get name;
String get model;
String get osVersionString;
}

class AndroidDevice extends UserDevice {
const AndroidDevice({
required this.name,
required this.model,
required this.osName,
required this.osVersionString,
});

@override
final String name;
@override
final String model;
final String osName;
@override
final String osVersionString;
}

class IOSDevice extends UserDevice {
const IOSDevice({
required this.name,
required this.model,
required this.osName,
required this.osVersionString,
});

@override
final String name;
@override
final String model;
final String osName;
@override
final String osVersionString;
}

class MacosDevice extends UserDevice {
const MacosDevice({
required this.name,
required this.model,
required this.osVersionString,
});

/// Altive's MacBook Air
@override
final String name;

/// example: Mac14,2
@override
final String model;

/// example: Version 14.2.1 (Build 23C71)
@override
final String osVersionString;
}

class WebDevice extends UserDevice {
const WebDevice({
required this.name,
required this.model,
required this.osVersionString,
});

@override
final String name;
@override
final String model;
@override
final String osVersionString;
}
Loading

0 comments on commit 91de7b0

Please sign in to comment.