diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78e11e764..1a84c2e6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1865,6 +1865,12 @@ jobs: env: UV_TEST_PUBLISH_KEYRING: ${{ secrets.UV_TEST_PUBLISH_KEYRING }} + - name: "Add password to uv text store" + run: | + ./uv auth login https://test.pypi.org/legacy/?astral-test-text-store --token ${UV_TEST_PUBLISH_TEXT_STORE} + env: + UV_TEST_PUBLISH_TEXT_STORE: ${{ secrets.UV_TEST_PUBLISH_TEXT_STORE }} + - name: "Publish test packages" # `-p 3.12` prefers the python we just installed over the one locked in `.python_version`. run: ./uv run -p "${PYTHON_VERSION}" scripts/publish/test_publish.py --uv ./uv all diff --git a/scripts/publish/test_publish.py b/scripts/publish/test_publish.py index a9dfcd49c..1cd85dc9f 100644 --- a/scripts/publish/test_publish.py +++ b/scripts/publish/test_publish.py @@ -35,6 +35,14 @@ The query parameter a horrible hack stolen from https://github.com/pypa/twine/issues/565#issue-555219267 to prevent the other projects from implicitly using the same credentials. +**pypi-text-store** +```console +uv auth login https://test.pypi.org/legacy/?astral-test-text-store --token +``` +The query parameter a horrible hack stolen from +https://github.com/pypa/twine/issues/565#issue-555219267 +to prevent the other projects from implicitly using the same credentials. + **pypi-trusted-publishing** This one only works in GitHub Actions on astral-sh/uv in `ci.yml` - sorry! @@ -138,6 +146,11 @@ local_targets: dict[str, TargetConfiguration] = { "https://test.pypi.org/legacy/?astral-test-keyring", "https://test.pypi.org/simple/", ), + "pypi-text-store": TargetConfiguration( + "astral-test-text-store", + "https://test.pypi.org/legacy/?astral-test-text-store", + "https://test.pypi.org/simple/", + ), "gitlab": TargetConfiguration( "astral-test-token", "https://gitlab.com/api/v4/projects/61853105/packages/pypi", @@ -163,7 +176,7 @@ all_targets: dict[str, TargetConfiguration] = local_targets | { } -def get_latest_version(target: str, client: httpx.Client) -> Version: +def get_latest_version(target: str, client: httpx.Client) -> Version | None: """Return the latest version on all indexes of the package.""" # To keep the number of packages small we reuse them across targets, so we have to # pick a version that doesn't exist on any target yet @@ -196,7 +209,7 @@ def get_latest_version(target: str, client: httpx.Client) -> Version: raise RuntimeError(f"Failed to fetch {url}") from error if not versions: - raise ValueError(f"No versions found for {target_config.project_name}") + return None return max(versions) @@ -365,7 +378,7 @@ def publish_project(target: str, uv: Path, client: httpx.Client): print(f"\nPublish {project_name} for {target}", file=sys.stderr) # The distributions are build to the dist directory of the project. - previous_version = get_latest_version(target, client) + previous_version = get_latest_version(target, client) or Version("0.0.0") version = get_new_version(previous_version) project_dir = build_project_at_version(target, version, uv) @@ -507,6 +520,9 @@ def target_configuration(target: str) -> tuple[dict[str, str], list[str]]: elif target == "pypi-keyring": extra_args = ["--username", "__token__", "--keyring-provider", "subprocess"] env = {} + elif target == "pypi-text-store": + extra_args = ["--username", "__token__"] + env = {} elif target == "pypi-trusted-publishing": extra_args = ["--trusted-publishing", "always"] env = {}