Created
May 26, 2023 03:22
-
-
Save DargonLee/5f83ca61374b4eb7dd2ac1ea134eb8ee to your computer and use it in GitHub Desktop.
This file contains hidden or 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: Flutter_iOS | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
jobs: | |
build_ios: | |
runs-on: macos-latest | |
env: | |
SHEME: Runner | |
BUILD_CONFIGURATION: Release | |
TEAM_ID: 64H5U3LG67 | |
PROVISIONING_PROFILE: 471e1388-37bb-4b51-a69c-e555ec425b51 | |
CODE_SIGN_IDENTITY: "Apple Distribution: JiHua Lai (64H5U3LG67)" | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v2 | |
- 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: Install and set Flutter version | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '2.10.3' | |
- name: Restore packages | |
run: flutter pub get | |
- name: pod repo update | |
run: pod repo update | |
- name: Build Flutter | |
run: flutter build ios --release --no-codesign | |
- 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=${{ env.TEAM_ID }} -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE=${{ env.PROVISIONING_PROFILE }} clean archive CODE_SIGN_IDENTITY="${{ env.CODE_SIGN_IDENTITY }}" | |
- name: Export ipa | |
run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/ExportOptions.plist | |
- name: Upload PGYER File | |
id: pgyer | |
uses: xtayga/upload-pgyer-action@master | |
with: | |
url: https://www.pgyer.com/apiv2/app/upload | |
forms: '{"_api_key":"${{ secrets.PGY_KEY }}","buildName":"RSS"}' | |
fileForms: '{"file":"build-output/ios/flutter_best_practice.ipa"}' # ipa 的名字为 info.plist 中的 CFBundleName | |
- name: Publish iOS Artefacts | |
uses: actions/upload-artifact@v1 | |
with: | |
name: release-ios | |
path: build-output/ios |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment