From 15c95668bfeccef9d4e802595b4878ce2f325a73 Mon Sep 17 00:00:00 2001 From: kimmy214 Date: Sat, 15 Oct 2022 12:55:05 +0800 Subject: [PATCH] feat(ci): update github action --- .github/workflows/release.yml | 93 ++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2c4880..26294ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,14 @@ on: required: true default: "v2.10.0" type: string + environment: + type: choice + description: "Which environment are you using? (iOS only)" + required: true + default: "development" + options: + - development + - production prerelease: description: "Prerelease" required: false @@ -24,6 +32,7 @@ jobs: needs: - apk-build - aab-build + - ios-build - windows-build - linux-build - macos-build @@ -40,7 +49,7 @@ jobs: uses: ncipollo/release-action@v1 with: name: ${{ github.event.inputs.version }} - artifacts: "./**/*.apk,./**/*.aab,./**/*.tar.gz,./**/*.zip" + artifacts: "./**/*.apk,./**/*.aab,./**/*.ipa,./**/*.tar.gz,./**/*.zip" tag: ${{ github.event.inputs.version }} token: ${{ secrets.FLUTTER_BOILERPLATE_BOT_TOKEN }} prerelease: ${{ github.event.inputs.prerelease == 'true' }} @@ -157,6 +166,88 @@ jobs: name: aab-artifact path: ./*.aab + ios-build: + name: Create ios build + runs-on: macos-latest + 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 }} + BUILD_CERTIFICATE_DEV_BASE64: ${{ secrets.P12_DEV_BASE64 }} + BUILD_CERT_BASE64: ${{ secrets.CERT_BASE64 }} + BUILD_CERT_DEV_BASE64: ${{ secrets.CERT_DEV_BASE64 }} + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.PROVISIONING_PROFILE_BASE64 }} + BUILD_PROVISION_PROFILE_DEV_BASE64: ${{ secrets.PROVISIONING_PROFILE_DEV_BASE64 }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + run: | + # create variables + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + CERTIFICATE_DEV_PATH=$RUNNER_TEMP/build_certificate_dev.p12 + CERT_PATH=$RUNNER_TEMP/ios_distribution.cer + CERT_DEV_PATH=$RUNNER_TEMP/development.cer + PP_PATH=$RUNNER_TEMP/flutter-template-ns-appstore.mobileprovision + PP_DEV_PATH=$RUNNER_TEMP/flutter-template-ns-dev.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_CERTIFICATE_DEV_BASE64" | base64 --decode --output $CERTIFICATE_DEV_PATH + echo -n "$BUILD_CERT_BASE64" | base64 --decode --output $CERT_PATH + echo -n "$BUILD_CERT_DEV_BASE64" | base64 --decode --output $CERT_DEV_PATH + echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH + echo -n "$BUILD_PROVISION_PROFILE_DEV_BASE64" | base64 --decode --output $PP_DEV_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 import $CERTIFICATE_DEV_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH + security import $CERT_PATH -P "$P12_PASSWORD" -A -t cert -k $KEYCHAIN_PATH + security import $CERT_DEV_PATH -P "$P12_PASSWORD" -A -t cert -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 + cp $PP_DEV_PATH ~/Library/MobileDevice/Provisioning\ Profiles + + - name: Build + run: flutter build ipa --release --export-options-plist=ios/ExportOptions-${{ github.event.inputs.environment }}.plist + + # Package the build. + - name: Copy build for iOS + run: cp *.ipa $GITHUB_WORKSPACE/ + working-directory: build/ios/ipa + + - uses: actions/upload-artifact@v3 + with: + name: ios-artifact + path: ./*.ipa + + - name: Clean up keychain and provisioning profile + if: ${{ always() }} + run: | + security delete-keychain $RUNNER_TEMP/app-signing.keychain-db + rm ~/Library/MobileDevice/Provisioning\ Profiles/flutter-template-ns-appstore.mobileprovision + rm ~/Library/MobileDevice/Provisioning\ Profiles/flutter-template-ns-dev.mobileprovision + windows-build: name: Create windows build runs-on: windows-latest