Build Job #5
Workflow file for this run
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: Build Android APK | |
run-name: Build Job | |
on: | |
workflow_dispatch: | |
inputs: | |
repository: | |
description: "Git repository URL" | |
required: true | |
default: "https://github.com/abdallahmehiz/mpvKt" | |
appName: | |
description: "New app name" | |
required: false | |
applicationId: | |
description: "New application ID" | |
required: false | |
jdkVersion: | |
description: "OpenJDK version to use: 8 / 11 / 17 etc." | |
required: false | |
default: "17" | |
taskName: | |
description: "build.gradle task name: assemble[Type]" | |
required: false | |
default: "assemblePreview" | |
jobs: | |
build: | |
runs-on: ubuntu-latest # Android SDK is built-in in this image | |
steps: | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: ${{ github.event.inputs.jdkVersion }} | |
- name: Clone project | |
run: git clone ${{ github.event.inputs.repository }} workspace | |
- name: Change App Name | |
run: | | |
set -e | |
cd workspace | |
if [ -n "${{ github.event.inputs.appName }}" ]; then | |
sed -i 's|<string name="app_name">.*</string>|<string name="app_name">${{ github.event.inputs.appName }}</string>|' app/src/main/res/values/strings.xml | |
fi | |
- name: Change Application ID | |
run: | | |
set -e | |
cd workspace | |
if [ -n "${{ github.event.inputs.applicationId }}" ]; then | |
sed -i 's|applicationId = ".*"|applicationId = "${{ github.event.inputs.applicationId }}"|' app/build.gradle.kts | |
fi | |
- name: Build APK | |
working-directory: ./workspace | |
run: | | |
if [ ! -f "gradlew" ]; then gradle wrapper; fi | |
chmod +x gradlew | |
./gradlew ${{ github.event.inputs.taskName }} --stacktrace | |
- name: Count commits | |
run: | | |
set -e | |
cd workspace | |
commit_count=$(git rev-list --count HEAD) | |
echo "COMMIT_COUNT=$commit_count" >> $GITHUB_ENV | |
- name: Upload APK 1 | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./workspace/app/build/outputs/apk/preview/app-universal-preview.apk | |
name: app-standard-universal-${{ env.COMMIT_COUNT }}.apk | |
retention-days: 3 | |
- name: Upload APK 2 | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./workspace/app/build/outputs/apk/preview/app-arm64-v8a-preview.apk | |
name: app-standard-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk | |
retention-days: 3 | |
- name: Upload APK 3 | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./workspace/app/build/outputs/apk/preview/app-armeabi-v7a-preview.apk | |
name: app-standard-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk | |
retention-days: 3 | |
- name: Upload APK 4 | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./workspace/app/build/outputs/apk/preview/app-x86-preview.apk | |
name: app-standard-x86-r${{ env.COMMIT_COUNT }}.apk | |
retention-days: 3 | |
- name: Upload APK 5 | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./workspace/app/build/outputs/apk/preview/app-x86_64-preview.apk | |
name: app-standard-x86_64-r${{ env.COMMIT_COUNT }}.apk | |
retention-days: 3 |