Skip to content

Commit

Permalink
feat: update github action
Browse files Browse the repository at this point in the history
  • Loading branch information
kimmy214 committed Oct 14, 2022
1 parent 550906d commit 2c70dbb
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 2 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Release Flutter (iOS)
on:
# Enable manual run
workflow_dispatch:
inputs:
version:
description: "Tag to create (e.g. v2.10.0). Must include 'v' and must match pubspec"
required: true
default: "v2.10.0"
type: string
prerelease:
description: "Prerelease"
required: false
default: false
type: boolean

# Declare default permissions as read only.
permissions: read-all

jobs:
macos-build:
name: Create ios build
runs-on: macos-latest
env:
SHEME: Runner
BUILD_CONFIGURATION: Release
steps:
- uses: actions/checkout@v3

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'

- name: Flutter doctor -v
run: flutter doctor -v

- name: Install Deps
run: flutter pub get

- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.P12_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.PROVISIONING_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Build
run: flutter build ios --release --no-codesign --no-tree-shake-icons

- name: Build resolve Swift dependencies
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme ${{ env.SHEME }} -configuration ${{ env.BUILD_CONFIGURATION }}

- name: Build xArchive
run: |
xcodebuild -workspace ios/Runner.xcworkspace -scheme ${{ env.SHEME }} -configuration ${{ env.BUILD_CONFIGURATION }} DEVELOPMENT_TEAM=${{ secrets.TEAM_ID }} -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE=${{ secrets.PROVISIONING_PROFILE }} clean archive CODE_SIGN_IDENTITY="${{ secrets.CODE_SIGN_IDENTITY }}"
- name: Export ipa
run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/ExportOptions.plist

- uses: actions/upload-artifact@v3
with:
name: ios-artifact
path: build-output/ios

- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '12.x'
java-version: "17.x"
distribution: 'temurin'

- name: Setup Flutter
uses: subosito/flutter-action@v2
Expand Down Expand Up @@ -107,7 +108,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '12.x'
java-version: "17.x"
distribution: 'temurin'

- name: Setup Flutter
uses: subosito/flutter-action@v2
Expand Down
4 changes: 4 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end

0 comments on commit 2c70dbb

Please sign in to comment.