APK Distribution Pipeline
apkdist builds an Android APK, uploads it to Google Drive, and sends a Telegram release message.
Quickstart
- Install:
python -m venv .venv
source .venv/bin/activate
pip install -e .
-
Create
.envfrom.env.exampleand set required values. -
Validate toolchain:
apkdist env-check --project /absolute/path/to/android-project
- Run a dry run:
apkdist make patch --dry-run
- Run a real release:
apkdist make patch release
What It Does
bump version -> build APK -> upload to Drive -> notify in Telegram
- Bumps
<module>/version.properties. - Runs
:module:assemble<Variant>with Gradle Wrapper. - Uploads APK to Drive and generates a direct download link.
- Sends Telegram notification and optionally
sendDocument.
Commands
apkdist make <major|minor|patch> [variant] [--force] [--dry-run] [--env-file PATH]
apkdist env-check [--project PATH]
apkdist cleanup [--days 7] [--delete] [--env-file PATH]
apkdist telegram-updates [--timeout 10] [--env-file PATH]
Required Environment
Minimum .env:
ANDROID_PROJECT_PATH=/absolute/path/to/android-project
DRIVE_FOLDER_ID=google_drive_folder_id
TELEGRAM_BOT_TOKEN=bot_token
TELEGRAM_CHAT_ID=-1001234567890
# Set one Drive auth mode:
GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/service-account.json
# OAUTH_CREDENTIALS_FILE=/absolute/path/to/credentials.json
Environment Variables
| Variable | Required | Notes |
|---|---|---|
ANDROID_PROJECT_PATH |
Yes | Android project root where gradlew exists |
APP_MODULE_NAME |
No | Default app |
DRIVE_FOLDER_ID |
Yes | Target Drive folder |
GOOGLE_APPLICATION_CREDENTIALS |
One of two | Service account JSON |
OAUTH_CREDENTIALS_FILE |
One of two | OAuth desktop credentials |
OAUTH_TOKEN_FILE |
No | Default: platform config dir token path |
TELEGRAM_BOT_TOKEN |
Yes | Bot token from BotFather |
TELEGRAM_CHAT_ID |
Yes | Chat/group/channel id |
TELEGRAM_THREAD_ID |
No | Topic/thread id |
TELEGRAM_SEND_DOCUMENT |
No | Default true |
TELEGRAM_CLOUD_DOCUMENT_LIMIT_MB |
No | Default 50, cloud API only |
TELEGRAM_API_BASE_URL |
No | Default https://api.telegram.org |
TELEGRAM_API_ID |
No | Needed only for local bot API container |
TELEGRAM_API_HASH |
No | Needed only for local bot API container |
Telegram Chat and Thread Discovery
Use:
apkdist telegram-updates --timeout 10
It prints discovered chat_id and optional thread_id values from Telegram getUpdates.
Telegram Delivery Behavior
- Drive upload happens on every run.
- Cloud Bot API (
api.telegram.org):- Sends text message.
- Sends document only when APK size is within
TELEGRAM_CLOUD_DOCUMENT_LIMIT_MB.
- Local Bot API server:
- With
TELEGRAM_SEND_DOCUMENT=true, sends one document message (single release message). - Caption includes fallback Drive link button.
- With
Optional: Local Telegram Bot API Server (Separate Container)
This repository includes docker-compose.yml for telegram-bot-api only.
The APK pipeline runs locally on host and calls that server.
- Add in
.env:
TELEGRAM_API_ID=12345678
TELEGRAM_API_HASH=0123456789abcdef0123456789abcdef
TELEGRAM_API_BASE_URL=http://localhost:8081
- Start server:
docker compose up -d telegram-bot-api
- Run
apkdistfrom host as usual.
Google Drive Auth Modes
Service account (recommended for shared/team setup)
- Enable Drive API in Google Cloud.
- Create service account and key JSON.
- Share target Drive folder/shared drive with service account email.
- Set
GOOGLE_APPLICATION_CREDENTIALSandDRIVE_FOLDER_ID.
OAuth desktop app (personal Google Drive)
- Enable Drive API in Google Cloud.
- Create OAuth client credentials (Desktop app).
- Set
OAUTH_CREDENTIALS_FILE. - First run opens browser consent and stores token in
OAUTH_TOKEN_FILE.
Cleanup Old APKs
apkdist cleanup --days 14
apkdist cleanup --days 14 --delete
--delete always prompts for confirmation.
Troubleshooting
| Problem | Action |
|---|---|
Required environment variable ... not set |
Fill .env and rerun |
Could not find gradlew |
Confirm ANDROID_PROJECT_PATH points to Android root |
Service account file not found |
Use absolute path for credentials JSON |
Could not find APK in ... |
Verify build variant folder under build/outputs/apk/ |
Telegram sendDocument Error |
Use local Bot API server or lower APK size |
Development Checks
Before submitting changes:
python -m py_compile apkdist/cli.py apkdist/pipeline.py apkdist/env_check.py apkdist/cleanup.py apkdist/config.py apkdist/telegram.py apkdist/drive_auth.py apkdist/telegram_updates.py
apkdist make patch --dry-run
License
Metadata
Release files for apk-distribution-pipeline 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| apk_distribution_pipeline-2.1.0.tar.gz | 17.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| apk_distribution_pipeline-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.3 kB
Release files / apk_distribution_pipeline-2.1.0.tar.gz
| Download URL | apk_distribution_pipeline-2.1.0.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
315145fa56ed5449a31f875436cf04a5165e6ae47e9fa0e891e046210f5e8bae
|
|
BLAKE2b-256 checksum How to use checksums |
4a32b1585859909864463a7fbfde095795bf6d52653886270fd05acde1b00fab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / apk_distribution_pipeline-2.1.0-py3-none-any.whl
| Download URL | apk_distribution_pipeline-2.1.0-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c1128a3e598792d09c9ef4e721f9eaa4d813aa0974614cdba9982124947cf13d
|
|
BLAKE2b-256 checksum How to use checksums |
f925b84559e2098ce555846e8c9225b2cbde9cca8434169c236b379017fa4619
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for apk-distribution-pipeline 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.