Skip to content

v0.1.1

v0.1.1 #20

Workflow file for this run

name: Build and Publish Python Package
on:
workflow_dispatch:
inputs:
version:
description: "Version to use for the Python package (e.g. 0.1.0)"
required: true
type: string
test-pypi:
description: "Publish to Test PyPI"
required: false
type: boolean
default: false
release:
types: [published]
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
id-token: write # mandatory for Pypi trusted publishing
contents: read
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- name: Install build dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install .[dev]
- name: Get version
id: get_version
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION="${{ github.event.inputs.version }}"
fi
VERSION=${VERSION#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build
env:
VERSION: ${{ steps.get_version.outputs.version }}
run: |
python -m build --wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
verbose: true
# Avoid workflow to fail if the version has already been published
skip-existing: true
# Upload to Test Pypi for testing
repository-url: ${{ github.event.inputs.test-pypi == 'true' && 'https://test.pypi.org/legacy/' || '' }}