2024-03-19 12:45:34 -04:00
# This workflow will upload a Python Package to PyPI when a release is created
2022-10-10 11:12:22 +00:00
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
2020-02-20 13:59:00 -05:00
2021-06-03 10:55:41 -04:00
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
2019-08-25 01:13:29 +01:00
name : Upload Python Package
2019-09-05 12:10:28 +01:00
on :
release :
2021-06-03 10:55:41 -04:00
types : [ published]
2019-08-25 01:13:29 +01:00
2024-03-19 16:41:37 -04:00
permissions :
contents : read
2019-08-25 01:13:29 +01:00
jobs :
2024-03-19 12:45:34 -04:00
release-build :
runs-on : ubuntu-latest
steps :
- uses : actions/checkout@v4
2020-02-21 12:55:06 -05:00
2024-03-19 12:45:34 -04:00
- uses : actions/setup-python@v5
with :
python-version : "3.x"
2024-03-19 15:40:07 -04:00
- name : Build release distributions
2024-03-19 12:45:34 -04:00
run : |
# NOTE: put your own distribution build steps here.
python -m pip install build
python -m build
2024-03-19 15:40:07 -04:00
- name : Upload distributions
2024-03-19 12:45:34 -04:00
uses : actions/upload-artifact@v4
with :
name : release-dists
path : dist/
pypi-publish :
2019-08-25 01:13:29 +01:00
runs-on : ubuntu-latest
2024-03-19 12:45:34 -04:00
needs :
- release-build
permissions :
2024-03-19 16:42:35 -04:00
# IMPORTANT: this permission is mandatory for trusted publishing
2024-03-19 12:45:34 -04:00
id-token : write
2020-02-21 12:55:06 -05:00
2024-03-19 16:57:58 -04:00
# Dedicated environments with protections for publishing are strongly recommended.
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
environment :
name : pypi
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
# url: https://pypi.org/p/YOURPROJECT
2024-08-20 13:39:26 -04:00
#
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
# ALTERNATIVE: exactly, uncomment the following line instead:
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
2024-03-19 16:57:58 -04:00
2019-08-25 01:13:29 +01:00
steps :
2024-03-19 12:45:34 -04:00
- name : Retrieve release distributions
uses : actions/download-artifact@v4
with :
name : release-dists
path : dist/
- name : Publish release distributions to PyPI
2024-11-22 09:48:05 -05:00
uses : pypa/gh-action-pypi-publish@release/v1
2024-11-22 09:47:32 -05:00
with :
packages-dir : dist/