name: Python CI + Release
on:
push:
branches: [ "main" ]
tags:
- 'v*' # Trigger on version tags like v1.0, v2.1.3
pull_request:
branches: [ "main" ]
permissions:
contents: read # Default needed for checkout
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# Run on Python version specified in pyproject.toml
# Add other versions if needed
python-version: ["3.10"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v5 # Use v5 of the action
with:
version: "0.6.12" # Pin uv version (example from docs)
enable-cache: true # Enable caching
cache-dependency-glob: "pyproject.toml" # Invalidate cache on pyproject changes
- name: Install dependencies and project
run: |
uv sync --all-extras --dev # Sync dev dependencies and extras
uv pip install -e . # Install the project itself
uv pip install ruff pytest hatch # Install tools explicitly
shell: bash
- name: Lint with Ruff
run: uv run ruff check . # Use uv run
shell: bash
- name: Check formatting with Ruff
run: uv run ruff format . --check # Use uv run
shell: bash
- name: Test with pytest
run: uv run pytest # Use uv run
shell: bash
publish:
name: Publish to PyPI
needs: [build] # Run only after the build job succeeds
runs-on: ubuntu-latest
# Run only on tagged commits
if: startsWith(github.ref, 'refs/tags/')
permissions:
# IMPORTANT: mandatory for trusted publishing
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10" # Use a specific Python version
- name: Install uv and Hatch
uses: astral-sh/setup-uv@v5 # Use v5 of the action
with:
version: "0.6.12" # Pin uv version
- name: Install dependencies and Hatch
run: |
uv sync --dev # Sync dev dependencies
uv pip install -e . # Install the project itself
uv pip install hatch # Install hatch
shell: bash
- name: Build package
run: uv run hatch build # Use uv run, Uses hatchling backend specified in pyproject.toml
shell: bash
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# Trusted publishing automatically uses OIDC, no API token needed
build-executables:
name: Build Executables
needs: [build]
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, ubuntu-22.04-arm, macos-latest, macos-13]
include:
- os: windows-latest
exe_name: hirebase-mcp-windows
python_arch: x64
- os: ubuntu-latest
exe_name: hirebase-mcp-linux-x64
python_arch: x64
- os: ubuntu-22.04-arm
exe_name: hirebase-mcp-linux-arm64
python_arch: arm64
- os: macos-latest
exe_name: hirebase-mcp-macos-arm64
python_arch: arm64
- os: macos-13
exe_name: hirebase-mcp-macos-x64
python_arch: x64
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v5 # Use v5 of the action
with:
version: "0.6.12" # Pin uv version
- name: Install dependencies
run: |
uv sync --all-extras --dev # Sync dev dependencies and extras
uv pip install -e . # Install the project itself
shell: bash
- name: Create PyInstaller Package
uses: sayyid5416/pyinstaller@v1
with:
spec: src/__init__.py
python_ver: '3.12'
python_arch: ${{ matrix.python_arch }}
options: --onefile, --name ${{ matrix.exe_name }}, --add-data "src:src"
upload_exe_with_name: ${{ matrix.exe_name }}
create-release:
name: Create GitHub Release
needs: [build-executables]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write # Needed to create releases
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
files: |
artifacts/hirebase-mcp-windows/*
artifacts/hirebase-mcp-linux-x64/*
artifacts/hirebase-mcp-linux-arm64/*
artifacts/hirebase-mcp-macos-arm64/*
artifacts/hirebase-mcp-macos-x64/*