Add multi architecture Android builds and reduce bundle sizes (#413)

* Add multi architecture Android builds and reduce bundle sizes

* Disable Proguard

* Add universal build
This commit is contained in:
Reckless_Satoshi 2023-04-10 17:02:30 +00:00 committed by GitHub
parent 72f620fee4
commit 1ac6e0fa86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 168 additions and 45 deletions

View File

@ -53,12 +53,6 @@ jobs:
- name: Setup Gradle - name: Setup Gradle
uses: gradle/gradle-build-action@v2 uses: gradle/gradle-build-action@v2
# - name: 'Build Android Debug'
# if: inputs.semver == '' # Only build debug if this is a pre-release
# run: |
# cd mobile/android
# ./gradlew assembleDebug
- name: 'Build Android Release' - name: 'Build Android Release'
run: | run: |
cd mobile/android cd mobile/android
@ -68,26 +62,46 @@ jobs:
id: commit id: commit
uses: pr-mpt/actions-commit-hash@v1 uses: pr-mpt/actions-commit-hash@v1
- name: 'Upload .apk Release Artifact (for Release)' # Create artifacts (only for Release)
# Create app-universal-release APK artifact asset for Release
- name: 'Upload universal .apk Release Artifact (for Release)'
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
if: inputs.semver != '' # If this workflow is called from release.yml if: inputs.semver != '' # If this workflow is called from release.yml
with: with:
name: robosats-${{ inputs.semver }}.apk name: robosats-${{ inputs.semver }}-universal.apk
path: mobile/android/app/build/outputs/apk/release/app-release.apk path: mobile/android/app/build/outputs/apk/release/app-universal-release.apk
- name: 'Upload .apk Artifact (for Pre-release)' # Create app-arm64-v8a-release APK artifact asset for Release
- name: 'Upload arm64-v8a .apk Release Artifact (for Release)'
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release) if: inputs.semver != '' # If this workflow is called from release.yml
with: with:
name: robosats-${{ steps.commit.outputs.short }}.apk name: robosats-${{ inputs.semver }}-arm64-v8a.apk
path: mobile/android/app/build/outputs/apk/release/app-release.apk path: mobile/android/app/build/outputs/apk/release/app-arm64-v8a-release.apk
# - name: 'Upload .apk Debug Artifact (for Pre-release)' # Create app-armeabi-v7a-release APK artifact asset for Release
# if: inputs.semver == '' # Only build debug if this is a pre-release - name: 'Upload armeabi-v7a .apk Release Artifact (for Release)'
# uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
# with: if: inputs.semver != '' # If this workflow is called from release.yml
# name: robosats-debug-${{ steps.commit.outputs.short }}.apk with:
# path: mobile/android/app/build/outputs/apk/debug/app-debug.apk name: robosats-${{ inputs.semver }}-armeabi-v7a.apk
path: mobile/android/app/build/outputs/apk/release/app-armeabi-v7a-release.apk
# Create app-x86_64-release APK artifact asset for Release
- name: 'Upload x86_64 .apk Release Artifact (for Release)'
uses: actions/upload-artifact@v3
if: inputs.semver != '' # If this workflow is called from release.yml
with:
name: robosats-${{ inputs.semver }}-x86_64.apk
path: mobile/android/app/build/outputs/apk/release/app-x86_64-release.apk
# Create app-x86-release APK artifact asset for Release
- name: 'Upload x86 .apk Release Artifact (for Release)'
uses: actions/upload-artifact@v3
if: inputs.semver != '' # If this workflow is called from release.yml
with:
name: robosats-${{ inputs.semver }}-x86.apk
path: mobile/android/app/build/outputs/apk/release/app-x86-release.apk
- name: 'Create Pre-release' - name: 'Create Pre-release'
id: create_release id: create_release
@ -102,26 +116,67 @@ jobs:
draft: false draft: false
prerelease: true prerelease: true
- name: 'Upload Pre-release APK Release Asset' # Upload universal APK to pre-release
id: upload-release-apk-asset - name: 'Upload universal Pre-release APK Asset'
id: upload-release-universal-apk-asset
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release) if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ steps.create_release.outputs.upload_url }} upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mobile/android/app/build/outputs/apk/release/app-release.apk asset_path: ./mobile/android/app/build/outputs/apk/release/app-universal-release.apk
asset_name: robosats-${{ steps.commit.outputs.short }}.apk asset_name: robosats-${{ steps.commit.outputs.short }}-universal.apk
asset_content_type: application/apk asset_content_type: application/apk
# - name: 'Upload Pre-release APK Debug Asset' # Upload arm64-v8a APK to pre-release
# id: upload-debug-apk-asset - name: 'Upload arm64-v8a Pre-release APK Asset'
# if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release) id: upload-release-arm64-v8a-apk-asset
# uses: actions/upload-release-asset@v1 if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
# env: uses: actions/upload-release-asset@v1
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} env:
# with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# upload_url: ${{ steps.create_release.outputs.upload_url }} with:
# asset_path: ./mobile/android/app/build/outputs/apk/debug/app-debug.apk upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_name: robosats-debug-${{ steps.commit.outputs.short }}.apk asset_path: ./mobile/android/app/build/outputs/apk/release/app-arm64-v8a-release.apk
# asset_content_type: application/apk asset_name: robosats-${{ steps.commit.outputs.short }}-arm64-v8a.apk
asset_content_type: application/apk
# Upload armeabi-v7a APK to pre-release
- name: 'Upload armeabi-v7a Pre-release APK Asset'
id: upload-release-armeabi-v7a-apk-asset
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mobile/android/app/build/outputs/apk/release/app-armeabi-v7a-release.apk
asset_name: robosats-${{ steps.commit.outputs.short }}-armeabi-v7a.apk
asset_content_type: application/apk
# Upload x86_64 APK to pre-release
- name: 'Upload x86_64 Pre-release APK Asset'
id: upload-release-x86_64-apk-asset
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mobile/android/app/build/outputs/apk/release/app-x86_64-release.apk
asset_name: robosats-${{ steps.commit.outputs.short }}-x86_64.apk
asset_content_type: application/apk
# Upload x86 APK to pre-release
- name: 'Upload x86 Pre-release APK Asset'
id: upload-release-x86-apk-asset
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mobile/android/app/build/outputs/apk/release/app-x86-release.apk
asset_name: robosats-${{ steps.commit.outputs.short }}-x86.apk
asset_content_type: application/apk

View File

@ -83,19 +83,87 @@ jobs:
with: with:
body: ${{ steps.changelog.outputs.changelog }} body: ${{ steps.changelog.outputs.changelog }}
# Upload APK artifact asset # Upload app-universal-release APK artifact asset
- name: 'Download APK Artifact' - name: 'Download universal APK Artifact'
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: robosats-${{ needs.check-versions.outputs.semver }}.apk name: robosats-${{ needs.check-versions.outputs.semver }}-universal.apk
path: . path: .
- name: 'Upload APK Asset' - name: 'Upload universal APK Asset'
id: upload-release-asset id: upload-release-asset
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ steps.create-release.outputs.upload_url }} upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: app-release.apk asset_path: app-universal-release.apk
asset_name: robosats-${{ needs.check-versions.outputs.semver }}.apk asset_name: robosats-${{ needs.check-versions.outputs.semver }}-universal.apk
asset_content_type: application/apk
# Upload app-arm64-v8a-release APK artifact asset
- name: 'Download arm64-v8a APK Artifact'
uses: actions/download-artifact@v3
with:
name: robosats-${{ needs.check-versions.outputs.semver }}-arm64-v8a.apk
path: .
- name: 'Upload arm64-v8a APK Asset'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: app-arm64-v8a-release.apk
asset_name: robosats-${{ needs.check-versions.outputs.semver }}-arm64-v8a.apk
asset_content_type: application/apk
# Upload app-armeabi-v7a-release APK artifact asset
- name: 'Download armeabi-v7a APK Artifact'
uses: actions/download-artifact@v3
with:
name: robosats-${{ needs.check-versions.outputs.semver }}-armeabi-v7a.apk
path: .
- name: 'Upload armeabi-v7a APK Asset'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: app-armeabi-v7a-release.apk
asset_name: robosats-${{ needs.check-versions.outputs.semver }}-armeabi-v7a.apk
asset_content_type: application/apk
# Upload app-x86_64-release APK artifact asset
- name: 'Download x86_64 APK Artifact'
uses: actions/download-artifact@v3
with:
name: robosats-${{ needs.check-versions.outputs.semver }}-x86_64.apk
path: .
- name: 'Upload x86_64 APK Asset'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: app-x86_64-release.apk
asset_name: robosats-${{ needs.check-versions.outputs.semver }}-x86_64.apk
asset_content_type: application/apk
# Upload app-x86-release APK artifact asset
- name: 'Download x86 APK Artifact'
uses: actions/download-artifact@v3
with:
name: robosats-${{ needs.check-versions.outputs.semver }}-x86.apk
path: .
- name: 'Upload x86 APK Asset'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: app-x86-release.apk
asset_name: robosats-${{ needs.check-versions.outputs.semver }}-x86.apk
asset_content_type: application/apk asset_content_type: application/apk

View File

@ -91,7 +91,7 @@ apply from: "../../node_modules/react-native/react.gradle"
* Upload all the APKs to the Play Store and people will download * Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device. * the correct one based on the CPU architecture of their device.
*/ */
def enableSeparateBuildPerCPUArchitecture = false def enableSeparateBuildPerCPUArchitecture = true
/** /**
* Run Proguard to shrink the Java bytecode in release builds. * Run Proguard to shrink the Java bytecode in release builds.
@ -224,7 +224,7 @@ android {
abi { abi {
reset() reset()
enable enableSeparateBuildPerCPUArchitecture enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK universalApk true // If true, also generate a universal APK
include (*reactNativeArchitectures()) include (*reactNativeArchitectures())
} }
} }

View File

@ -1,12 +1,12 @@
{ {
"name": "robosats", "name": "robosats",
"version": "0.4.1", "version": "0.4.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "robosats", "name": "robosats",
"version": "0.4.1", "version": "0.4.2",
"dependencies": { "dependencies": {
"@react-native-clipboard/clipboard": "^1.11.1", "@react-native-clipboard/clipboard": "^1.11.1",
"@react-native-community/netinfo": "^9.3.4", "@react-native-community/netinfo": "^9.3.4",

View File

@ -1,6 +1,6 @@
{ {
"name": "robosats", "name": "robosats",
"version": "0.4.1", "version": "0.4.2",
"private": true, "private": true,
"scripts": { "scripts": {
"android": "react-native run-android", "android": "react-native run-android",