Skip to content

Instantly share code, notes, and snippets.

@tboy1337
Last active February 6, 2025 12:54
Show Gist options
  • Save tboy1337/758bda5d4d4cac8d6e8c67ef82990978 to your computer and use it in GitHub Desktop.
Save tboy1337/758bda5d4d4cac8d6e8c67ef82990978 to your computer and use it in GitHub Desktop.
name: Build Python APK
on:
push:
branches:
- main # Trigger on push to the main branch
pull_request:
branches:
- main # Trigger on pull requests to the main branch
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12' # Use the Python version required by your project
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
python3-pip \
python3-setuptools \
python3-virtualenv \
git \
zip \
unzip \
openjdk-11-jdk \
zlib1g-dev \
libncurses5-dev \
libncursesw5-dev \
libtinfo5 \
build-essential \
libssl-dev \
libffi-dev \
libxml2-dev \
libxslt1-dev \
libjpeg8-dev \
zlib1g-dev
- name: Install Buildozer
run: |
python3 -m pip install --upgrade pip
python3 -m pip install buildozer
- name: Generate buildozer.spec if it doesn't exist
run: |
if [ ! -f buildozer.spec ]; then
echo "Creating buildozer.spec..."
buildozer init
# Update the source.include_exts in buildozer.spec to include your Python script
sed -i "s/^source.include_exts = .*/source.include_exts = py/" buildozer.spec
# Set the main Python script as the entry point
MAIN_SCRIPT=$(find . -name "*.py" -not -path "./venv/*" -not -path "./.git/*" | head -n 1)
if [ -n "$MAIN_SCRIPT" ]; then
sed -i "s|^source.include_patterns = .*|source.include_patterns = $(basename "$MAIN_SCRIPT")|" buildozer.spec
else
echo "No Python script found in the repository!"
exit 1
fi
else
echo "buildozer.spec already exists. Skipping generation."
fi
- name: Build APK
run: |
buildozer -v android debug
- name: Upload APK as artifact
uses: actions/upload-artifact@v4
with:
name: app-debug.apk
path: bin/*.apk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment