Skip to content

rhenwinch/android-gh-workflows-template

Repository files navigation

Android GitHub Actions Workflow Templates

A comprehensive collection of GitHub Actions workflows for Android projects, providing automated building, testing, validation, and release management.

🚀 Features

  • Automated APK Building & Releases - Build signed APKs and create GitHub releases with auto-generated changelogs
  • Comprehensive Testing - Run both unit tests and instrumented tests across multiple Android API levels
  • Code Quality Assurance - Validate Gradle wrapper integrity and perform pre-merge checks
  • Multi-Platform Support - Test builds across Ubuntu, macOS, and Windows
  • Smart Release Management - Support for both stable releases and pre-releases with automatic cleanup

📁 Workflow Files

Workflow File Purpose
APK Release apk-release.yaml Builds signed APK and creates GitHub releases with changelogs
Unit Tests unit-tests.yaml Runs unit tests and generates test reports
Instrumented Tests instrumented-tests.yaml Runs Android instrumented tests on emulators (API 29 & 33)
Pre-merge Checks pre-merge.yaml Cross-platform build validation before merging
Gradle Validation gradle-wrapper-validation.yaml Validates Gradle wrapper integrity

🔧 Setup Instructions

1. Copy Workflow Files

Copy all .yaml files to your repository's .github/workflows/ directory.

2. Configure Main Branch

Update the branch names in all workflows to match your repository's main branch:

# If your main branch is 'main' instead of 'master'
branches:
  - main  # Change from 'master' to 'main' or your branch name

3. Configure Java Version

Update the Java version in all workflows to match your project requirements:

java-version: '19'  # Change to your project's Java version
distribution: 'temurin'

4. Set Up Release Signing (Required for APK Release)

Add the following secrets to your repository settings:

  • SIGNING_KEY - Base64 encoded signing key
  • ALIAS - Key alias
  • KEY_STORE_PASSWORD - Keystore password
  • KEY_PASSWORD - Key password

5. Follow Conventional Commits

Ensure all commit messages follow the Conventional Commits specification for automatic changelog generation.

Examples:

feat: add new user authentication feature
fix: resolve crash on app startup
docs: update README with setup instructions

🏷️ Release Tags

The APK release workflow supports two tag formats:

  • Stable Releases: 1.2.3 (semantic versioning)
  • Pre-releases: PRE-abc1234 (7-character commit SHA)
# Create stable release
git tag 1.0.0
git push origin 1.0.0

# Create pre-release
git tag PRE-$(git rev-parse --short HEAD)
git push origin PRE-$(git rev-parse --short HEAD)

🔄 Workflow Triggers

Workflow Triggers
APK Release Tag push ([0-9]+.[0-9]+.[0-9]+, PRE-[a-f0-9]{7}), Manual dispatch
Unit Tests Push to main branch, PR to main branch, Manual dispatch
Instrumented Tests Push to main branch, PR to main branch, Manual dispatch
Pre-merge Checks Push to main branch, PR to any branch
Gradle Validation Push to main branch, PR to any branch

Note: Replace "main branch" with your actual branch name (e.g., master, main, develop) as configured in step 2.

📦 GitHub Actions Used

Core Actions

Gradle & Android

Testing & Reporting

Release Management

🛠️ Customization

Skip CI for Specific Commits

Add ci skip to commit messages to skip pre-merge checks:

git commit -m "docs: update README [ci skip]"

Modify Test API Levels

Update the matrix strategy in instrumented-tests.yaml:

strategy:
  matrix:
    api-level: [29, 33, 34]  # Add or remove API levels

Customize Changelog Types

Modify excluded commit types in apk-release.yaml:

excludeTypes: 'build,docs,other,style,refactor'

About

List of GitHub Action workflow templates for Android development

Resources

Stars

Watchers

Forks