Skip to content

Automate PyPi Publishing on Github Release #682

@derks

Description

@derks

The following was removed from PR #681 in order to give it more thought and testing:

.github/workflows/pythonpublish.yml

name: Upload Python Package

on:
  release:
    types: [published]

permissions:
  id-token: write # trusted publishing
  contents: read

jobs:
  deploy:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - 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 package
        run: python -m build
      - name: Publish a Python distribution to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1

PR comments from @sigma67:

I added this to simplify pypi uploads - I use the same workflow in my projects

All you need to do is create a release and the rest will be taken care of by pypi

All you need to do is set up trusted publishing in your pypi settings (not hard to do)

https://docs.pypi.org/trusted-publishers/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions