Allow repeat PyPI release uploads (#8) #21
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 | |
| permissions: | |
| contents: read | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| test: | |
| name: Build and test | |
| runs-on: ubuntu-24.04 | |
| env: | |
| IMPORT_NAME: src_py_lib | |
| PYTHON_VERSION: "3.11" | |
| UV_VERSION: "0.11.7" | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: pip | |
| - name: Install uv | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install "uv==${UV_VERSION}" | |
| - name: Validate lockfile | |
| run: uv lock --check | |
| - name: Lint Markdown | |
| run: npx --yes markdownlint-cli2 | |
| - name: Lint Python | |
| run: uv run --frozen ruff check . | |
| - name: Check Python formatting | |
| run: uv run --frozen ruff format --check . | |
| - name: Type check | |
| run: uv run --frozen pyright | |
| - name: Run tests | |
| run: uv run --frozen python -m unittest discover -s tests | |
| - name: Smoke test source checkout import | |
| run: | | |
| uv run --frozen python - <<'PY' | |
| import os | |
| import src_py_lib | |
| if src_py_lib.__name__ != os.environ["IMPORT_NAME"]: | |
| raise SystemExit(f"unexpected import name: {src_py_lib.__name__}") | |
| PY | |
| - name: Build wheel | |
| run: uv build --wheel --out-dir dist --no-create-gitignore | |
| - name: Smoke test installed wheel | |
| run: | | |
| python -m venv build/ci-venv | |
| . build/ci-venv/bin/activate | |
| python -m pip install --upgrade pip | |
| python -m pip install dist/*.whl | |
| python - <<'PY' | |
| import os | |
| import src_py_lib | |
| if src_py_lib.__name__ != os.environ["IMPORT_NAME"]: | |
| raise SystemExit(f"unexpected import name: {src_py_lib.__name__}") | |
| PY | |
| - name: Upload wheel artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: src-py-lib-wheel | |
| path: dist/*.whl |