Build package & release to PyPI #3
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
# Publish a release to PyPI | |
# Requires build package workflow to run first | |
# This version releases to https://pypi.org/, only trigger if the release has been thorough tested | |
name: Build package & release to PyPI | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "Select release to publish" | |
required: true | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.tag }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build a source tarball | |
run: python -m build --sdist | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v4.3.0 | |
with: | |
name: python-package-distributions-${{ inputs.tag }} | |
path: dist/ | |
publish: | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi-publish | |
url: https://pypi.org/p/medpy | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download dists | |
uses: actions/download-artifact@v4.1.1 # make sure that same major version as actions/upload-artifact | |
with: | |
name: python-package-distributions-${{ inputs.tag }} | |
path: dist/ | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@v1.8.11 |