1 name: Test, build, publish
3 # Run tests (all branches),
4 # for tags build wheels, publish wheels to PyPI and Github Releases.
6 on: [push, pull_request]
11 not_in_conda: "['3.11', 'pypy-3.7']"
15 os: [ubuntu-latest, macos-11, windows-latest]
16 python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy-3.7"]
20 pip-cache-path: ~/.cache/pip
23 pip-cache-path: ~/Library/Caches/pip
26 pip-cache-path: ~\AppData\Local\pip\Cache
28 name: Python ${{ matrix.python-version }} @ ${{ matrix.os-name }}
29 runs-on: ${{ matrix.os }}
34 - uses: s-weigand/setup-conda@v1
36 python-version: ${{ matrix.python-version }}
37 if: ${{ runner.os == 'Linux' && !contains(fromJSON(env.not_in_conda), matrix.python-version) }}
38 - uses: actions/setup-python@v4
40 python-version: ${{ matrix.python-version }}
41 if: ${{ runner.os != 'Linux' || contains(fromJSON(env.not_in_conda), matrix.python-version) }}
43 uses: actions/cache@v3
45 path: ${{ matrix.pip-cache-path }}
46 key: ${{ runner.os }}-pip
49 - name: Install dependencies
52 python -m pip install --upgrade pip setuptools wheel
54 pip install --upgrade virtualenv tox
58 ld_library_path = None
59 if hasattr(sys, 'pypy_version_info'):
62 pyver = '%d%d' % tuple(sys.version_info[:2])
63 if os.name == 'posix':
64 if pyver == '27': # Python 2.7 on Linux requires `$LD_LIBRARY_PATH`
65 ld_library_path = os.path.join(
66 os.path.dirname(os.path.dirname(sys.executable)), 'lib')
67 toxenv = 'py%s' % pyver
68 if os.name == 'posix':
69 toxenv += ',py%s-flake8' % pyver
70 with open(os.environ['GITHUB_ENV'], 'a') as f:
72 f.write('LD_LIBRARY_PATH=' + ld_library_path + '\n')
73 f.write('TOXENV=' + toxenv + '\n')
79 python -c "import os; print(os.environ['TOXENV'])"
83 - name: Build and publish wheel
85 pip install -U pip setuptools twine wheel
86 python setup.py bdist_wheel
87 twine upload --disable-progress-bar --skip-existing dist\*
88 if: ${{ startsWith(github.ref, 'refs/tags/') }}
90 TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
91 TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
92 - name: Publish wheel to Releases
93 uses: ncipollo/release-action@v1
97 bodyFile: "LATEST-CHANGES.rst"
98 omitBodyDuringUpdate: true
99 omitNameDuringUpdate: true
100 omitPrereleaseDuringUpdate: true
102 replacesArtifacts: false
103 skipIfReleaseExists: false
104 updateOnlyUnreleased: false
105 if: ${{ startsWith(github.ref, 'refs/tags/') }}