Skip to content

Update build.yml

Update build.yml #31

Workflow file for this run

name: Build APK
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20.x'
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '8'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Cache Android SDK
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.android-sdk
key: ${{ runner.os }}-android-sdk-${{ hashFiles('buildozer.spec') }}
restore-keys: |
${{ runner.os }}-android-sdk-
- name: Set up Buildozer
run: |
pip install buildozer
sudo apt-get install -y liblzma-dev
- name: Check and Install Android SDK
run: |
export ANDROID_HOME=${{ github.workspace }}/.android-sdk
export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH
mkdir -p $ANDROID_HOME
echo "ANDROID_HOME is set to: $ANDROID_HOME"
echo "PATH is set to: $PATH"
ls -alh $ANDROID_HOME # Debugging: Check directory contents
sdkmanager --list || true # Debugging: List installed SDK components
sdkmanager --list_installed > installed_sdk.txt || true
if ! grep -q 'platform-tools' installed_sdk.txt; then
echo "Accepting SDK licenses..."
yes | sdkmanager --licenses
echo "Installing SDK components..."
sdkmanager --sdk_root=$ANDROID_HOME "platform-tools" "platforms;android-30" "build-tools;30.0.3"
else
echo "Android SDK is already installed"
fi
- name: Set ANDROID_HOME in buildozer.spec
run: |
sed -i 's|# (str) Path to where the android sdk is installed|ANDROID_HOME = ${{ github.workspace }}/.android-sdk|' buildozer.spec
- name: Debug List of files in bin directory
run: |
ls -alh bin || echo "bin directory does not exist"
- name: Build APK
run: |
export ANDROID_HOME=${{ github.workspace }}/.android-sdk
export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH
buildozer android debug > buildozer.log 2>&1 || true
cat buildozer.log
- name: Upload Buildozer Log
uses: actions/upload-artifact@v3
with:
name: buildozer-log
path: buildozer.log
- name: Ensure destination directory exists
run: mkdir -p ${GITHUB_WORKSPACE}/project/bin
- name: Copy APK to workspace
run: |
if [ -d "bin" ]; then cp -r bin ${GITHUB_WORKSPACE}/project/bin; else echo "bin directory does not exist"; fi
ls -alh ${GITHUB_WORKSPACE}/project/bin || echo "${GITHUB_WORKSPACE}/project/bin directory does not exist"
- name: Upload an APK
uses: actions/upload-artifact@v3
with:
name: apk
path: ${GITHUB_WORKSPACE}/project/bin/*.apk
if-no-files-found: warn