diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml deleted file mode 100644 index 202c89e..0000000 --- a/.github/workflows/check-format.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: ruff - -on: - push: - branches: [main] - pull_request: - -jobs: - format: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install uv - uses: astral-sh/setup-uv@v3 - with: - enable-cache: true - - - name: "Set up Python" - uses: actions/setup-python@v5 - with: - python-version-file: ".python-version" - - - name: Install the project - run: uv sync --frozen --all-extras --dev - - - name: Run ruff format check - run: uv run --frozen ruff check . diff --git a/.github/workflows/check-types.yml b/.github/workflows/check-types.yml deleted file mode 100644 index 3463fcf..0000000 --- a/.github/workflows/check-types.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: typecheck - -on: - push: - branches: [main] - pull_request: - -jobs: - typecheck: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install uv - uses: astral-sh/setup-uv@v3 - with: - enable-cache: true - - - name: "Set up Python" - uses: actions/setup-python@v5 - with: - python-version-file: ".python-version" - - - name: Install the project - run: uv sync --frozen --all-extras --dev - - - name: Run pyright - run: uv run --frozen pyright diff --git a/.github/workflows/main-checks.yml b/.github/workflows/main-checks.yml new file mode 100644 index 0000000..d6d4565 --- /dev/null +++ b/.github/workflows/main-checks.yml @@ -0,0 +1,9 @@ +name: Main branch checks + +on: + push: + branches: [main] + +jobs: + checks: + uses: ./.github/workflows/shared.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 24a31cd..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,29 +0,0 @@ -on: - push: - branches: - - main - - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install uv - uses: astral-sh/setup-uv@v3 - with: - enable-cache: true - - - name: "Set up Python" - uses: actions/setup-python@v5 - with: - python-version-file: ".python-version" - - - name: Install the project - run: uv sync --frozen --all-extras --dev - - - name: Run pytest - run: uv run --frozen pytest diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 0000000..fddf83f --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,55 @@ +name: Publishing + +on: + release: + types: [published] + +jobs: + release-build: + name: Build distribution + runs-on: ubuntu-latest + needs: [checks] + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: "Set up Python" + uses: actions/setup-python@v5 + with: + python-version-file: ".python-version" + + - name: Install the project + run: uv sync --frozen --all-extras --dev + + - name: Build + run: uv build + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: release-dists + path: dist/ + + checks: + uses: ./.github/workflows/shared.yml + + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: release + needs: + - release-build + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@v4 + with: + name: release-dists + path: dist/ + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/pull-request-checks.yml b/.github/workflows/pull-request-checks.yml new file mode 100644 index 0000000..a7e7a8b --- /dev/null +++ b/.github/workflows/pull-request-checks.yml @@ -0,0 +1,8 @@ +name: Pull request checks + +on: + pull_request: + +jobs: + checks: + uses: ./.github/workflows/shared.yml diff --git a/.github/workflows/shared.yml b/.github/workflows/shared.yml new file mode 100644 index 0000000..2be9f12 --- /dev/null +++ b/.github/workflows/shared.yml @@ -0,0 +1,69 @@ +name: Shared Checks + +on: + workflow_call: + +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + + - name: "Set up Python" + uses: actions/setup-python@v5 + with: + python-version-file: ".python-version" + + - name: Install the project + run: uv sync --frozen --all-extras --dev + + - name: Run ruff format check + run: uv run --frozen ruff check . + + typecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + + - name: "Set up Python" + uses: actions/setup-python@v5 + with: + python-version-file: ".python-version" + + - name: Install the project + run: uv sync --frozen --all-extras --dev + + - name: Run pyright + run: uv run --frozen pyright + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + + - name: "Set up Python" + uses: actions/setup-python@v5 + with: + python-version-file: ".python-version" + + - name: Install the project + run: uv sync --frozen --all-extras --dev + + - name: Run pytest + run: uv run --frozen pytest