Skip to content

Merge pull request #14 from jentic/fix/preserve-enum-on-depth-limit #8

Merge pull request #14 from jentic/fix/preserve-enum-on-depth-limit

Merge pull request #14 from jentic/fix/preserve-enum-on-depth-limit #8

# This workflow is triggered on push events but only for the arazzo_runner directory.
# It builds and publishes the arazzo-runner to PyPI and TestPyPI.
name: Publish Python distribution of the arazzo-runner to PyPI and TestPyPI
on:
push:
branches:
- main
paths:
- "runner/arazzo_runner/**"
- "runner/pyproject.toml"
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
version_changed: ${{ steps.check.outputs.changed }}
steps:
- uses: actions/checkout@v4
- name: Get current version
id: get_version
run: |
VERSION=$(grep '^version =' runner/pyproject.toml | sed -E 's/version = "([^"]+)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Get published version from PyPI
id: get_pypi_version
run: |
PKG_NAME=$(grep '^name =' runner/pyproject.toml | sed -E 's/name = "([^"]+)"/\1/')
PYPI_VERSION=$(curl -s https://pypi.org/pypi/$PKG_NAME/json | jq -r .info.version)
echo "pypi_version=$PYPI_VERSION" >> $GITHUB_OUTPUT
- name: Check if version changed
id: check
run: |
if [ "${{ steps.get_version.outputs.version }}" = "${{ steps.get_pypi_version.outputs.pypi_version }}" ]; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
build:
name: Build distribution 📦
runs-on: ubuntu-latest
needs: check-version
if: needs.check-version.outputs.version_changed == 'true'
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build runner
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: runner/dist/
publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
- check-version
if: needs.check-version.outputs.version_changed == 'true'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/arazzo-runner # 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:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
- check-version
if: needs.check-version.outputs.version_changed == 'true'
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/arazzo-runner
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/