Semantic Versioning for Android

Why Semantic Versioning Matters

Version numbers shouldn't be arbitrary. They should communicate meaning. When you see 2.0.0, you know there are breaking changes. When you see 1.3.0, you know there are new features. When you see 1.2.5, you know it's a patch.

This project demonstrates how to fully automate semantic versioning for Android libraries and applications using conventional commits and GitHub Actions.

Semantic Versioning Banner
Semantic Versioning Banner

The Complete Pipeline

This isn't just about version numbers. It's a full DevOps setup for Android projects:

1. Conventional Commits

Every commit follows the Conventional Commits specification:

feat(auth): add OAuth2 login support
fix(api): resolve connection timeout issue
docs(readme): update installation instructions

Commitlint enforces this at the pre-commit hook level - no more "fix stuff" commits making it to main.

2. Automated Analysis

Every pull request triggers:

3. Semantic Release

When commits are merged to main:

  1. Analyze commit messages since last release
  2. Determine version bump (major/minor/patch)
  3. Generate changelog
  4. Create GitHub release
  5. Publish to Maven

GitHub Actions Workflows

The project includes several workflows:

# Code Scanner - runs on every PR
code-scanner.yml:
  - SpotBugs analysis
  - Security scanning
  - Code quality checks

# SDK CI - builds and tests
sdk-ci.yml:
  - Build project
  - Run unit tests
  - Generate coverage report
  - Upload to SonarQube

# Release - publishes on merge
release.yml:
  - Semantic version calculation
  - Changelog generation
  - Maven publishing
  - GitHub release creation

Installation

Add the repository to your project:

repositories {
    maven {
        url = uri("https://maven.pkg.github.com/abd3lraouf/Semantic")
    }
}

Add the dependency:

dependencies {
    implementation("dev.abd3lraouf.learn.Semantic:sdk:<latest-release>")
}

Key Takeaways

This project serves as a template for anyone wanting to:

The configuration files and workflows can be copied and adapted to any Android project.

Resources