Skip to content

Publish

Publish #43

Workflow file for this run

name: "Publish"
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]"
# Alpha versions
- "v[0-9]+.[0-9]+.[0-9]a[0-9]+"
workflow_dispatch:
inputs:
branch:
description: Branch that contains the release
type: string
default: main
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
if: github.event_name == 'push'
- uses: actions/checkout@v3
if: github.event_name == 'workflow_dispatch'
with:
ref: ${{ inputs.branch }}
- name: Install Poetry
run: pipx install poetry==1.8.3
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install --all-extras
- name: Check package version matches tag
if: github.event_name == 'push'
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(poetry version -s)
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "Error: Tag version ($TAG_VERSION) does not match package version ($PACKAGE_VERSION)"
exit 1
fi
- name: Check that version is alpha version
if: github.event_name == 'workflow_dispatch'
run: |
PACKAGE_VERSION=$(poetry version -s)
if [[ ! "$PACKAGE_VERSION" =~ .*(a|dev)[0-9]+$ ]]; then
echo "Error: Package version ($PACKAGE_VERSION) is not an alpha version (should end with 'aN' or 'devN' where N is a number)"
exit 1
fi
- name: Build Python package
run: poetry build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
print-hash: true