Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci/python-publish: bump, use trusted publishing #2345

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
56 changes: 35 additions & 21 deletions ci/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow will upload a Python Package using Twine when a release is created
# This workflow will upload a Python Package to PyPI when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

Copy link

@webknjaz webknjaz Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not against some policy, let's link https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ (additionally) — we're trying to keep it up-to-date over in PyPUG, which often happens sooner than GH gets docs updated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. I'll defer to GH folks for any actual policy here 🙂

# This workflow uses actions that are not certified by GitHub.
Expand All @@ -12,28 +12,42 @@ on:
release:
types: [published]

permissions:
contents: read
woodruffw marked this conversation as resolved.
Show resolved Hide resolved

jobs:
deploy:
release-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: build release distributions
run: |
woodruffw marked this conversation as resolved.
Show resolved Hide resolved
# NOTE: put your own distribution build steps here.
python -m pip install build
python -m build

woodruffw marked this conversation as resolved.
Show resolved Hide resolved
- name: upload distributions
uses: actions/upload-artifact@v4
woodruffw marked this conversation as resolved.
Show resolved Hide resolved
with:
name: release-dists
path: dist/

pypi-publish:
runs-on: ubuntu-latest
needs:
- release-build
permissions:
id-token: write
woodruffw marked this conversation as resolved.
Show resolved Hide resolved

woodruffw marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/

- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
woodruffw marked this conversation as resolved.
Show resolved Hide resolved