From 47421e291671bc5d29a74d22566d5bee5d1ecca3 Mon Sep 17 00:00:00 2001 From: "Kevin A. Mitchell" Date: Thu, 19 Feb 2026 14:15:28 -0600 Subject: [PATCH 1/4] github/workflows: Update publish step to use PyPI Trusted Publishing - Changed the publish step in `test-and-publish.yml` to target PyPI instead of CodeArtifact, aligning with trusted publishing practices. - Added `environment: production` and `UV_TRUSTED_PUBLISHING: always` to ensure proper publishing conditions for PyPI. - Removed AWS role assumption and CodeArtifact-specific steps for streamlined PyPI publishing flow. Assisted-by: Codex --- .github/workflows/test-and-publish.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/test-and-publish.yml index 48c73f1f..0f6373f8 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/test-and-publish.yml @@ -116,26 +116,22 @@ jobs: PDFREST_API_KEY: ${{ secrets.PDFREST_API_KEY }} publish: - name: Publish to CodeArtifact + name: Publish to PyPI needs: - docs-check - tests - examples - if: github.event_name == 'release' + if: github.event_name == 'release' && github.event.action == 'published' runs-on: ubuntu-latest + environment: production permissions: id-token: write contents: read - packages: write env: UV_PROJECT_ENVIRONMENT: .venv-release + UV_TRUSTED_PUBLISHING: always steps: - uses: actions/checkout@v4 - - name: Assume AWS role for repository CI - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::304774597385:role/cit-oidc-role-${{ github.event.repository.name }}-ci - aws-region: us-east-2 - name: Install uv uses: astral-sh/setup-uv@v6 with: @@ -149,11 +145,9 @@ jobs: path: | ${{ env.UV_PROJECT_ENVIRONMENT }} key: ${{ runner.os }}-uv-release-${{ hashFiles('pyproject.toml') }} - - name: Install keyring - run: uv tool install keyring --with keyrings.codeartifact - name: Synchronize project dependencies run: uv sync --group dev - name: Build distribution artifacts run: uv build --python 3.11 - - name: Publish package to CodeArtifact - run: uv publish --publish-url=https://datalogics-304774597385.d.codeartifact.us-east-2.amazonaws.com/pypi/cit-pypi/ --username __token__ + - name: Publish package to PyPI (Trusted Publishing) + run: uv publish From 0cd9d281811438961ec58bdfe1c3a61db49a163e Mon Sep 17 00:00:00 2001 From: "Kevin A. Mitchell" Date: Thu, 19 Feb 2026 14:49:08 -0600 Subject: [PATCH 2/4] github/workflows: Add `environment: ci-live` to test and examples jobs - Updated `test-and-publish.yml` to include `environment: ci-live` for both the `tests` and `examples` workflows. - Ensures proper environment targeting during CI runs. Assisted-by: Codex --- .github/workflows/test-and-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/test-and-publish.yml index 0f6373f8..6518b7c4 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/test-and-publish.yml @@ -33,6 +33,7 @@ jobs: tests: name: Tests (Python ${{ matrix.python-version }}) runs-on: ubuntu-latest + environment: ci-live strategy: fail-fast: false matrix: @@ -91,6 +92,7 @@ jobs: examples: name: Examples (Python ${{ matrix.python-version }}) runs-on: ubuntu-latest + environment: ci-live strategy: fail-fast: false matrix: From 922d905dfeefa87cdcdb223791a07de9d056317d Mon Sep 17 00:00:00 2001 From: "Kevin A. Mitchell" Date: Thu, 19 Feb 2026 16:53:04 -0600 Subject: [PATCH 3/4] tests/live: Add conftest for injecting `wsn` header in live tests - Introduced `conftest.py` to the `tests/live` folder to facilitate header injection for live tests. - Added `pdfrest_live_wsn` fixture to retrieve the `wsn` value from environment variables with a default fallback. - Used `monkeypatch` to modify `PdfRestClient` and `AsyncPdfRestClient` constructors for seamless `wsn` header injection. Assisted-by: Codex --- tests/live/conftest.py | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/live/conftest.py diff --git a/tests/live/conftest.py b/tests/live/conftest.py new file mode 100644 index 00000000..70009fc2 --- /dev/null +++ b/tests/live/conftest.py @@ -0,0 +1,58 @@ +from __future__ import annotations + +import os +from typing import Any + +import pytest + +from pdfrest import AsyncPdfRestClient, PdfRestClient + +DEFAULT_LIVE_WSN = "dl-internal-python-ci" + + +def _with_live_wsn_header(kwargs: dict[str, Any], wsn: str) -> dict[str, Any]: + new_kwargs = dict(kwargs) + headers = dict(new_kwargs.get("headers") or {}) + headers["wsn"] = wsn + new_kwargs["headers"] = headers + return new_kwargs + + +@pytest.fixture(scope="session") +def pdfrest_live_wsn() -> str: + return os.getenv("PDFREST_LIVE_WSN", DEFAULT_LIVE_WSN) + + +@pytest.fixture(autouse=True) +def inject_live_test_wsn_header( + monkeypatch: pytest.MonkeyPatch, + pdfrest_live_wsn: str, +) -> None: + original_sync_init = PdfRestClient.__init__ + original_async_init = AsyncPdfRestClient.__init__ + + def sync_init_with_live_header( + self: PdfRestClient, + *args: Any, + **kwargs: Any, + ) -> None: + original_sync_init( + self, + *args, + **_with_live_wsn_header(kwargs, pdfrest_live_wsn), + ) + + def async_init_with_live_header( + self: AsyncPdfRestClient, + *args: Any, + **kwargs: Any, + ) -> None: + original_async_init( + self, + *args, + **_with_live_wsn_header(kwargs, pdfrest_live_wsn), + ) + + monkeypatch.setattr(PdfRestClient, "__init__", sync_init_with_live_header) + monkeypatch.setattr(AsyncPdfRestClient, "__init__", async_init_with_live_header) + return From 25cf8f04cd6b6b1e08534a78f2805467440a5945 Mon Sep 17 00:00:00 2001 From: "Kevin A. Mitchell" Date: Thu, 19 Feb 2026 16:55:09 -0600 Subject: [PATCH 4/4] pyproject: Bump version to 1.0.0 - Updated project version to `1.0.0` in `pyproject.toml` to signify the first stable release of the library. --- pyproject.toml | 2 +- uv.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b14d546e..af57e62a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pdfrest" -version = "0.1.0" +version = "1.0.0" description = "Python client library for interacting with the PDFRest API" readme = "README.md" authors = [ diff --git a/uv.lock b/uv.lock index 83176688..4e6372b3 100644 --- a/uv.lock +++ b/uv.lock @@ -961,7 +961,7 @@ wheels = [ [[package]] name = "pdfrest" -version = "0.1.0" +version = "1.0.0" source = { editable = "." } dependencies = [ { name = "exceptiongroup" },