Modernize packaging #1108
Workflow file for this run
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: Build, Test and Publish | |
on: | |
merge_group: | |
push: | |
pull_request: | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
urllib3-version: ["1.26.19", "2.2.2"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Set up uv and Python ${{ matrix.python-version }} | |
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1 | |
with: | |
version: "0.7.7" | |
python-version: ${{ matrix.python-version }} | |
enable-cache: true | |
cache-dependency-glob: "**/pyproject.toml" | |
- name: Install dependencies | |
run: | | |
uv sync | |
uv pip install "urllib3==${{ matrix.urllib3-version }}" | |
- if: matrix.python-version == '3.10' && matrix.urllib3-version == '1.26.19' | |
name: Run `ruff` | |
run: uv run ruff check | |
- name: Run tests and collect coverage | |
run: uv run pytest --cov-fail-under 60 --cov openfga_sdk | |
- if: matrix.python-version == '3.10' && matrix.urllib3-version == '1.26.19' | |
name: Upload coverage to Codecov | |
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2 | |
continue-on-error: true | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: openfga/python-sdk | |
publish: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: [test] | |
permissions: | |
id-token: write # Required for PyPI trusted publishing | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Set up uv and Python | |
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1 | |
with: | |
version: "0.7.7" | |
python-version: "3.10" | |
enable-cache: true | |
cache-dependency-glob: "**/pyproject.toml" | |
- name: Install dependencies | |
run: uv sync | |
- name: Build package | |
run: uv build | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 | |
create-release: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: [publish] | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- uses: Roang-zero1/github-create-release-action@57eb9bdce7a964e48788b9e78b5ac766cb684803 # v3.0.1 | |
with: | |
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |