Skip to content

Commit

Permalink
ci-cd: Add ios CICD
Browse files Browse the repository at this point in the history
  • Loading branch information
roxk committed Sep 6, 2024
1 parent 0f68671 commit 8783bcc
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 5 deletions.
120 changes: 117 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ jobs:
- name: Distribute to App Center
env:
APPCENTER_ACCESS_TOKEN: ${{ secrets.ANDROID_APPCENTER_ACCESS_TOKEN }}
run: appcenter distribute release --debug --silent --file "./build/app/outputs/flutter-apk/app-release.apk" --group "Collaborators" --app "Oursky/Authgear-Migrate-Tool-Xamarin-To-Flutter-Sample" --release-notes "flutter"
run: appcenter distribute release --debug --silent --file "./build/app/outputs/flutter-apk/app-release.apk" --group "Collaborators" --app "Oursky/Authgear-Migrate-Tool-Xamarin-To-Flutter-Sample" --release-notes "flutter android"
xamarin-android:
runs-on: macos-12
needs: ["test-xamarin"]
needs: ["test-xamarin", "test-flutter"]
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -118,4 +118,118 @@ jobs:
- name: Distribute to App Center
env:
APPCENTER_ACCESS_TOKEN: ${{ secrets.ANDROID_APPCENTER_ACCESS_TOKEN }}
run: appcenter distribute release --debug --silent --file "$RUNNER_TEMP/app-signed.apk" --group "Collaborators" --app "Oursky/Authgear-Migrate-Tool-Xamarin-To-Flutter-Sample" --release-notes "xamarin"
run: appcenter distribute release --debug --silent --file "$RUNNER_TEMP/app-signed.apk" --group "Collaborators" --app "Oursky/Authgear-Migrate-Tool-Xamarin-To-Flutter-Sample" --release-notes "xamarin android"
flutter-ios:
runs-on: macos-13
needs: ["xamarin-ios"] # Depends on xamarin so that its version code is always bigger to allow updating
if: ${{ github.ref == 'refs/heads/main' }}
defaults:
run:
working-directory: "./example"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: "./.tool-versions"
- run: sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer
- run: npm install -g appcenter-cli
- uses: subosito/flutter-action@v2
with:
# This has to be kept in sync with .tool-versions
flutter-version: '3.24.2'
channel: 'stable'
# This action takes 1m30s to finish. Enable cache to make it shorter.
cache: true
- run: flutter pub get
- run: flutter test
- run: flutter analyze --no-fatal-infos
- run: dart format --set-exit-if-changed lib
- name: Prepare certificate and provisioning profile
env:
IOS_CERTIFICATE_BASE64: ${{ secrets.IOS_CERTIFICATE_BASE64 }}
IOS_PROVISIONING_PROFILE_BASE64: ${{ secrets.IOS_PROVISIONING_PROFILE_BASE64 }}
run: |
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$IOS_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$IOS_PROVISIONING_PROFILE_BASE64" | base64 --decode -o $PP_PATH
security create-keychain -p "" $KEYCHAIN_PATH
security set-keychain-settings $KEYCHAIN_PATH
security unlock-keychain -p "" $KEYCHAIN_PATH
security import $CERTIFICATE_PATH -P "" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Build .ipa
run: |
BUILD_NUMBER=$(date +%s)
flutter build ipa --export-options-plist ./exportOptions.plist --build-number $BUILD_NUMBER
- name: Distribute to App Center
env:
APPCENTER_ACCESS_TOKEN: ${{ secrets.IOS_APPCENTER_ACCESS_TOKEN }}
run: appcenter distribute release --debug --silent --file "./build/ios/ipa/Authgear Flutter.ipa" --store "App Store Connect Users" --app "Oursky/Authgear-Migrate-Tool-Xamarin-To-Flutter-Sample" --release-notes "flutter ios"
xamarin-ios:
runs-on: macos-12
needs: ["test-xamarin", "test-flutter"]
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- uses: actions/setup-dotnet@v3
with:
global-json-file: ./global.json
# `select-xamarin-sdk-v2.sh --mono` set /Library/Frameworks/Mono.framework/Versions/Current
# Tools like `msbuild`, `nuget` comes from /Library/Frameworks/Mono.framework/Versions/Current/Commands/
- run: npm install -g appcenter-cli
- name: Set Xamarin SDK versions
run: |
# https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
$VM_ASSETS/select-xamarin-sdk-v2.sh --mono=6.12 --ios=16.2 --android=13.2
- run: sudo xcode-select -s /Applications/Xcode_14.2.app/Contents/Developer
- name: nuget restore
run: |
nuget restore ./XamarinFormSample/XamarinFormSample/XamarinFormSample.csproj
nuget restore ./XamarinFormSample/XamarinFormSample.iOS/XamarinFormSample.iOS.csproj
- name: Install the Apple certificate and provisioning profile
env:
IOS_CERTIFICATE_BASE64: ${{ secrets.IOS_CERTIFICATE_BASE64 }}
IOS_PROVISIONING_PROFILE_BASE64: ${{ secrets.IOS_PROVISIONING_PROFILE_BASE64 }}
run: |
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$IOS_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$IOS_PROVISIONING_PROFILE_BASE64" | base64 --decode -o $PP_PATH
security create-keychain -p "" $KEYCHAIN_PATH
security set-keychain-settings $KEYCHAIN_PATH
security unlock-keychain -p "" $KEYCHAIN_PATH
security import $CERTIFICATE_PATH -P "" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Set CFBundleVersion
run: |
BUILD_NUMBER=$(date +%s)
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $BUILD_NUMBER" ./XamarinFormSample/XamarinFormSample.iOS/Info.plist
- name: msbuild
run: msbuild ./XamarinFormSample/XamarinFormSample.iOS/XamarinFormSample.iOS.csproj /p:Configuration=Release /p:Platform=iPhone /p:BuildIpa=true /t:Rebuild /p:IpaPackageDir="$RUNNER_TEMP"
- name: Distribute to App Center
env:
APPCENTER_ACCESS_TOKEN: ${{ secrets.IOS_APPCENTER_ACCESS_TOKEN }}
run: appcenter distribute release --debug --silent --file "$RUNNER_TEMP/XamarinFormSample.iOS.ipa" --store "App Store Connect Users" --app "Oursky/Authgear-Migrate-Tool-Xamarin-To-Flutter-Sample" --release-notes "no release notes"
- 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<MtouchArch>x86_64</MtouchArch>
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
<CodesignProvision>Authgear Demo Xamarin Dev</CodesignProvision>
<CodesignProvision>authgear-tool-migrate-xamarin-flutter DEV</CodesignProvision>
<CodesignKey>iPhone Developer</CodesignKey>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
Expand All @@ -39,7 +39,7 @@
<WarningLevel>4</WarningLevel>
<MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch>
<CodesignProvision>Authgear Demo Xamarin</CodesignProvision>
<CodesignProvision>authgear-tool-migrate-xamarin-flutter PROD</CodesignProvision>
<CodesignKey>Apple Distribution: Oursky Limited (M7HB6C3N6X)</CodesignKey>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
Expand Down

0 comments on commit 8783bcc

Please sign in to comment.