Update workflow & fix tests #107
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: | |
check-and-deploy: | |
name: Check & Deploy on Ubuntu (latest) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout git repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
path: _src/ | |
- name: Install dependencies | |
shell: bash | |
run: | | |
pushd _src | |
python3 -m pip install --upgrade pytest | |
popd | |
- name: Run checks | |
shell: bash | |
run: | | |
pushd _src | |
python3 -m pip install . | |
python3 -m pytest | |
popd | |
- name: Verify release version matches source code version | |
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') | |
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 bdist | |
shell: bash | |
run: | | |
mkdir dist | |
pushd _src | |
python3 ./setup.py sdist -d ../dist/ | |
python3 ./setup.py bdist_wheel -d ../dist/ | |
popd | |
- 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 | |
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: ${{ secrets.TWINE_USERNAME }} | |
password: ${{ secrets.TWINE_PASSWORD }} |