name: DroidMind CI/CD ๐
on:
push:
branches: [main]
tags:
- "v*"
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build-and-test: # ๐๏ธ Build, Lint & Test ๐งช
name: ๐๏ธ Build, Lint & Test ๐งช
runs-on: ubuntu-latest
steps:
- name: ๐ฐ๏ธ Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for `softprops/action-gh-release` to generate release notes
- name: ๐ Set up Python Environment
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache-dependency-path: "pyproject.toml"
- name: โก Install uv Build System
uses: astral-sh/setup-uv@v6
- name: ๐ฆ Install Project Dependencies
run: uv sync --all-groups
- name: ๐
Run DroidMind Lint Script
run: uv run python scripts/lint.py
- name: ๐งช Execute Pytest Suite
run: uv run pytest
- name: ๐ Upload Test Results Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ github.sha }}
path: test-results/ # Adjust if your pytest output path is different
- name: ๐ง Set up QEMU (for multi-platform builds)
uses: docker/setup-qemu-action@v3
- name: ๐ ๏ธ Set up Docker Buildx Engine
uses: docker/setup-buildx-action@v3
- name: ๐ณ Build Docker Image (no push)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: false
tags: droidmind:latest,droidmind:${{ github.sha }}
build-docs: # ๐ Build Documentation Site ๐
name: ๐ Build Documentation Site ๐
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- name: ๐ฐ๏ธ Checkout Repository
uses: actions/checkout@v4
- name: ๐ Set up Python Environment
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache-dependency-path: "pyproject.toml"
- name: โก Install uv Build System
uses: astral-sh/setup-uv@v6
- name: ๐ Install Documentation Dependencies
run: uv sync --all-groups
- name: ๐๏ธ Build MkDocs Site
run: uv run mkdocs build --config-file mkdocs.yml
- name: ๐ค Upload Documentation Artifact
uses: actions/upload-artifact@v4
with:
name: site-${{ github.sha }}
path: site
deploy-docs: # ๐ Deploy Documentation to GitHub Pages ๐
name: ๐ Deploy Documentation to GitHub Pages ๐
needs: [build-docs]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: ๐ฐ๏ธ Checkout Repository
uses: actions/checkout@v4
- name: ๐ฅ Download Built Documentation Artifact
uses: actions/download-artifact@v4
with:
name: site-${{ github.sha }}
path: site
- name: ๐ Publish to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
create-release: # ๐ Create GitHub Release โจ
name: ๐ Create GitHub Release โจ
needs: [build-and-test, deploy-docs]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: ๐ฐ๏ธ Checkout Repository (full history)
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for release notes generation
- name: ๐ท๏ธ Generate GitHub Release Notes
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.ref_name }}
generate_release_notes: true
# files: | # Optional: attach files like .whl or .tar.gz to the release
# dist/*.whl
# dist/*.tar.gz
publish-pypi: # ๐ Publish Python Package to PyPI ๐ฆ
name: ๐ Publish Python Package to PyPI ๐ฆ
needs: create-release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write # For trusted PyPI publishing
steps:
- name: ๐ฐ๏ธ Checkout Repository
uses: actions/checkout@v4
- name: ๐ Set up Python Environment
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: โก Install uv Build System
uses: astral-sh/setup-uv@v6
- name: ๐ ๏ธ Build Python Package
run: |
uv pip install --system build
python -m build
- name: ๐ Publish to PyPI via Trusted Publisher
uses: pypa/gh-action-pypi-publish@release/v1
publish-docker: # ๐ณ Publish Docker Image to Registries ๐ข
name: ๐ณ Publish Docker Image to Registries ๐ข
needs: create-release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: read
packages: write
id-token: write # If using OIDC for Docker Hub
steps:
- name: ๐ฐ๏ธ Checkout Repository
uses: actions/checkout@v4
- name: ๐ Extract Version from Git Tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: ๐ง Set up QEMU (for multi-platform builds)
uses: docker/setup-qemu-action@v3
- name: ๐ ๏ธ Set up Docker Buildx Engine
uses: docker/setup-buildx-action@v3
- name: ๐ Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: ๐ Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: ๐ Build & Push Docker Images to Registries
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
hyperb1iss/droidmind:latest
hyperb1iss/droidmind:${{ steps.get_version.outputs.VERSION }}
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ steps.get_version.outputs.VERSION }}
labels: |
org.opencontainers.image.title=DroidMind
org.opencontainers.image.description=Control Android devices with AI through the Model Context Protocol
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.version=${{ steps.get_version.outputs.VERSION }}
org.opencontainers.image.created=${{ github.event.repository.updated_at }}
org.opencontainers.image.revision=${{ github.sha }}