Skip to content

Modernize MCP Server (#9) #12

Modernize MCP Server (#9)

Modernize MCP Server (#9) #12

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
test-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Check uv.lock is up to date
run: uv lock --check
- name: Install dependencies
run: uv sync --dev
- name: Run tests
run: uv run pytest -v --tb=short
- name: Run type checking
run: uv run mypy src
- name: Run linting
run: uv run ruff check .
- name: Check formatting
run: uv run ruff format --check
build:
runs-on: ubuntu-latest
needs: test-release
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python
run: uv python install 3.11
- name: Validate tag matches pyproject.toml version
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
if [ "$TAG_VERSION" != "$PYPROJECT_VERSION" ]; then
echo "Error: Tag version ($TAG_VERSION) does not match pyproject.toml version ($PYPROJECT_VERSION)"
exit 1
fi
echo "Version validation passed: $TAG_VERSION"
- name: Install dependencies
run: uv sync --dev
- name: Run tests
run: uv run pytest
- name: Build package
run: uv build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
publish-pypi:
runs-on: ubuntu-latest
needs: build
environment:
name: pypi
url: https://pypi.org/project/largefile/
steps:
- name: Check if version exists on PyPI
id: pypi_check
run: |
VERSION=${GITHUB_REF#refs/tags/v}
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --retry 3 "https://pypi.org/pypi/largefile/${VERSION}/json")
if [ "$STATUS" = "200" ]; then
echo "Version $VERSION already exists on PyPI, skipping publish"
echo "exists=true" >> "$GITHUB_OUTPUT"
elif [ "$STATUS" = "404" ]; then
echo "Version $VERSION not found on PyPI, will publish"
echo "exists=false" >> "$GITHUB_OUTPUT"
else
echo "::warning::Unexpected status $STATUS from PyPI for version $VERSION, attempting publish anyway"
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Download build artifacts
if: steps.pypi_check.outputs.exists == 'false'
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Install uv
if: steps.pypi_check.outputs.exists == 'false'
uses: astral-sh/setup-uv@v6
- name: Publish to PyPI
if: steps.pypi_check.outputs.exists == 'false'
run: uv publish dist/*
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}