ci(pypi): publish to pypi

This commit is contained in:
Fangyin Cheng
2025-03-20 15:01:46 +08:00
parent da8559d98e
commit 856ad8f8a6

View File

@@ -17,6 +17,17 @@ on:
description: 'Package version (e.g. 0.7.0rc0)'
required: true
type: string
publish_to_testpypi:
description: 'Publish to TestPyPI'
required: false
type: boolean
default: false
publish_to_pypi:
description: 'Publish to PyPI'
required: false
type: boolean
default: false
permissions:
contents: read
@@ -47,6 +58,7 @@ jobs:
else
echo "Prepping package for release"
fi
- name: Install the project
run: uv sync --all-packages --dev
@@ -62,14 +74,15 @@ jobs:
path: dist/*
retention-days: 7
# - name: Publish package to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
# - name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish package to TestPyPI
if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish_to_testpypi == true }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish package distributions to PyPI
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.publish_to_pypi == true) }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}