2.2.0rc6 #24
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and upload to PyPI | |
on: | |
workflow_dispatch: # run on request (no need for PR) | |
release: | |
types: [published] | |
# Declare default permissions as read only. | |
permissions: read-all | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 | |
with: | |
python-version: "3.10" | |
- name: Install pypa/build | |
run: | | |
python -m pip install --require-hashes --no-deps -r .ci/requirements.txt | |
pip-compile --generate-hashes --output-file=/tmp/requirements.txt --extra=ci_publish pyproject.toml | |
python -m pip install --require-hashes --no-deps -r /tmp/requirements.txt | |
rm /tmp/requirements.txt | |
- name: Build sdist | |
run: python -m build --sdist | |
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 | |
with: | |
name: artifact-sdist | |
path: dist/*.tar.gz | |
- name: Build wheel | |
run: python -m build --wheel | |
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 | |
with: | |
name: artifact-wheel | |
path: dist/*.whl | |
publish_package: | |
name: Publish package | |
needs: [build] | |
environment: pypi | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: write | |
id-token: write | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3 | |
with: | |
path: dist | |
pattern: artifact-* | |
merge-multiple: true | |
# to determine where to publish the package distribution to PyPI or TestPyPI | |
- name: Check tag | |
id: check-tag | |
uses: actions-ecosystem/action-regex-match@9e6c4fb3d5e898f505be7a1fb6e7b0a278f6665b # v2.0.2 | |
with: | |
text: ${{ github.ref }} | |
regex: '^refs/tags/[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+rc[0-9]+|rc[0-9]+)?$' | |
- name: Upload package distributions to github | |
if: ${{ steps.check-tag.outputs.match != '' }} | |
uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: dist/* | |
tag: ${{ github.ref }} | |
overwrite: true | |
file_glob: true | |
- name: Publish package distributions to PyPI | |
if: ${{ steps.check-tag.outputs.match != '' }} | |
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0 | |
- name: Publish package distributions to TestPyPI | |
if: ${{ steps.check-tag.outputs.match == '' }} | |
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
verbose: true |