Skip to content

Commit

Permalink
ci-cd: Setup CI/CD ref dev-1955
Browse files Browse the repository at this point in the history
  • Loading branch information
roxk committed Sep 4, 2024
1 parent 88c15be commit 6e67475
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 14 deletions.
121 changes: 121 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
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 "no release notes"
xamarin-android:
runs-on: macos-12
needs: ["test-xamarin"]
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 "no release notes"
2 changes: 1 addition & 1 deletion XamarinFormSample/Sample.Shared/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MainViewModel : INotifyPropertyChanged
public delegate void ErrorRaisedHandler(object sender, Exception e);
private AuthgearSdk authgear;
private readonly IAuthgearFactory authgearFactory;
public readonly string RedirectUri = "com.authgear.migrate.tool.xamarin.flutter.sample://host/path";
public readonly string RedirectUri = "com.authgear.sdk.migratepluginexampleapp.xamarinflutter://host/path";
public string ClientId { get; set; } =
Preferences.Get("authgear.clientID", Config.AuthgearClientId);
public string AuthgearEndpoint { get; set; } =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.authgear.migrate.tool.xamarin.flutter.sample" android:installLocation="auto">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.authgear.sdk.migratepluginexampleapp.xamarinflutter" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
<application android:label="Authgear Migrate Tool XamarinToFlutter Xamarin" android:theme="@style/MainTheme" android:usesCleartextTraffic="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace XamarinFormSample.Droid
[Activity(NoHistory = true, LaunchMode = LaunchMode.SingleTop, Exported = true)]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable },
DataScheme = "com.authgear.migrate.tool.xamarin.flutter.sample")]
DataScheme = "com.authgear.sdk.migratepluginexampleapp.xamarinflutter")]
public class WebAuthenticationCallbackActivity : Xamarin.Essentials.WebAuthenticatorCallbackActivity
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SelectedDevice>Google Pixel 7a</SelectedDevice>
<SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup>
<ActiveDebugProfile>Google Pixel 7a %28Android 14.0 - API 34%29</ActiveDebugProfile>
<SelectedDevice>Windows Subsystem for Android</SelectedDevice>
<SelectedPlatformGroup>Emulator</SelectedPlatformGroup>
<ActiveDebugProfile>Windows Subsystem for Android %28Android 13.0 - API 33%29</ActiveDebugProfile>
<DefaultDevice>Windows Subsystem for Android</DefaultDevice>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion XamarinFormSample/XamarinFormSample.iOS/Entitlements.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>keychain-access-groups</key>
<array>
<string>com.authgear.migrate.tool.xamarin.flutter.sample</string>
<string>com.authgear.sdk.migratepluginexampleapp.xamarinflutter</string>
</array>
</dict>
</plist>
4 changes: 2 additions & 2 deletions XamarinFormSample/XamarinFormSample.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.authgear.migrate.tool.xamarin.flutter.sample://host/path</string>
<string>com.authgear.sdk.migratepluginexampleapp.xamarinflutter://host/path</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.authgear.migrate.tool.xamarin.flutter.sample</string>
<string>com.authgear.sdk.migratepluginexampleapp.xamarinflutter</string>
</array>
</dict>
</array>
Expand Down
2 changes: 1 addition & 1 deletion flutter-example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.authgear.migrate.tool.xamarin.flutter.sample"
applicationId "com.authgear.sdk.migratepluginexampleapp.xamarinflutter"
// minSdkVersion flutter.minSdkVersion
// 21 is required to use androidx.security
minSdkVersion 21
Expand Down
14 changes: 10 additions & 4 deletions flutter-example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import 'dart:async' show StreamSubscription;
import 'dart:io';
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart' hide ColorScheme;
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart'
show SharedPreferences;
import 'package:flutter_authgear/flutter_authgear.dart';

const authgearEndpoint = "https://migrate-tool-xamarin-flutter.authgear-staging.com";
const authgearEndpoint =
"https://migrate-tool-xamarin-flutter.authgear-staging.com";
const authgearClientID = "9f01ea8c46d4bc22";
const redirectURI = "com.authgear.exampleapp.flutter://host/path";
var wechatRedirectURI = "";
Expand Down Expand Up @@ -288,8 +290,10 @@ class _MyAppState extends State<MyApp> {

void init() async {
_sharedPreferences = await SharedPreferences.getInstance();
final endpoint = _sharedPreferences.getString("authgear.endpoint") ?? authgearEndpoint;
final clientID = _sharedPreferences.getString("authgear.clientID") ?? authgearClientID;
final endpoint =
_sharedPreferences.getString("authgear.endpoint") ?? authgearEndpoint;
final clientID =
_sharedPreferences.getString("authgear.clientID") ?? authgearClientID;
_endpointController.text = endpoint;
_clientIDController.text = clientID;
}
Expand Down Expand Up @@ -1089,7 +1093,9 @@ class _MyAppState extends State<MyApp> {
});
await _authgear.wechatAuthCallback(state: state, code: code);
} on PlatformException catch (e) {
print("exception: $e");
if (kDebugMode) {
print("exception: $e");
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "6.0.408",
"rollForward": "latestPatch"
}
}

0 comments on commit 6e67475

Please sign in to comment.