| 1 |
name: Publish Python 🐍 distribution 📦 to PyPI |
| 2 |
|
| 3 |
on: |
| 4 |
pull_request: |
| 5 |
push: |
| 6 |
branches: |
| 7 |
- main |
| 8 |
release: |
| 9 |
types: |
| 10 |
- published |
| 11 |
|
| 12 |
permissions: |
| 13 |
contents: read |
| 14 |
|
| 15 |
concurrency: |
| 16 |
group: ${{ github.workflow }}-${{ github.ref }} |
| 17 |
cancel-in-progress: true |
| 18 |
|
| 19 |
jobs: |
| 20 |
build: |
| 21 |
name: Build distribution 📦 |
| 22 |
runs-on: ubuntu-latest |
| 23 |
steps: |
| 24 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 25 |
with: |
| 26 |
fetch-depth: 0 |
| 27 |
persist-credentials: false |
| 28 |
|
| 29 |
- name: Set up Python |
| 30 |
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 |
| 31 |
with: |
| 32 |
python-version: "3.13" |
| 33 |
|
| 34 |
- name: Build sdist and wheel |
| 35 |
run: pipx run --spec build==1.5.0 pyproject-build --sdist --wheel --outdir dist |
| 36 |
|
| 37 |
- name: Check distributions |
| 38 |
working-directory: dist |
| 39 |
run: | |
| 40 |
ls -alh |
| 41 |
python -m pip install *.whl |
| 42 |
pipx run --spec twine==6.2.0 twine check * |
| 43 |
|
| 44 |
- name: Upload distributions 📦 |
| 45 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 46 |
with: |
| 47 |
name: dist |
| 48 |
path: dist/ |
| 49 |
|
| 50 |
publish: |
| 51 |
name: Publish Python 🐍 distribution 📦 to PyPI |
| 52 |
runs-on: ubuntu-latest |
| 53 |
if: github.event_name == 'release' |
| 54 |
needs: [build] |
| 55 |
permissions: |
| 56 |
id-token: write |
| 57 |
environment: |
| 58 |
name: pypi |
| 59 |
url: https://pypi.org/p/conda-package-handling |
| 60 |
|
| 61 |
steps: |
| 62 |
- name: Retrieve distributions |
| 63 |
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 64 |
with: |
| 65 |
name: dist |
| 66 |
path: dist/ |
| 67 |
|
| 68 |
- name: Publish distribution 📦 to PyPI |
| 69 |
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 |
| 70 |
with: |
| 71 |
packages-dir: dist/ |
| 72 |
|
| 73 |
upload-release-assets: |
| 74 |
name: Upload release assets |
| 75 |
runs-on: ubuntu-latest |
| 76 |
if: github.event_name == 'release' |
| 77 |
needs: [publish] |
| 78 |
permissions: |
| 79 |
contents: write |
| 80 |
|
| 81 |
steps: |
| 82 |
- name: Retrieve distributions |
| 83 |
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 84 |
with: |
| 85 |
name: dist |
| 86 |
path: dist/ |
| 87 |
|
| 88 |
- name: Upload assets to GitHub Release |
| 89 |
env: |
| 90 |
GH_TOKEN: ${{ github.token }} |
| 91 |
GH_REPO: ${{ github.repository }} |
| 92 |
TAG_NAME: ${{ github.event.release.tag_name }} |
| 93 |
run: gh release upload "$TAG_NAME" dist/* --repo "$GH_REPO" |