update workflows to run tests on various Python versions #123
Workflow file for this run
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
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
release: | |
types: [ published ] | |
name: Check & Deploy | |
jobs: | |
test: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.9, '3.10', '3.11', '3.12', '3.13'] | |
steps: | |
- name: Checkout git repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
path: _src/ | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
shell: bash | |
run: | | |
pushd _src | |
python3 -m pip install --upgrade pytest | |
python3 -m pip install . | |
popd | |
- name: Run tests | |
shell: bash | |
run: | | |
pushd _src | |
python3 -m pytest | |
popd | |
deploy: | |
name: Build & Deploy | |
needs: test # Ensure tests pass before deployment | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout git repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
path: _src/ | |
- name: Set up Python (single version for deployment) | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' # Use one version for deployment | |
- name: Install dependencies | |
shell: bash | |
run: | | |
pushd _src | |
python3 -m pip install --upgrade pip setuptools wheel build | |
popd | |
- name: Verify release version matches source code version | |
shell: bash | |
run: | | |
pushd _src | |
export TAG_VERSION=${GITHUB_REF##refs/tags/v} | |
export SRC_VERSION=$(python3 -c "from wilson._version import __version__; print(__version__)") | |
if [[ ${TAG_VERSION} != ${SRC_VERSION} ]] ; then | |
echo "tag/release version and source code version disagree, exiting" | |
exit 1 | |
fi | |
popd | |
- name: Build distribution | |
shell: bash | |
run: | | |
mkdir dist | |
pushd _src | |
python3 -m build --outdir ../dist | |
popd | |
- name: Verify package metadata | |
shell: bash | |
run: | | |
python3 -m pip install twine | |
python3 -m twine check dist/* | |
- name: Test installing the wheel | |
shell: bash | |
run: | | |
python3 -m pip install dist/wilson-*.whl | |
- name: Upload build as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wilson-dist-${{ github.sha }} | |
path: dist | |
- name: Upload to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: ${{ secrets.TWINE_USERNAME }} | |
password: ${{ secrets.TWINE_PASSWORD }} |