Skip to content

Publish to PyPI

Publish to PyPI #2

Workflow file for this run

# New release tags trigger this workflow to publish to test.pypi.org.
# If that looks good, a `workflow_dispatch` can be used to publish to pypi.org (with `prod-pypi` set to 'true').
name: Publish to PyPI
on:
push:
tags:
- 'v[0-9]+*'
workflow_dispatch:
inputs:
prod-pypi:
type: boolean
description: 'Publish to pypi.org (default: test.pypi.org)'
jobs:
build:
name: Build package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11.11'
- name: Build package
run: |
pip install build
python -m build
ls -l dist
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
retention-days: 1
publish:
name: Upload release to PyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://${{ inputs.prod-pypi && '' || 'test.' }}pypi.org/p/tiledbsoma_ml # Displayed in GHA UI
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish package distributions to ${{ inputs.prod-pypi && '' || 'test ' }}PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ inputs.prod-pypi && '' || 'https://test.pypi.org/legacy/' }}