pypi-publish.ymlβ’2.27 kB
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Publish to PyPI on tag
on:
push:
tags: ["*"]
permissions:
contents: read
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set tag version
run: |
VERSION=${GITHUB_REF##refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Inject version into pyproject.toml
run: sed -i "s|^version = \".*\"|version = \"${VERSION}\"|" pyproject.toml
# - name: Replace mcp-config.json for PyPI
# run: cp -f mcp-config.json.pypi mcp-config.json
- uses: actions/setup-python@v6
with:
python-version: "3.12.x"
- name: Install build tool
run: pip install --upgrade build
- name: Build distributions
run: python -m build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
publish-to-testpypi:
name: Publish to TestPyPI
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: build
permissions:
id-token: write
environment:
name: testpypi
url: https://test.pypi.org/project/mcp-ambari-api
steps:
- uses: actions/download-artifact@v5
with:
name: dist
path: dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: build
#needs: publish-to-testpypi
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/project/mcp-ambari-api
steps:
- uses: actions/download-artifact@v5
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://upload.pypi.org/legacy/