Skip to content

Publish Python 🐍 distributions 📦 to PyPI/TestPyPI #45

Publish Python 🐍 distributions 📦 to PyPI/TestPyPI

Publish Python 🐍 distributions 📦 to PyPI/TestPyPI #45

# follows https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
name: Publish Python 🐍 distributions 📦 to PyPI/TestPyPI
on:
workflow_dispatch:
inputs:
releasetype:
description: "Is this a 'release' or a 'test'?"
required: true
default: 'test'
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- name: Display phase
run: echo "Deploying "${{github.event.inputs.releasetype}}" $INPUT_RELEASETYPE to PyPI"
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install build tool
run: pip install build
- name: Build a test source tarball
if: github.event.inputs.releasetype == 'test'
run: |
export PYTERRIER_VERSION_SUFFIX=".`date +%s`"
sed -Ei "1 s/'\$/.$PYTERRIER_VERSION_SUFFIX'/g" pyterrier/__init__.py
head -n 1 pyterrier/__init__.py
- name: Build a source tarball
if: github.event.inputs.releasetype == 'release'
run: python -m build
- name: Publish distribution 📦 to Test PyPI
if: github.event.inputs.releasetype == 'test'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.test_pypi_password }}
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: github.event.inputs.releasetype == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.pypi_password }}