Skip to content

Commit

Permalink
feat(ci): update github action
Browse files Browse the repository at this point in the history
  • Loading branch information
kimmy214 committed Oct 15, 2022
1 parent d4eef91 commit 15c9566
Showing 1 changed file with 92 additions and 1 deletion.
93 changes: 92 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,6 +32,7 @@ jobs:
needs:
- apk-build
- aab-build
- ios-build
- windows-build
- linux-build
- macos-build
Expand All @@ -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' }}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 15c9566

Please sign in to comment.