diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..99b7038 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,82 @@ +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: 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 + xamarin_android: + runs-on: macos-12 + needs: ["test-xamarin"] + 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 + - 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 + - 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="30.0.3" + "$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION/zipalign" -p -f -v 4 ./XamarinFormSample/XamarinFormSample.Android/bin/Release/com.authgear.migrate.tool.xamarin.flutter.sample.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="30.0.3" + "$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" diff --git a/global.json b/global.json new file mode 100644 index 0000000..5f04948 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "6.0.408", + "rollForward": "latestPatch" + } +}