Skip to content

Publish Python Package to PyPI #7

Publish Python Package to PyPI

Publish Python Package to PyPI #7

name: Publish Python Package to PyPI
on:
release:
types: [created]
workflow_run:
workflows: ["Bump Version"]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'release' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')) && github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || 'main' }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install uv twine toml
- name: Build package
run: |
rm -rf dist/
uv build --no-sources
- name: Check distribution with twine
run: |
twine check dist/*
- name: Publish to PyPI
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/* -u __token__ -p $PYPI_API_TOKEN
- name: Extract package version
id: get_version
run: |
PACKAGE_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
echo "version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
- name: Notify Slack about PyPI release
id: slack
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
slack-message: |
:rocket: *New Release Published to PyPI!*
*Package:* codelogic-mcp-server v${{ steps.get_version.outputs.version }}
*Published by:* ${{ github.actor }}
:link: <https://pypi.org/project/codelogic-mcp-server/${{ steps.get_version.outputs.version }}|View on PyPI>
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}