Skip to content

Publish Python 🐍 distribution 📦 to PyPI and TestPyPI #562

Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

Publish Python 🐍 distribution 📦 to PyPI and TestPyPI #562

Workflow file for this run

name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
on:
workflow_dispatch:
push:
branches: ["**"]
tags-ignore: ["**"]
pull_request:
release:
types:
- published
jobs:
build_wheels:
name: Build wheels [${{ matrix.os }}]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
os:
- ubuntu-22.04
steps:
- uses: actions/checkout@master
- run: git fetch --prune --unshallow
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install pypa/build
run: pip install build
- name: Build wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- name: Create a File
run: echo "{{ matrix.os }}" > file-${{ matrix.os }}.txt
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}
path: file-${{ matrix.os }}.txt
deploy_test_PyPI:
name: 📦 Deploy to TestPyPI
needs: build_wheels
runs-on: ubuntu-22.04
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
pattern: dist-*
merge-multiple: true
- run: ls -R dist
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
skip-existing: true
deploy_PyPI:
name: 📦 Deploy to PyPI
runs-on: ubuntu-22.04
needs: build_wheels
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
pattern: dist-*
merge-multiple: true
- run: ls -R dist
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true