Skip to content

Commit 2487dcf

Browse files
Merge pull request #29 from datalogics-kam/pdfcloud-5592-publish-to-pypi
PDFCLOUD-5592 Publish to PYPI
2 parents 021ea30 + 25cf8f0 commit 2487dcf

4 files changed

Lines changed: 68 additions & 14 deletions

File tree

.github/workflows/test-and-publish.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
tests:
4141
name: Tests (Python ${{ matrix.python-version }})
4242
runs-on: ubuntu-latest
43+
environment: ci-live
4344
strategy:
4445
fail-fast: false
4546
matrix:
@@ -98,6 +99,7 @@ jobs:
9899
examples:
99100
name: Examples (Python ${{ matrix.python-version }})
100101
runs-on: ubuntu-latest
102+
environment: ci-live
101103
strategy:
102104
fail-fast: false
103105
matrix:
@@ -123,26 +125,22 @@ jobs:
123125
PDFREST_API_KEY: ${{ secrets.PDFREST_API_KEY }}
124126

125127
publish:
126-
name: Publish to CodeArtifact
128+
name: Publish to PyPI
127129
needs:
128130
- docs-check
129131
- tests
130132
- examples
131-
if: github.event_name == 'release'
133+
if: github.event_name == 'release' && github.event.action == 'published'
132134
runs-on: ubuntu-latest
135+
environment: production
133136
permissions:
134137
id-token: write
135138
contents: read
136-
packages: write
137139
env:
138140
UV_PROJECT_ENVIRONMENT: .venv-release
141+
UV_TRUSTED_PUBLISHING: always
139142
steps:
140143
- uses: actions/checkout@v4
141-
- name: Assume AWS role for repository CI
142-
uses: aws-actions/configure-aws-credentials@v4
143-
with:
144-
role-to-assume: arn:aws:iam::304774597385:role/cit-oidc-role-${{ github.event.repository.name }}-ci
145-
aws-region: us-east-2
146144
- name: Install uv
147145
uses: astral-sh/setup-uv@v6
148146
with:
@@ -156,11 +154,9 @@ jobs:
156154
path: |
157155
${{ env.UV_PROJECT_ENVIRONMENT }}
158156
key: ${{ runner.os }}-uv-release-${{ hashFiles('pyproject.toml') }}
159-
- name: Install keyring
160-
run: uv tool install keyring --with keyrings.codeartifact
161157
- name: Synchronize project dependencies
162158
run: uv sync --group dev
163159
- name: Build distribution artifacts
164160
run: uv build --python 3.11
165-
- name: Publish package to CodeArtifact
166-
run: uv publish --publish-url=https://datalogics-304774597385.d.codeartifact.us-east-2.amazonaws.com/pypi/cit-pypi/ --username __token__
161+
- name: Publish package to PyPI (Trusted Publishing)
162+
run: uv publish

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pdfrest"
3-
version = "0.1.0"
3+
version = "1.0.0"
44
description = "Python client library for interacting with the PDFRest API"
55
readme = "README.md"
66
authors = [

tests/live/conftest.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from __future__ import annotations
2+
3+
import os
4+
from typing import Any
5+
6+
import pytest
7+
8+
from pdfrest import AsyncPdfRestClient, PdfRestClient
9+
10+
DEFAULT_LIVE_WSN = "dl-internal-python-ci"
11+
12+
13+
def _with_live_wsn_header(kwargs: dict[str, Any], wsn: str) -> dict[str, Any]:
14+
new_kwargs = dict(kwargs)
15+
headers = dict(new_kwargs.get("headers") or {})
16+
headers["wsn"] = wsn
17+
new_kwargs["headers"] = headers
18+
return new_kwargs
19+
20+
21+
@pytest.fixture(scope="session")
22+
def pdfrest_live_wsn() -> str:
23+
return os.getenv("PDFREST_LIVE_WSN", DEFAULT_LIVE_WSN)
24+
25+
26+
@pytest.fixture(autouse=True)
27+
def inject_live_test_wsn_header(
28+
monkeypatch: pytest.MonkeyPatch,
29+
pdfrest_live_wsn: str,
30+
) -> None:
31+
original_sync_init = PdfRestClient.__init__
32+
original_async_init = AsyncPdfRestClient.__init__
33+
34+
def sync_init_with_live_header(
35+
self: PdfRestClient,
36+
*args: Any,
37+
**kwargs: Any,
38+
) -> None:
39+
original_sync_init(
40+
self,
41+
*args,
42+
**_with_live_wsn_header(kwargs, pdfrest_live_wsn),
43+
)
44+
45+
def async_init_with_live_header(
46+
self: AsyncPdfRestClient,
47+
*args: Any,
48+
**kwargs: Any,
49+
) -> None:
50+
original_async_init(
51+
self,
52+
*args,
53+
**_with_live_wsn_header(kwargs, pdfrest_live_wsn),
54+
)
55+
56+
monkeypatch.setattr(PdfRestClient, "__init__", sync_init_with_live_header)
57+
monkeypatch.setattr(AsyncPdfRestClient, "__init__", async_init_with_live_header)
58+
return

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)