Skip to content

Release Workflow

Release Workflow #2

Workflow file for this run

name: Release Workflow
on:
release:
types: [published]
jobs:
verify-and-publish:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install Poetry
run: pip install poetry
- name: Extract tag version
id: get_tag_version
run: echo "::set-output name=tag_version::${GITHUB_REF#refs/tags/v}"
- name: Extract tag version without pre-release identifiers
id: get_tag_version_clean
run: |
# This extracts the version number and removes any pre-release identifiers like '-rc1'
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
CLEAN_TAG_VERSION="${TAG_VERSION%%-*}"
echo "::set-output name=clean_tag_version::$CLEAN_TAG_VERSION"
- name: Get current package version
id: get_package_version
run: echo "::set-output name=package_version::$(poetry version --short)"
- name: Verify versions match
run: |
if [ "${{ steps.get_tag_version.outputs.clean_tag_version }}" != "${{ steps.get_package_version.outputs.package_version }}" ]; then
echo "Error: Tag version does not match the pyproject.toml version"
exit 1
fi
- name: Set version to match the release tag
run: |
echo "Setting package version to ${{ steps.get_tag_version.outputs.clean_tag_version }}"
poetry version "${{ steps.get_tag_version.outputs.clean_tag_version }}""
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry build
poetry publish