Manually parse URL without depending on packaging (#1071) #536
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
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions | |
# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
# | |
# Needed GitHub Repository Secret: | |
# PYPI_PASSWORD - PyPI API token allowing write, release access to PyPI. | |
# Limit scope to just project. | |
# (See package.python.org example link above.) | |
name: tests | |
on: | |
pull_request: | |
push: | |
# If changing default-python be sure to change job "tests" matrix: include: also | |
env: | |
default-python: "3.11" | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ env.default-python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.default-python }} | |
- name: Upgrade pip, Install nox | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install nox | |
- name: Lint | |
run: | | |
nox --error-on-missing-interpreters --non-interactive --session lint | |
verify-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ env.default-python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.default-python }} | |
- name: Upgrade pip, Install nox | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install nox | |
- name: Verify Docs | |
run: | | |
nox --error-on-missing-interpreters --non-interactive --session build_docs | |
tests: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
include: | |
- os: windows-latest | |
python-version: "3.11" | |
- os: macos-latest | |
python-version: "3.11" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Get pip cache dir | |
id: pip-cache | |
run: | | |
echo "::set-output name=dir::$(pip cache dir)" | |
- name: Persistent Github pip cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: ${{ runner.os }}-pip${{ matrix.python-version }} | |
- name: Persistent .pipx_tests/package_cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/.pipx_tests/package_cache/${{ matrix.python-version }} | |
key: pipx-tests-package-cache-${{ runner.os }}-${{ matrix.python-version }} | |
- name: Upgrade pip, Install nox | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install nox | |
- name: Execute Tests | |
run: | | |
nox --non-interactive --session tests-${{ matrix.python-version }} | |
pypi-publish: | |
name: Publish pipx to PyPI on release | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
needs: [verify-docs, lint, tests] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ${{ github.ref }} | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ env.default-python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.default-python }} | |
- name: Upgrade pip, Install nox | |
run: | | |
python -m pip install --upgrade pip | |
pip install nox | |
- name: Build sdist and wheel | |
run: | | |
nox --error-on-missing-interpreters --non-interactive --session build | |
- name: Publish to PyPi | |
uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} | |
build-zipapp: | |
name: Build zipapp | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
needs: [verify-docs, lint, tests] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ${{ github.ref }} | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ env.default-python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.default-python }} | |
- name: Upgrade pip, Install shiv | |
run: | | |
python -m pip install --upgrade pip | |
pip install shiv | |
- name: Build zipapp | |
run: shiv -c pipx -o ./pipx.pyz git+https://github.com/pypa/pipx@${{ github.ref_name }} | |
- name: Test zipapp | |
run: | | |
python ./pipx.pyz --version | |
python ./pipx.pyz install black | |
- name: Upload to releases | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: pipx.pyz |