image: debian/stable
sources:
- https://git.sr.ht/~singpolyma/cheogram-android
artifacts:
- cheogram.apk
- cheogram_google_play.apk
- cheogram_google_play.aab
packages:
- wget
- unzip
- android-sdk
secrets:
- 7eed327c-05c7-49b4-baed-a4d8785588d5
- b412b263-bdde-410b-997e-6326aba90132
- 6b782fde-a43b-4988-b102-38fa541bb788
environment:
  ANDROID_SDK_ROOT: /home/build/android
tasks:
- sdk: |
    wget -qO android.zip https://dl.google.com/android/repository/commandlinetools-linux-6987402_latest.zip
    unzip -qq android.zip
    mkdir -p android/cmdline-tools
    mv cmdline-tools android/cmdline-tools/tools
    echo y | android/cmdline-tools/tools/bin/sdkmanager "platforms;android-29"
    echo y | android/cmdline-tools/tools/bin/sdkmanager "platform-tools"
    echo y | android/cmdline-tools/tools/bin/sdkmanager "build-tools;29.0.2"
    touch ~/.android/repositories.cfg
    yes | android/cmdline-tools/tools/bin/sdkmanager --licenses
- sentry: |
    cd cheogram-android
    sed -ie 's/<!-- INSERT -->/<meta-data android:name="io.sentry.dsn" android:value="https:\/\/680d470d348a4cc494bf2198eed30c49@o559641.ingest.sentry.io\/6221823" \/>/' src/cheogram/AndroidManifest.xml
    sed -ie 's/\/\/ INSERT/implementation "io.sentry:sentry-android:6.4.2"/' build.gradle
- build_free: |
    cd cheogram-android
    ./gradlew assembleCheogramFreeDebug
- build_google_play: |
    cd cheogram-android
    mkdir -p src/playstore/res/values/
    mv ~/push.xml src/playstore/res/values/
    ./gradlew assembleCheogramPlaystoreDebug
    echo keystore=$HOME/.android/cheogram.keystore > signing.properties
    echo keystore.password=cheogram >> signing.properties
    echo keystore.alias=cheogram >> signing.properties
    ./gradlew bundleCheogramPlaystoreRelease
- assets: |
    mv cheogram-android/build/outputs/apk/cheogramFree/debug/*.apk cheogram.apk
    mv cheogram-android/build/outputs/apk/cheogramPlaystore/debug/*.apk cheogram_google_play.apk
    mv cheogram-android/build/outputs/bundle/cheogramPlaystoreRelease/*.aab cheogram_google_play.aab
