Skip to content

Merge pull request #845 from projectsyn/renovate/black-23.x #2040

Merge pull request #845 from projectsyn/renovate/black-23.x

Merge pull request #845 from projectsyn/renovate/black-23.x #2040

Workflow file for this run

name: PyPI release
on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
jobs:
build-and-publish:
# Skip job on forks
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false
name: Build and publish to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- uses: Gr1N/setup-poetry@v8
- uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-publish-pypi-${{ hashFiles('poetry.lock') }}
- name: Setup poetry environment
run: |
poetry install
- name: Inject package versions to action env
run: make inject-version
- name: Set Python package version for release
if: startsWith(github.ref, 'refs/tags/v')
run: poetry version "${PYVERSION}"
- name: Set Python package version
if: "!startsWith(github.ref, 'refs/tags/v')"
run: |
poetry version "${PYVERSION}.dev${GITHUB_RUN_NUMBER}"
- name: Build Python package
run: poetry build
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v')
run: poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }}
- name: Publish to TestPyPI
if: "!startsWith(github.ref, 'refs/tags/v')"
run: |
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry publish -r test-pypi -u __token__ -p ${{ secrets.TEST_PYPI_TOKEN }}