Skip to content

Instantly share code, notes, and snippets.

@jhj0517
Created December 27, 2024 08:43
Show Gist options
  • Save jhj0517/6679122dd29991e8d2c97fdef651fefa to your computer and use it in GitHub Desktop.
Save jhj0517/6679122dd29991e8d2c97fdef651fefa to your computer and use it in GitHub Desktop.
publish-pypi.yml
# This workflow is an automated CD to the DockerHub. The trigger is disabled by default, you can edit the trigger in the `on` section if you want.
name: Publish to PyPI
on:
workflow_dispatch:
# Uncomment the following line to trigger the workflow when you make "release" in the repository
# release:
# types: [created]
jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
# Update URL with your package name
url: https://pypi.org/p/package-name
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish package distributions to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment