diff --git a/.github/workflows/generate-apk-aab-debug-release.yml b/.github/workflows/generate-apk-aab-debug-release.yml new file mode 100644 index 00000000..e3115fdb --- /dev/null +++ b/.github/workflows/generate-apk-aab-debug-release.yml @@ -0,0 +1,82 @@ +name: Build APKs for PR (multi-module) + +# Trigger on pull requests (any branch / any PR event) +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + build-modules: + name: Build ${{ matrix.module }} + runs-on: ubuntu-latest + strategy: + matrix: + # Edit these module names to match your Gradle module names + module: [app, lyrics-maker] + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '17' + + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + with: + api-level: 33 + components: | + build-tools;33.0.2 + platform-tools + platforms;android-33 + + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/**') }} + + - name: Ensure gradlew is executable + run: chmod +x ./gradlew + + - name: Build APK for module ${{ matrix.module }} + # Using assembleRelease so you get APKs in build/outputs; if you prefer debug builds (always unsigned), + # change to :${{ matrix.module }}:assembleDebug + run: ./gradlew :modules:${{ matrix.module }}:assembleDebug --no-daemon -Porg.gradle.jvmargs=-Xmx3g + + - name: Collect produced APKs + id: find-apks + run: | + # find APK(s) for this module (search under module build outputs) + APKS=( $(find . -path "./modules/${{ matrix.module }}/build/outputs/apk" -type f -name '*.apk' -print) ) + if [ ${#APKS[@]} -eq 0 ]; then + echo "No APKs found for module '${{ matrix.module }}'." + # exit non-zero if you want the job to fail instead: + # exit 1 + else + echo "Found APKs:" + for f in "${APKS[@]}"; do + echo " - $f" + done + fi + # export a newline-separated list for upload step + printf "%s\n" "${APKS[@]}" > apks_list.txt + echo "apks_list=apks_list.txt" >> $GITHUB_OUTPUT + shell: bash + + - name: Upload APK artifact for ${{ matrix.module }} + if: always() # still run to ensure artifact (even if none found, action will create empty artifact) + uses: actions/upload-artifact@v4 + with: + # name artifact per module so each appears separately in Actions UI + name: ${{ matrix.module }}-apk + # upload all apk files found under the module build outputs + path: | + modules/${{ matrix.module }}/build/outputs/apk/**/*.apk + modules/${{ matrix.module }}/build/outputs/**/**/*.apk