Skip to content

v0.8.4 - Sep 9, 2024 #5

v0.8.4 - Sep 9, 2024

v0.8.4 - Sep 9, 2024 #5

# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
name: Publish On Release
on:
# trigger when a release or pre-release is published
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
env:
test-requires: "[test,extra]"
test-dir: test
pytest-args: >-
-rap
build-python-version: "3.8"
jobs:
tests-pip:
name: Tests (pip, Python ${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "windows-latest" ] # todo support macos test
python-version: [ "3.8", "3.9", "3.10" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools
pip install ".${{ env.test-requires }}"
- name: Run tests
run: |
pytest ${{ env.pytest-args }} ${{ env.test-dir }}
package-publish-pypi:
name: Package and publish to pypi.org
needs: tests-pip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.build-python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.build-python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade build wheel setuptools twine
- name: Build package (source distribution and wheel)
run: |
python -m build --sdist --wheel
- name: Show package contents
run: |
ls -alh dist
echo "========== .tar.gz =========="
tar tf dist/*.tar.gz
echo "========== .whl =========="
unzip -l dist/*.whl
- name: Verify package
run: |
twine check dist/* --strict
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true