Release to PyPI #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release to PyPI | |
on: | |
push: | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+' | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: "Setup Python, Poetry and Dependencies" | |
uses: packetcoders/action-setup-cache-python-poetry@main | |
with: | |
python-version: "${{ vars.PRIMARY_PYTHON_VERSION }}" | |
poetry-version: "${{ vars.POETRY_VERSION }}" | |
- name: Install Task | |
run: | | |
sudo sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin | |
- name: Install the library | |
run: poetry install --no-interaction --only-root | |
- name: Run CI-CD-checks | |
run: poetry run task ci-cd-checks | |
- name: Publish package | |
run: | | |
# Use GitHub's run_number as a post-release version identifier | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" || "${{ github.ref }}" == 'refs/heads/main' ]]; then | |
POETRY_VERSION=$(poetry version | awk '{print $2}') | |
NEW_VERSION="${POETRY_VERSION}.post${{ github.run_number }}" | |
poetry version "${NEW_VERSION}" | |
fi | |
poetry build | |
poetry publish --username __token__ --password ${{ secrets.PUBLIC_PYPI_API_TOKEN }} |