Skip to content

Commit

Permalink
Update android-release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Jun 26, 2024
1 parent 2183beb commit 9c35a5f
Showing 1 changed file with 40 additions and 25 deletions.
65 changes: 40 additions & 25 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,72 @@ jobs:
build: [default, lite]
env:
ANDROID_NDK_VERSION: "21.3.6528147"
BUILD_TOOLS_VERSION: "34.0.0"
ANDROID_SDK_ROOT: "/usr/local/lib/android/sdk"
FILES: |
app/src/main/AndroidManifest.xml
app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt
app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt
app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt
steps:
- name: checkout repository code
uses: actions/checkout@v4

- name: diff the code to get lite
if: matrix.build == 'lite'
run: |
echo "lite"
ls -al \
app/build.gradle \
app/src/main/AndroidManifest.xml \
app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt \
app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt \
app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt
sed -i 's/\(versionName "[0-9.]\+\)"/\1-lite"/' app/build.gradle
cp app/src/main/AndroidManifest.xml.lite app/src/main/AndroidManifest.xml
cp app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt
cp app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt
cp app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt
- name: set more env
run: echo "BRANCHNAME="${GITHUB_REF##*/} >> $GITHUB_ENV

- name: checkout repository code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: expose version from build.gradle
uses: dogi/[email protected]
with:
expose-version-name: 'true'
expose-version-code: 'true'

- name: diff the code to get lite
if: matrix.build == 'lite'
run: |
ls -al app/build.gradle
sed -i 's/\(versionName "[0-9.]\+\)"/\1-lite"/' app/build.gradle
echo "${{ env.FILES }}" | xargs -n 1 | while read file; do
ls -al $file*
cp "${file}.lite" "$file"
done
- name: setup JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'

- name: cache NDK
id: cache-ndk
uses: actions/cache@v4
with:
path: ${{ env.ANDROID_SDK_ROOT }}/ndk/${{ env.ANDROID_NDK_VERSION }}
key: ${{ runner.os }}-ndk-${{ env.ANDROID_NDK_VERSION }}
restore-keys: |
${{ runner.os }}-ndk-
- name: install NDK
if: steps.cache-ndk.outputs.cache-hit != 'true'
run: |
set -x
echo "ANDROID_HOME is set to: ${ANDROID_HOME}"
echo "ANDROID_SDK_ROOT is set to: ${ANDROID_SDK_ROOT}"
echo "ANDROID_NDK_VERSION is set to: ${ANDROID_NDK_VERSION}"
echo "y" | sudo ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${ANDROID_NDK_VERSION}" --sdk_root=${ANDROID_SDK_ROOT} 2>&1
if [ $? -ne 0 ]; then
echo "SDK Manager command failed"
exit 1
fi
set +x
chmod +x ./gradlew
ls -al ${ANDROID_SDK_ROOT}/ndk
- name: setup gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.7
cache-disabled: false
cache-read-only: false
cache-write-only: false

- name: build release APK and AAB
run: |
Expand Down

0 comments on commit 9c35a5f

Please sign in to comment.