Skip to content

Publish Python 🐍 distribution πŸ“¦ to PyPI #2

Publish Python 🐍 distribution πŸ“¦ to PyPI

Publish Python 🐍 distribution πŸ“¦ to PyPI #2

name: Publish Python 🐍 distribution πŸ“¦ to PyPI
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]' # only run non-alpha tags
jobs:
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build SDist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
build_wheels-manylinux:
name: Build wheels on ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BEFORE_ALL_LINUX: >
yum update &&
yum install -y gmp-devel
CIBW_BUILD: cp39-manylinux* cp310-manylinux* cp311-manylinux* cp312-manylinux* cp313-manylinux*
CIBW_ENVIRONMENT_LINUX: CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-manylinux
path: ./wheelhouse/*.whl
# macos-13 is an intel runner
build_wheels-macos-13:
name: Build wheels on macos-13
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-*
CIBW_ENVIRONMENT_MACOS: CFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib"
MACOSX_DEPLOYMENT_TARGET: 13.0
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-macos-13
path: ./wheelhouse/*.whl
# macos-14 is apple silicon
build_wheels-macos-14:
name: Build wheels on macos-14
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-*
CIBW_ENVIRONMENT_MACOS: CFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib"
MACOSX_DEPLOYMENT_TARGET: 14.0
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-macos-14
path: ./wheelhouse/*.whl
publish-to-pypi:
name: Publish Python 🐍 distribution πŸ“¦ to PyPI
needs: [make_sdist, build_wheels-manylinux, build_wheels-macos-13, build_wheels-macos-14]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/fastecdsa # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist/
merge-multiple: true
- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
github-release:
name: >-
Sign the Python 🐍 distribution πŸ“¦ with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist/
merge-multiple: true
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
"$GITHUB_REF_NAME"
--repo "$GITHUB_REPOSITORY"
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
"$GITHUB_REF_NAME" dist/**
--repo "$GITHUB_REPOSITORY"