Bump actions/setup-python from 4 to 5 (#9) #47
  
    
      This file contains hidden or 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: CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| tags: [v*.*.*] | |
| jobs: | |
| build: | |
| name: Test & Build | |
| container: | |
| # Run some matrix cases in a container. If `container-image` is blank, the | |
| # job will run conventionally on the agent. | |
| image: ${{ matrix.container-image }} | |
| env: | |
| PYTHON: ${{ matrix.python-version }} | |
| runs-on: [ubuntu-20.04] | |
| strategy: | |
| # Finish the other builds even if one fails. | |
| fail-fast: false | |
| matrix: | |
| python-version: ['2.7', '3.7', '3.8', '3.10'] | |
| include: | |
| - python-version: '2.7' | |
| container-image: python:2.7 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # Fetch all the history so setuptools_scm can version relative to the | |
| # most recent version tag. | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| # Only set up Python if we're running directly on an agent. If we're in | |
| # a container, the image should already provide the intended Python. | |
| if: '! matrix.container-image' | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install python dependencies | |
| run: | | |
| pip install wheel build tox | |
| pip install . | |
| - name: Determine pyenv | |
| id: pyenv | |
| run: echo "value=py$(echo $PYTHON | tr -d '.')" >> $GITHUB_OUTPUT | |
| - name: Run tests | |
| env: | |
| TOXENV: ${{ steps.pyenv.outputs.value }} | |
| run: tox | |
| - name: Build python package | |
| run: python -m build | |
| - name: Upload coverage | |
| uses: codecov/codecov-action@v3 | |
| if: matrix.python-version == '3.8' | |
| with: | |
| env_vars: PYTHON | |
| # TODO: re-enable errors when rate limit is resolved? | |
| # fail_ci_if_error: true | |
| files: .coverage.${{ steps.pyenv.outputs.value }}.xml | |
| - uses: actions/upload-artifact@v4 | |
| if: matrix.python-version == '2.7' || matrix.python-version == '3.8' | |
| with: | |
| name: dist-${{ matrix.python-version }} | |
| path: dist | |
| publish: | |
| name: Publish to PyPI | |
| needs: build | |
| runs-on: [ubuntu-latest] | |
| permissions: | |
| id-token: write | |
| if: github.event_name != 'pull_request' | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| - name: Organize files for upload | |
| run: | | |
| mkdir dist | |
| mv dist-3.8/* dist/ | |
| mv dist-2.7/*.whl dist/ | |
| - name: Test Publish package | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| - name: Publish package | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| if: startsWith(github.event.ref, 'refs/tags/v') |