Merge pull request #50 from mammo0/dependabot/pip/pytest-8.0.0 #174
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: PyPI package | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- v* | |
pull_request: | |
jobs: | |
test: | |
name: Test package | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.8', '3.9', '3.10', '3.11'] | |
steps: | |
# checkout the repo | |
- uses: actions/checkout@v4 | |
# setup python environment | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set up Poetry | |
uses: abatilo/actions-poetry@v2 | |
# install the test dependencies | |
- name: Install test dependencies | |
run: | | |
poetry install | |
- name: Test package | |
run: | | |
poetry run pytest | |
build-publish: | |
name: Build and publish package | |
if: ${{ github.event_name == 'push' }} | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
# checkout the repo | |
- uses: actions/checkout@v4 | |
with: | |
# fetch complete history because it's needed by Poetry | |
fetch-depth: 0 | |
# setup python environment | |
- name: Set up Python 3.7 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.7" | |
- name: Set up Poetry | |
uses: abatilo/actions-poetry@v2 | |
- name: Add dynamic versioning plugin | |
run: | | |
poetry self add "poetry-dynamic-versioning[plugin]" | |
# build the package | |
- name: Build package | |
run: | | |
poetry build | |
# on a regular push publish the package to test PyPI repo | |
- name: Publish test package | |
env: | |
PYPI_TEST_TOKEN: ${{ secrets.PYPI_TEST_TOKEN }} | |
run: | | |
poetry config repositories.test-pypi https://test.pypi.org/legacy/ | |
poetry config pypi-token.test-pypi $PYPI_TEST_TOKEN | |
poetry publish -r test-pypi | |
# on a release push publish the package to the regular PyPI repo | |
- name: Publish release package | |
if: startsWith(github.event.ref, 'refs/tags') | |
env: | |
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
poetry config pypi-token.pypi $PYPI_TOKEN | |
poetry publish |