Publish Python 🐍 distributions 📦 to TestPyPI #49
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
# publish a python package to the test pipy registry - await until the generate clients finishes | |
name: Publish Python 🐍 distributions 📦 to TestPyPI | |
#----------------------------------------------------------------------------------- | |
# Push to TestPyPI unconditionally (need to rev version, del/yank ver will not work) | |
# | |
# For testing use: | |
# on: push | |
# NOTE: | |
# The workflow may fail the first time the clients are generate as it does not wait | |
# for the [Generate OpenAPI Clients] to complete before it executes. | |
# Don't use final ver number when testing, it will fail when published based on the | |
# workflows: [Generate OpenAPI Clients]) | |
# | |
# Once test is completed use: | |
# on: | |
# workflow_run: | |
# workflows: [Generate OpenAPI Clients] | |
# types: | |
# - completed | |
#----------------------------------------------------------------------------------- | |
on: | |
workflow_run: | |
workflows: [Generate OpenAPI Clients] | |
types: | |
- completed | |
# on: push | |
jobs: | |
build-n-publish: | |
name: Build and publish Python 🐍 distributions 📦 to TestPyPI | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout your code | |
- uses: actions/checkout@v4 | |
# Check for changed files (looking for changes to the src/python_client/README.md) file) | |
- name: Get changed file (src/python_client/README.md) 🔧 | |
id: changed-files | |
uses: tj-actions/changed-files@v39 | |
# Only if the client version has changed | |
- name: Set up Python | |
if: contains(steps.changed-files.outputs.modified_files, 'src/python_client/README.md') | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: Install pypa/build | |
if: contains(steps.changed-files.outputs.modified_files, 'src/python_client/README.md') | |
run: | | |
python -m pip install build --user | |
- name: Build a binary wheel and a source tarball | |
if: contains(steps.changed-files.outputs.modified_files, 'src/python_client/README.md') | |
run: | | |
cd src/python_client | |
python -m build --sdist --wheel --outdir dist/ | |
- name: Publish distribution 📦 to Test PyPI | |
if: contains(steps.changed-files.outputs.modified_files, 'src/python_client/README.md') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: src/python_client/dist/ | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ |