Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
release: | |
types: [published] | |
jobs: | |
pypi-publish: | |
name: Upload release to PyPI | |
runs-on: ubuntu-latest | |
environment: | |
name: release | |
url: https://pypi.org/project/pyvsnr | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install build and twine | |
run: | | |
python -m pip install --upgrade pip | |
pip install build twine | |
- name: Build package | |
run: | | |
python -m build | |
- name: Check package with Twine | |
run: | | |
twine check dist/* | |
- name: Determine PyPI repository | |
run: | | |
if [[ ${{ github.event.release.prerelease }} == 'true' ]]; then | |
echo "REPOSITORY_URL=https://test.pypi.org/legacy/" >> $GITHUB_ENV | |
echo "PYPI_API_TOKEN=${{ secrets.TEST_PYPI_API_TOKEN }}" >> $GITHUB_ENV | |
else | |
echo "REPOSITORY_URL=https://upload.pypi.org/legacy/" >> $GITHUB_ENV | |
echo "PYPI_API_TOKEN=${{ secrets.PYPI_API_TOKEN }}" >> $GITHUB_ENV | |
fi | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@v1.9.0 | |
with: | |
repository-url: ${{ env.REPOSITORY_URL }} | |
user: __token__ | |
password: ${{ env.PYPI_API_TOKEN }} |