mirror of https://github.com/astral-sh/uv
parent
249089c96a
commit
874aa29b57
|
|
@ -1139,6 +1139,7 @@ jobs:
|
|||
env:
|
||||
# No dbus in GitHub Actions
|
||||
PYTHON_KEYRING_BACKEND: keyrings.alt.file.PlaintextKeyring
|
||||
PYTHON_VERSION: 3.12
|
||||
permissions:
|
||||
# For trusted publishing
|
||||
id-token: write
|
||||
|
|
@ -1149,7 +1150,7 @@ jobs:
|
|||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
python-version: "${{ env.PYTHON_VERSION }}"
|
||||
|
||||
- name: "Download binary"
|
||||
uses: actions/download-artifact@v4
|
||||
|
|
@ -1169,7 +1170,7 @@ jobs:
|
|||
|
||||
- name: "Publish test packages"
|
||||
# `-p 3.12` prefers the python we just installed over the one locked in `.python_version`.
|
||||
run: ./uv run -p 3.12 scripts/publish/test_publish.py --uv ./uv all
|
||||
run: ./uv run -p ${{ env.PYTHON_VERSION }} scripts/publish/test_publish.py --uv ./uv all
|
||||
env:
|
||||
RUST_LOG: uv=debug,uv_publish=trace
|
||||
UV_TEST_PUBLISH_TOKEN: ${{ secrets.UV_TEST_PUBLISH_TOKEN }}
|
||||
|
|
@ -1177,6 +1178,7 @@ jobs:
|
|||
UV_TEST_PUBLISH_GITLAB_PAT: ${{ secrets.UV_TEST_PUBLISH_GITLAB_PAT }}
|
||||
UV_TEST_PUBLISH_CODEBERG_TOKEN: ${{ secrets.UV_TEST_PUBLISH_CODEBERG_TOKEN }}
|
||||
UV_TEST_PUBLISH_CLOUDSMITH_TOKEN: ${{ secrets.UV_TEST_PUBLISH_CLOUDSMITH_TOKEN }}
|
||||
UV_TEST_PUBLISH_PYTHON_VERSION: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
cache-test-ubuntu:
|
||||
timeout-minutes: 10
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ from packaging.utils import (
|
|||
from packaging.version import Version
|
||||
|
||||
TEST_PYPI_PUBLISH_URL = "https://test.pypi.org/legacy/"
|
||||
PYTHON_VERSION = os.environ.get("UV_TEST_PUBLISH_PYTHON_VERSION", "3.12")
|
||||
|
||||
cwd = Path(__file__).parent
|
||||
|
||||
|
|
@ -124,8 +125,8 @@ all_targets: dict[str, TargetConfiguration] = local_targets | {
|
|||
}
|
||||
|
||||
|
||||
def get_new_version(project_name: str, client: httpx.Client) -> Version:
|
||||
"""Return the next free patch version on all indexes of the package."""
|
||||
def get_latest_version(project_name: str, client: httpx.Client) -> Version:
|
||||
"""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
|
||||
versions = set()
|
||||
|
|
@ -151,10 +152,12 @@ def get_new_version(project_name: str, client: httpx.Client) -> Version:
|
|||
time.sleep(1)
|
||||
else:
|
||||
raise RuntimeError(f"Failed to fetch {url}") from error
|
||||
max_version = max(versions)
|
||||
return max(versions)
|
||||
|
||||
# Bump the path version to obtain an empty version
|
||||
release = list(max_version.release)
|
||||
|
||||
def get_new_version(latest_version: Version) -> Version:
|
||||
"""Bump the path version to obtain an empty version."""
|
||||
release = list(latest_version.release)
|
||||
release[-1] += 1
|
||||
return Version(".".join(str(i) for i in release))
|
||||
|
||||
|
|
@ -193,7 +196,10 @@ def build_project_at_version(
|
|||
|
||||
if project_root.exists():
|
||||
rmtree(project_root)
|
||||
check_call([uv, "init", "--lib", "--name", project_name, dir_name], cwd=cwd)
|
||||
check_call(
|
||||
[uv, "init", "-p", PYTHON_VERSION, "--lib", "--name", project_name, dir_name],
|
||||
cwd=cwd,
|
||||
)
|
||||
pyproject_toml = project_root.joinpath("pyproject.toml")
|
||||
|
||||
# Set to an unclaimed version
|
||||
|
|
@ -217,7 +223,12 @@ def build_project_at_version(
|
|||
return project_root
|
||||
|
||||
|
||||
def wait_for_index(index_url: str, project_name: str, version: Version, uv: Path):
|
||||
def wait_for_index(
|
||||
index_url: str,
|
||||
project_name: str,
|
||||
version: Version,
|
||||
uv: Path,
|
||||
):
|
||||
"""Check that the index URL was updated, wait up to 100s if necessary.
|
||||
|
||||
Often enough the index takes a few seconds until the index is updated after an
|
||||
|
|
@ -231,6 +242,8 @@ def wait_for_index(index_url: str, project_name: str, version: Version, uv: Path
|
|||
uv,
|
||||
"pip",
|
||||
"compile",
|
||||
"-p",
|
||||
PYTHON_VERSION,
|
||||
"--index",
|
||||
index_url,
|
||||
"--quiet",
|
||||
|
|
@ -241,7 +254,7 @@ def wait_for_index(index_url: str, project_name: str, version: Version, uv: Path
|
|||
"-",
|
||||
],
|
||||
text=True,
|
||||
input=project_name,
|
||||
input=f"{project_name}",
|
||||
)
|
||||
if f"{project_name}=={version}" in output and output.count("--hash") == 2:
|
||||
break
|
||||
|
|
@ -265,7 +278,8 @@ def publish_project(target: str, uv: Path, client: httpx.Client):
|
|||
print(f"\nPublish {project_name} for {target}")
|
||||
|
||||
# The distributions are build to the dist directory of the project.
|
||||
version = get_new_version(project_name, client)
|
||||
previous_version = get_latest_version(project_name, client)
|
||||
version = get_new_version(previous_version)
|
||||
project_dir = build_project_at_version(project_name, version, uv)
|
||||
|
||||
# Upload configuration
|
||||
|
|
|
|||
Loading…
Reference in New Issue