Add test PyPI publishing #16
Workflow file for this run
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
name: Lint, Type-Check, Test, Build and Publish Package | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: [main] | |
tags: ["v*"] | |
jobs: | |
uv-check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: uv.lock | |
- name: Check uv.lock | |
run: uv lock --locked | |
mypy: | |
needs: uv-check | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: uv.lock | |
- name: Set Up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install mypy From Locked Dependencies | |
run: uv sync --python ${{ matrix.python-version }} --no-python-downloads | |
--only-group type-check --frozen | |
- name: Run mypy | |
run: uv run --python ${{ matrix.python-version }} --no-sync --no-python-downloads | |
mypy . | |
pre-commit: | |
needs: uv-check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: uv.lock | |
- name: Set Up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: .python-version | |
- name: Install pre-commit From Locked Dependencies | |
run: uv sync --no-python-downloads --only-group pre-commit --frozen | |
- name: Save Hashed Python Version | |
run: echo "HASHED_PYTHON_VERSION=$(uv run python -VV | sha256sum | |
| cut -d' ' -f1)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit|${{ env.HASHED_PYTHON_VERSION }}|${{ hashFiles('.pre-commit-config.yaml')}} | |
- name: Setup pre-commit Environments | |
run: uv run --no-sync --no-python-downloads pre-commit install-hooks | |
- name: Store pre-commit Checks Which Require Skipping | |
run: echo "SKIP=check-github-workflows,ruff,ruff-format,taplo-format,taplo-lint,uv-lock,yamlfmt" | |
>> $GITHUB_ENV | |
- name: Run pre-commit | |
run: uv run --no-sync --no-python-downloads pre-commit run --all-files | |
--hook-stage manual | |
pytest: | |
needs: uv-check | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: uv.lock | |
- name: Set Up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install pytest From Locked Dependencies | |
run: uv sync --python ${{ matrix.python-version }} --no-python-downloads | |
--only-group test --frozen | |
- name: Run pytest | |
run: uv run --python ${{ matrix.python-version }} --no-sync --no-python-downloads | |
pytest | |
ruff: | |
needs: uv-check | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: uv.lock | |
- name: Set Up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install ruff From Locked Dependencies | |
run: uv sync --python ${{ matrix.python-version }} --no-python-downloads | |
--only-group lint --frozen | |
- name: Run Ruff | |
run: uv run --python ${{ matrix.python-version }} --no-sync --no-python-downloads | |
ruff check --output-format=github | |
taplo-format: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: uv.lock | |
- name: Run Taplo Formatter | |
run: uvx taplo format . --check --option reorder_arrays=true --option | |
reorder_keys=true --option "indent_string= " | |
taplo-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: uv.lock | |
- name: Run Taplo Linter | |
run: uvx taplo lint . --default-schema-catalogs | |
yamlfmt: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Golang | |
uses: actions/setup-go@v5 | |
- name: Install yamlfmt | |
run: go install github.com/google/yamlfmt/cmd/yamlfmt@latest | |
- name: Run yamlfmt | |
run: yamlfmt . -lint -formatter indent=4 -formatter line_ending=lf | |
-formatter disallow_anchors=true -formatter max_line_length=75 | |
-formatter trim_trailing_whitespace=true -formatter eof_newline=true | |
-formatter retain_line_breaks_single=true -formatter pad_line_comments=2 | |
build: | |
needs: [mypy, pre-commit, pytest, ruff, taplo-format, taplo-lint, yamlfmt] | |
runs-on: ubuntu-latest | |
if: github.ref_type == 'tag' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: uv.lock | |
- name: Build Package | |
run: uv build --no-sources | |
- name: Save Build Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: built-typed_classproperties-package | |
path: dist/ | |
publish: | |
needs: [build] | |
runs-on: ubuntu-latest | |
environment: publish | |
permissions: | |
id-token: write | |
steps: | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: uv.lock | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: built-typed_classproperties-package | |
path: dist/ | |
- name: Publish to PyPI | |
run: uv publish | |
# release: | |
# needs: [publish] | |
# runs-on: ubuntu-latest | |
# permissions: | |
# content: write | |
# | |
# steps: |