-
Notifications
You must be signed in to change notification settings - Fork 43
129 lines (118 loc) · 5.68 KB
/
build-ios.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Build iOS App Release
on:
workflow_dispatch:
push:
# branches:
# - 'release_v*' #${{ github.ref_name }}
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
build_with_signing:
runs-on: macos-latest-xlarge
steps:
# Checkout the repo
- name: Checkout repository
uses: actions/checkout@v4
# Install the Apple certificate and provisioning profile
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.APPLE_DISTRIBUTION_CERT }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.PROVISIONING_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
BUILD_CERT_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/FlutterAppStoreProfileWithPush.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $BUILD_CERT_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $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 $BUILD_CERT_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
# Create p8 Auth Key from secrets
- name: Create p8 Auth Key
env:
APP_STORE_CONNECT_KEY: ${{ secrets.APP_STORE_CONNECT_KEY }}
APP_STORE_KEY_ID: ${{ secrets.APP_STORE_KEY_ID }}
run: |
# Create private_keys folder
KEY_PATH=$GITHUB_WORKSPACE/example/build/ios/ipa/private_keys
mkdir -p $KEY_PATH
AUTH_KEY_PATH=$KEY_PATH/AuthKey_$APP_STORE_KEY_ID.p8
# import certificate and provisioning profile from secrets
echo -n "$APP_STORE_CONNECT_KEY" | base64 --decode -o $AUTH_KEY_PATH
# Install Flutter SDK
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.5'
# Get package dependencies and generate files
- name: Get package dependencies and generate files
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
# Get example app dependencies and generate files
- name: Get example app dependencies and generate files
working-directory: example
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
# Build ios example app
- name: Build ios example app
working-directory: example
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
APP_STORE_KEY_ID: ${{ secrets.APP_STORE_KEY_ID }}
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
APPKIT_AUTH: ${{ secrets.APPKIT_AUTH }}
APPKIT_PROJECT_ID: ${{ secrets.APPKIT_PROJECT_ID }}
AUTH_SERVICE_URL: ${{ secrets.AUTH_SERVICE_URL }}
run: |
# Get app version from file
FILE_VALUE=$(echo | grep "^version: " pubspec.yaml)
PARTS=(${FILE_VALUE//:/ })
FULL_VERSION=${PARTS[1]}
VERSION_NUMBER=(${FULL_VERSION//-/ })
# Build ios app with flutter
flutter build ios --build-name $VERSION_NUMBER --dart-define="PROJECT_ID=$PROJECT_ID" --dart-define="APPKIT_AUTH=$APPKIT_AUTH" --dart-define="APPKIT_PROJECT_ID=$APPKIT_PROJECT_ID" --dart-define="AUTH_SERVICE_URL=$AUTH_SERVICE_URL" --config-only --release
cd ios
agvtool new-marketing-version $VERSION_NUMBER
agvtool next-version -all
# Archive and export
xcodebuild -workspace "$GITHUB_WORKSPACE/example/ios/Runner.xcworkspace" -scheme Runner -sdk iphoneos -destination generic/platform=iOS -archivePath "$GITHUB_WORKSPACE/example/ios/Runner.xcarchive" archive
xcodebuild -exportArchive -allowProvisioningUpdates -sdk iphoneos -archivePath "$GITHUB_WORKSPACE/example/ios/Runner.xcarchive" -exportOptionsPlist "$GITHUB_WORKSPACE/example/ios/Runner/ExportOptionsRelease.plist" -exportPath "$GITHUB_WORKSPACE/example/build/ios/ipa" -authenticationKeyIssuerID $APPLE_ISSUER_ID -authenticationKeyID $APP_STORE_KEY_ID -authenticationKeyPath "$GITHUB_WORKSPACE/example/build/ios/ipa/private_keys/AuthKey_$APP_STORE_KEY_ID.p8"
# Upload IPA to Testflight
- name: Upload IPA to Testflight
working-directory: example/build/ios/ipa
env:
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
APP_STORE_KEY_ID: ${{ secrets.APP_STORE_KEY_ID }}
run: xcrun altool --upload-app --type ios -f web3modal_flutter.ipa --apiKey $APP_STORE_KEY_ID --apiIssuer $APPLE_ISSUER_ID
- name: Notify Channel
uses: slackapi/[email protected]
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: 'INCOMING_WEBHOOK'
with:
payload: |-
{
"text":"🍎 New *iOS* build *${{ github.ref_name }}* stable version for *Web3Modal Flutter* was just deployed."
}
# Clean up
- name: Clean up
if: ${{ always() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/FlutterAppStoreProfileWithPush.mobileprovision
flutter clean
cd example
flutter clean