Ensure generated release apk filename indicates it's heavyweight #40
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: | |
- android/** | |
- .github/workflows/* | |
pull_request: | |
branches: [ "main" ] | |
paths: | |
- android/** | |
- .github/workflows/* | |
release: | |
types: ["published"] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: source submodules | |
run: git submodule update --init | |
- name: set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: rust deps | |
run: cargo install [email protected] --locked | |
- name: rust targets | |
run: rustup target add aarch64-linux-android armv7-linux-androideabi | |
- name: rust cache | |
uses: actions/[email protected] | |
with: | |
# A list of files, directories, and wildcard patterns to cache and restore | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
rust/target/ | |
# An explicit key for restoring and saving the cache | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
# Run the post step to save the cache even if another step before fail | |
save-always: true | |
- name: gradle cargoNDK plugin needs this file for some reason | |
run: touch android/local.properties | |
- name: Grant execute permission for gradlew | |
working-directory: android/ | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
if: ${{ !(github.event_name == 'release') }} | |
working-directory: android/ | |
run: ./gradlew build | |
- name: Decode and write Keystore | |
if: ${{ (github.event_name == 'release') }} | |
env: | |
SIGNING_STORE_BASE64: ${{ secrets.SIGNING_STORE_BASE64 }} | |
TMP_DIR: ${{ runner.temp }} | |
run: | | |
SIGNING_STORE_FILE_PATH="${TMP_DIR}/keystore.jks" | |
echo ${SIGNING_STORE_BASE64} | base64 -di > ${SIGNING_STORE_FILE_PATH} | |
- name: Change gradle signing config to github release | |
if: ${{ (github.event_name == 'release') }} | |
run: | | |
sed -i 's/signingConfigs.getByName("debug")/signingConfigs.getByName("github")/g' android/app/build.gradle.kts | |
- name: Build with Gradle for release | |
if: ${{ (github.event_name == 'release') }} | |
working-directory: android/ | |
run: ./gradlew build assembleSource-originalRelease | |
env: | |
SIGNING_STORE_FILE_PATH: ${{ runner.temp }}/keystore.jks | |
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} | |
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} | |
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }} | |
- name: Upload apks to release assets | |
if: ${{ (github.event_name == 'release') }} | |
run: | | |
curl --fail -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.RELEASE_UPLOAD_PAT }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Content-Type: application/octet-stream" \ | |
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets?name=sharepaste.oo-source-original-arm64-v8a-release.unstrippedlibs.apk" \ | |
--data-binary "@android/app/build/outputs/apk/source-original/release/sharepaste.oo-source-original-arm64-v8a-release.apk" | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.RELEASE_UPLOAD_PAT }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Content-Type: application/octet-stream" \ | |
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets?name=sharepaste.oo-source-original-armeabi-v7a-release.unstrippedlibs.apk" \ | |
--data-binary "@android/app/build/outputs/apk/source-original/release/sharepaste.oo-source-original-armeabi-v7a-release.apk" | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.RELEASE_UPLOAD_PAT }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Content-Type: application/octet-stream" \ | |
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets?name=sharepaste.oo-source-original-universal-release.unstrippedlibs.apk" \ | |
--data-binary "@android/app/build/outputs/apk/source-original/release/sharepaste.oo-source-original-universal-release.apk" | |
- name: Upload Build Artifacts (Apks) | |
if: ${{ !(github.event_name == 'release') }} | |
uses: actions/[email protected] | |
with: | |
# Artifact name | |
name: BuiltApks-${{ github.sha }} | |
# A file, directory or wildcard pattern that describes what to upload | |
path: android/app/build/outputs/apk/**/release/ | |
# The level of compression for Zlib to be applied to the artifact archive. The value can range from 0 to 9: - 0: No compression - 1: Best speed - 6: Default compression (same as GNU Gzip) - 9: Best compression Higher levels will result in better compression, but will take longer to complete. For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads. | |
compression-level: 9 | |
# If true, an artifact with a matching name will be deleted before a new one is uploaded. If false, the action will fail if an artifact for the given name already exists. Does not fail if the artifact does not exist. | |
#overwrite: # optional, default is false | |