Skip to content

Publish Python Packages #1

Publish Python Packages

Publish Python Packages #1

Workflow file for this run

name: Publish Python Packages
on:
workflow_dispatch:
inputs:
packages:
description: 'Which packages to publish'
required: true
default: 'all'
type: choice
options:
- all
- ison-py
- isonantic
dry_run:
description: 'Dry run (no actual publish)'
required: false
default: false
type: boolean
jobs:
publish-ison-py:
name: Publish ison-py
runs-on: ubuntu-latest
if: ${{ inputs.packages == 'all' || inputs.packages == 'ison-py' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
working-directory: ison-py
run: python -m build
- name: Check package
working-directory: ison-py
run: twine check dist/*
- name: Publish to PyPI
if: ${{ inputs.dry_run != true }}
working-directory: ison-py
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*
- name: Dry run - show what would be published
if: ${{ inputs.dry_run == true }}
working-directory: ison-py
run: |
echo "Would publish:"
ls -la dist/
publish-isonantic:
name: Publish isonantic
runs-on: ubuntu-latest
needs: publish-ison-py
if: ${{ always() && (inputs.packages == 'all' || inputs.packages == 'isonantic') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Wait for PyPI propagation
if: ${{ inputs.packages == 'all' && inputs.dry_run != true }}
run: sleep 60
- name: Build package
working-directory: isonantic
run: python -m build
- name: Check package
working-directory: isonantic
run: twine check dist/*
- name: Publish to PyPI
if: ${{ inputs.dry_run != true }}
working-directory: isonantic
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*
- name: Dry run - show what would be published
if: ${{ inputs.dry_run == true }}
working-directory: isonantic
run: |
echo "Would publish:"
ls -la dist/