[WIP] Upgrade ktx MWA to facilitate auth/reauth automatically #634
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android CI | |
on: | |
push: | |
branches: [ main ] | |
paths: [ '.github/**', 'android/**' ] | |
pull_request: | |
branches: [ main ] | |
paths: [ '.github/**', 'android/**' ] | |
release: | |
types: [ published ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: android | |
steps: | |
# Setup | |
- uses: actions/checkout@v3 | |
- name: set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Deploy APK signing keystore and related secrets (test signing) | |
if: ${{ github.event_name != 'pull_request' }} | |
env: | |
KEYSTORE_BASE64: ${{ secrets.APK_SIGNING_TEST_KEYSTORE }} | |
KEYSTORE_PATH: ${{ runner.temp }}/apk_signing_keystore.jks | |
run: echo $KEYSTORE_BASE64 | base64 --decode > $KEYSTORE_PATH | |
# Build | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle and run tests | |
env: | |
ORG_GRADLE_PROJECT_apkSigningKeystorePath: ${{ runner.temp }}/apk_signing_keystore.jks | |
ORG_GRADLE_PROJECT_apkSigningKeyAlias: signing | |
ORG_GRADLE_PROJECT_apkSigningKeystorePassword: ${{ secrets.APK_SIGNING_TEST_PASSWORD }} | |
ORG_GRADLE_PROJECT_apkSigningKeyPassword: ${{ secrets.APK_SIGNING_TEST_PASSWORD }} | |
run: ./gradlew build | |
# Upload binaries to workflow artifacts | |
- uses: actions/upload-artifact@v3 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
name: binaries | |
path: | | |
android/clientlib/build/outputs/aar/*.aar | |
android/clientlib-ktx/build/outputs/aar/*.aar | |
android/common/build/outputs/aar/*.aar | |
android/fakedapp/build/outputs/apk/**/*.apk | |
android/fakewallet/build/outputs/apk/**/*.apk | |
android/walletlib/build/outputs/aar/*.aar | |
if-no-files-found: error | |
retention-days: 5 | |
# Upload javadoc to workflow artifacts | |
- uses: actions/upload-artifact@v3 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
name: clientlib-javadoc | |
path: | | |
android/clientlib/build/docs/* | |
!android/clientlib/build/docs/**/*.zip | |
if-no-files-found: error | |
retention-days: 1 | |
- uses: actions/upload-artifact@v3 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
name: common-javadoc | |
path: | | |
android/common/build/docs/* | |
!android/common/build/docs/**/*.zip | |
if-no-files-found: error | |
retention-days: 1 | |
- uses: actions/upload-artifact@v3 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
name: walletlib-javadoc | |
path: | | |
android/walletlib/build/docs/* | |
!android/walletlib/build/docs/**/*.zip | |
if-no-files-found: error | |
retention-days: 1 | |
# Publish to Maven Central (only for releases that start with 'v') | |
- name: Publish to Maven Central (release only) | |
if: ${{ github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v') }} | |
env: | |
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PRIVATE_KEY }} | |
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PRIVATE_KEY_PASSWORD }} | |
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_USERNAME }} | |
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PASSWORD }} | |
TAG: ${{ github.event.release.tag_name }} | |
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -P version=${TAG:1} | |
test: | |
runs-on: macos-latest | |
needs: build | |
strategy: | |
matrix: | |
api-level: [28] | |
steps: | |
# Setup | |
- uses: actions/checkout@v3 | |
- name: set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
cache: gradle | |
# Caching | |
- name: Gradle cache | |
uses: gradle/gradle-build-action@v2 | |
- name: AVD cache | |
uses: actions/cache@v3 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.api-level }} | |
- name: create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
working-directory: android | |
api-level: ${{ matrix.api-level }} | |
target: google_apis | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: false | |
script: echo "Generated AVD snapshot for caching." | |
# Test | |
# Note: the fakedapp tests rely on fakewallet, so we always run the fakewallet | |
# tests first to ensure fakewallet is installed before the fakedapp tests | |
- name: run tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
working-directory: android | |
api-level: ${{ matrix.api-level }} | |
target: google_apis | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: | | |
adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS | |
./gradlew :fakewallet:connectedDebugAndroidTest | |
./gradlew :fakedapp:connectedDebugAndroidTest | |
- name: Archive fakewallet test results | |
if: ${{ success() || failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: fakewallet-connected-test-results-${{ matrix.api-level }} | |
path: android/fakewallet/build/reports/androidTests/connected/ | |
retention-days: 7 | |
- name: Archive fakedapp test results | |
if: ${{ success() || failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: fakedapp-connected-test-results-${{ matrix.api-level }} | |
path: android/fakedapp/build/reports/androidTests/connected/ | |
retention-days: 7 | |
# Note: only runs on 'push' events | |
publish-to-gh-pages: | |
runs-on: ubuntu-latest | |
needs: build | |
concurrency: publish-to-gh-pages | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- name: Update clientlib javadoc | |
uses: solana-mobile/gha-commit-artifact-to-branch@v1 | |
with: | |
token: ${{ secrets.UPDATE_GITHUB_PAGES_TOKEN }} | |
branch: gh-pages | |
artifact-name: clientlib-javadoc | |
dest: clientlib | |
commit-message: 'Update clientlib javadoc' | |
- name: Update common javadoc | |
uses: solana-mobile/gha-commit-artifact-to-branch@v1 | |
with: | |
token: ${{ secrets.UPDATE_GITHUB_PAGES_TOKEN }} | |
branch: gh-pages | |
artifact-name: common-javadoc | |
dest: common | |
commit-message: 'Update common javadoc' | |
- name: Update walletlib javadoc | |
uses: solana-mobile/gha-commit-artifact-to-branch@v1 | |
with: | |
token: ${{ secrets.UPDATE_GITHUB_PAGES_TOKEN }} | |
branch: gh-pages | |
artifact-name: walletlib-javadoc | |
dest: walletlib | |
commit-message: 'Update walletlib javadoc' | |
# Note: only runs on 'release' events | |
upload-to-release: | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
contents: write # needed for uploading files to releases | |
if: ${{ github.event_name == 'release' }} | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: binaries | |
path: binaries | |
- uses: actions/download-artifact@v3 | |
with: | |
name: clientlib-javadoc | |
path: clientlib-javadoc | |
- uses: actions/download-artifact@v3 | |
with: | |
name: common-javadoc | |
path: common-javadoc | |
- uses: actions/download-artifact@v3 | |
with: | |
name: walletlib-javadoc | |
path: walletlib-javadoc | |
- name: Compress clientlib javadoc | |
run: tar -cvzf clientlib-javadoc/clientlib-javadoc.tgz -C clientlib-javadoc javadoc | |
- name: Compress common javadoc | |
run: tar -cvzf common-javadoc/common-javadoc.tgz -C common-javadoc javadoc | |
- name: Compress walletlib javadoc | |
run: tar -cvzf walletlib-javadoc/walletlib-javadoc.tgz -C walletlib-javadoc javadoc | |
- name: Upload files to release | |
run: find ${FILES} -type f -exec gh release -R ${GITHUB_REPOSITORY} upload ${TAG} {} + | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAG: ${{ github.event.release.tag_name }} | |
FILES: | | |
binaries/ | |
clientlib-javadoc/clientlib-javadoc.tgz | |
common-javadoc/common-javadoc.tgz | |
walletlib-javadoc/walletlib-javadoc.tgz |