Skip to content

Release Workflow

Release Workflow #7

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
run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Extract tag version without pre-release identifiers
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
CLEAN_TAG_VERSION=$(echo $TAG_VERSION | awk -F- '{print $1}')
echo $CLEAN_TAG_VERSION
echo "CLEAN_TAG_VERSION=$CLEAN_TAG_VERSION" >> $GITHUB_ENV
- name: Get current package version
run: |
PACKAGE_VERSION=$(poetry version --short)
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
- name: Verify versions match
run: |
if [ "$CLEAN_TAG_VERSION" != "$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 $TAG_VERSION"
poetry version "$TAG_VERSION"
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry build
poetry publish