-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (225 loc) · 10 KB
/
ci.yaml
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: CI
on:
push:
branches:
- "*"
- "!gh-pages"
tags:
- "*"
pull_request:
branches:
- "*"
- "!gh-pages"
jobs:
test-xamarin:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
global-json-file: ./global.json
- working-directory: ./XamarinFormSample
run: dotnet format --verify-no-changes
test-flutter:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.10.0'
channel: 'stable'
- working-directory: flutter-example
run: |
flutter pub get
flutter test
flutter analyze --no-fatal-infos
dart format --set-exit-if-changed lib
flutter-android:
runs-on: macos-13
needs: ["xamarin-android"] # Depends on xamarin so that its version code is always bigger to allow updating
if: ${{ github.ref == 'refs/heads/main' }}
defaults:
run:
working-directory: "./flutter-example"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
# https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#java
- name: Set java version
run: |
echo "JAVA_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
- run: npm install -g appcenter-cli
- uses: subosito/flutter-action@v2
with:
# Do _NOT_ use the latest stable as those contain breaking changes
flutter-version: '3.10.0'
channel: 'stable'
- run: flutter pub get
- run: flutter test
- run: flutter analyze --no-fatal-infos
- run: dart format --set-exit-if-changed lib
- name: Build .apk
run: |
BUILD_NUMBER=$(date +%s)
flutter build apk --build-number $BUILD_NUMBER
- 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 android"
xamarin-android:
runs-on: macos-12
needs: ["test-xamarin", "test-flutter"]
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
global-json-file: ./global.json
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- 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
- name: nuget restore
run: |
nuget restore ./XamarinFormSample/XamarinFormSample/XamarinFormSample.csproj
nuget restore ./XamarinFormSample/XamarinFormSample.Android/XamarinFormSample.Android.csproj
- name: Set versionCode
run: |
VERSION_CODE=$(date +%s)
sed -I "" -E 's/android:versionCode="[[:digit:]]+"/android:versionCode="'"$VERSION_CODE"'"/' XamarinFormSample/XamarinFormSample.Android/Properties/AndroidManifest.xml
- name: msbuild
run: msbuild ./XamarinFormSample/XamarinFormSample.Android/XamarinFormSample.Android.csproj /p:Configuration=Release /t:PackageForAndroid
- name: Run zipalign
run: |
BUILD_TOOLS_VERSION="35.0.0"
ls "$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION"
"$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION/zipalign" -p -f -v 4 ./XamarinFormSample/XamarinFormSample.Android/bin/Release/com.authgear.sdk.migratepluginexampleapp.xamarinflutter.apk "$RUNNER_TEMP/app-aligned.apk"
- name: Run apksigner
env:
ANDROID_KEYSTORE_PASSWORD: Abcd1234!
ANDROID_KEY_ALIAS: main
ANDROID_KEY_PASSWORD: Abcd1234!
run: |
BUILD_TOOLS_VERSION="35.0.0"
"$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION/apksigner" sign \
--ks keystore-main.jks \
--ks-key-alias "$ANDROID_KEY_ALIAS" \
--ks-pass "pass:$ANDROID_KEYSTORE_PASSWORD" \
--key-pass "pass:$ANDROID_KEY_PASSWORD" \
--out "$RUNNER_TEMP/app-signed.apk" \
"$RUNNER_TEMP/app-aligned.apk"
- 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 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" --group "Collaborators" --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" --group "Collaborators" --app "Oursky/Authgear-Migrate-Tool-Xamarin-To-Flutter-Sample" --release-notes "xamarin ios"
- 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