name: Publish to PyPI
on:
push:
branches: [ "main" ]
release:
types: [ published ]
permissions:
contents: read
id-token: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/mcp-openapi-proxy/
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build wheel twine setuptools
- name: Bump version automatically
run: |
NEW_VERSION=$(python -c "import time; print('0.1.' + str(int(time.time())))")
echo "Updating version to $NEW_VERSION"
sed -i "s/^version = .*/version = \"$NEW_VERSION\"/" pyproject.toml
- name: Build package artifacts
run: python -m build
- name: Validate package structure
run: twine check dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://upload.pypi.org/legacy/
password: ${{ secrets.PYPI_API_TOKEN }}
attestations: false
twine-args: --verbose