From c3a060792c08ddf89999b3cbda054ee9384bab65 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 23 Nov 2026 10:18:23 +0100 Subject: [PATCH 1/6] Release the Python packages with verwalter Replace changesets.py, update_versions.py and the Package Release, Manual Version Bump, Changeset and Changeset Reminder workflows with verwalter.toml and the verwalter workflows. Keep the release gate. Co-Authored-By: Claude Opus 5.5 --- .changeset/README.md | 65 +-- .github/changesets.py | 294 ------------- .github/update_versions.py | 149 ------- .github/workflows/changeset-check.yml | 24 ++ .github/workflows/changeset-reminder.yml | 81 ---- .github/workflows/changeset.yml | 49 --- .github/workflows/manual-version-bump.yml | 152 ------- .github/workflows/package-release.yml | 497 ---------------------- .github/workflows/pre-release.yml | 27 ++ .github/workflows/release-gate.yml | 4 +- .github/workflows/release-pr.yml | 30 ++ .github/workflows/release.yml | 294 +++++++++++++ RELEASING.md | 71 ++++ verwalter.toml | 21 + 14 files changed, 481 insertions(+), 1277 deletions(-) delete mode 100644 .github/changesets.py delete mode 100644 .github/update_versions.py create mode 100644 .github/workflows/changeset-check.yml delete mode 100644 .github/workflows/changeset-reminder.yml delete mode 100644 .github/workflows/changeset.yml delete mode 100644 .github/workflows/manual-version-bump.yml delete mode 100644 .github/workflows/package-release.yml create mode 100644 .github/workflows/pre-release.yml create mode 100644 .github/workflows/release-pr.yml create mode 100644 .github/workflows/release.yml create mode 100644 RELEASING.md create mode 100644 verwalter.toml diff --git a/.changeset/README.md b/.changeset/README.md index 43c4e92a4..827399aaa 100644 --- a/.changeset/README.md +++ b/.changeset/README.md @@ -1,66 +1,25 @@ # Changesets -Add a changeset to any PR that should be released. Create a markdown file in -this directory (any name, e.g. `fix-token-parsing.md`): +Add a changeset to any PR that changes a published package. Create a markdown +file in this directory (any name, for example `fix-token-parsing.md`), or run +`verwalter changeset`: ```md --- "livekit-api": patch --- -Short description of the change, used in the release notes. +Short description of the change, for the user of the package. ``` -List one line per package the change should release: +- **Packages:** `livekit` (the code in `livekit-rtc/`), `livekit-api`, `livekit-protocol`. One line per package. +- **Levels:** `patch` for a fix, `minor` for an addition, `major` for a break. -- **Packages:** `livekit-rtc`, `livekit-api`, `livekit-protocol` -- **Types:** +Do not add the PR number: the release adds it. When several pending changesets +name the same package, the largest level wins. A change to `livekit-protocol` +also releases `livekit-api` as a patch, with no changeset for it. - | Type | Example | - |---|---| - | `patch` | 1.5.1 → 1.5.2 | - | `minor` | 1.5.1 → 1.6.0 | - | `major` | 1.5.1 → 2.0.0 | - | `patch-rc` | 1.5.1 → 1.5.2.rc1 | - | `minor-rc` | 1.5.1 → 1.6.0.rc1 | - | `major-rc` | 1.5.1 → 2.0.0.rc1 | - | `next-rc` | 1.6.0.rc1 → 1.6.0.rc2 | - | `promote` | 1.6.0.rc2 → 1.6.0 | +A PR that needs no release (docs, CI, tests) gets the `internal` label. -When several pending changesets touch the same package, the largest bump wins. -Mixing stable and rc types for one package, or combining `promote` with -anything else, is rejected. Only rc types are allowed on branches other than -`main`. - -While a package is at an rc (e.g. `1.6.0.rc1`), only `next-rc` and `promote` -are accepted for it, so fixes land in the next rc and the planned `1.6.0` still -ships. Any other type would skip it (`patch` would release `1.6.1`). To move -to a different version line, use the Manual Version Bump workflow below. - -## How releases happen - -1. Every PR is checked by the **Changeset** workflow; invalid changesets fail - the check. -2. On each push to `main`, **Package Release** applies all pending changesets - and opens (or updates) the `Release: ...` PR with the version bumps and - release notes, then deletes the changesets it used. Changesets used by an - rc release are kept instead (and recorded in `.changeset/pre.json`) until - that package's next stable release, normally `promote`, whose release notes - then list every change since the last stable version. -3. Merging that release PR tags each bumped package, publishes it to PyPI and - creates its GitHub Release. - -Changes that don't need a release (docs, CI, tests) don't need a changeset. - -## Manual version bump - -As a fallback, run the **Manual Version Bump** workflow with a package and -bump type. It opens a `release/-v` PR without reading any -changeset; merging it publishes the same way as a changeset release PR. -It doesn't touch `.changeset/`, so changesets kept from rc releases stay until -that package's next changeset stable release. - -The two flows don't know about each other: a manual bump doesn't close an open -`Release: ...` changeset PR for the same package (or the other way round), and -both change that package's version, so once one merges the other conflicts. -Close the stale one before merging. +Pre-releases (`1.6.0-rc.1`) are not a changeset level: run the Pre-release PR +workflow. See [RELEASING.md](../RELEASING.md). diff --git a/.github/changesets.py b/.github/changesets.py deleted file mode 100644 index a4722fdd4..000000000 --- a/.github/changesets.py +++ /dev/null @@ -1,294 +0,0 @@ -"""Consume pending .changeset/*.md files and bump package versions. - -A changeset looks like: - - --- - "livekit-rtc": patch - "livekit-api": minor-rc - --- - - Summary of the change. - -Supported bump types: patch, minor, major, patch-rc, minor-rc, major-rc, -next-rc, promote. When several changesets touch the same package, the -largest bump wins (an explicit X-rc wins over next-rc). Mixing stable and -rc bumps, or combining promote with anything else, is an error. While a -package is at an rc, only next-rc and promote are accepted for it. - -Changesets used by an rc release are kept and recorded in .changeset/pre.json -(package -> file names) instead of being deleted, so later runs skip them. The -package's next stable release (normally promote) lists them in its release -notes and deletes them. -""" - -from __future__ import annotations - -import json -import os -import pathlib -import re -import subprocess - -import click -from packaging.version import Version -from update_versions import PACKAGES, do_bump, do_prerelease, read_version - -CHANGESET_DIR = pathlib.Path(".changeset") -# Changesets already released in an rc, kept until the package's stable release -PRE_STATE = CHANGESET_DIR / "pre.json" - -# Names accepted in changeset frontmatter -> key in PACKAGES -PACKAGE_ALIASES = { - "livekit": "livekit", - "livekit-rtc": "livekit", - "livekit-api": "livekit-api", - "livekit-protocol": "livekit-protocol", -} - -STABLE = {"patch": 1, "minor": 2, "major": 3} -RC = {"patch-rc": 1, "minor-rc": 2, "major-rc": 3} -BUMP_TYPES = set(STABLE) | set(RC) | {"next-rc", "promote"} - - -def parse_changeset(path: pathlib.Path) -> tuple[dict[str, str], str]: - m = re.match(r"^---\s*\n(.*?)\n?---\s*\n?(.*)$", path.read_text(), re.DOTALL) - if not m: - raise click.ClickException(f"{path}: missing '---' frontmatter") - - bumps: dict[str, str] = {} - for line in m.group(1).splitlines(): - line = line.strip() - if not line or line.startswith("#"): - continue - lm = re.fullmatch(r'[\'"]?([\w.\-]+)[\'"]?\s*:\s*[\'"]?([\w\-]+)[\'"]?', line) - if not lm: - raise click.ClickException(f"{path}: cannot parse line {line!r}") - name, kind = lm.groups() - if name not in PACKAGE_ALIASES: - raise click.ClickException( - f"{path}: unknown package {name!r} (expected one of {sorted(PACKAGE_ALIASES)})" - ) - if kind not in BUMP_TYPES: - raise click.ClickException( - f"{path}: unknown bump type {kind!r} (expected one of {sorted(BUMP_TYPES)})" - ) - bumps[PACKAGE_ALIASES[name]] = kind - return bumps, m.group(2).strip() - - -def resolve(package: str, kinds: set[str]) -> str: - if "promote" in kinds: - if len(kinds) > 1: - raise click.ClickException( - f"{package}: 'promote' cannot be combined with {sorted(kinds - {'promote'})}" - ) - return "promote" - - stable = kinds & STABLE.keys() - if stable and kinds - stable: - raise click.ClickException(f"{package}: cannot mix stable and rc bumps ({sorted(kinds)})") - if stable: - return max(stable, key=STABLE.__getitem__) - - explicit_rc = kinds & RC.keys() - if explicit_rc: - return max(explicit_rc, key=RC.__getitem__) - return "next-rc" - - -def validate(package: str, kind: str) -> None: - cur = Version(read_version(pathlib.Path(PACKAGES[package]))) - if kind == "next-rc" and not (cur.pre and cur.pre[0] == "rc"): - raise click.ClickException(f"{package}: next-rc requires an rc version (got {cur})") - if kind == "promote" and not cur.is_prerelease: - raise click.ClickException(f"{package}: promote requires a pre-release (got {cur})") - # Any other bump would move past the rc's planned stable version, e.g. - # patch on 1.4.0.rc1 releases 1.4.1 and 1.4.0 never ships. - if cur.is_prerelease and kind not in ("next-rc", "promote"): - raise click.ClickException( - f"{package}: {kind} is not allowed while at pre-release {cur}; " - "use next-rc or promote (or the Manual Version Bump workflow)" - ) - - -def apply(package: str, kind: str) -> None: - if kind in STABLE: - do_bump(package, kind) - elif kind in RC: - do_bump(package, kind.removesuffix("-rc")) - do_prerelease(package, "rc") - elif kind == "next-rc": - do_prerelease(package, "rc") - elif kind == "promote": - do_bump(package, "release") - - -def changeset_origin(path: pathlib.Path, repo: str | None) -> str: - """Return " (#123 by @user)" for the PR that added this changeset, or "".""" - if not repo: - return "" - try: - sha = subprocess.run( - ["git", "log", "--diff-filter=A", "--format=%H", "-1", "--", str(path)], - capture_output=True, - text=True, - check=True, - ).stdout.strip() - if not sha: - return "" - pr = subprocess.run( - [ - "gh", - "api", - f"repos/{repo}/commits/{sha}/pulls", - "--jq", - '.[0] // empty | "\\(.number) \\(.user.login)"', - ], - capture_output=True, - text=True, - check=True, - ).stdout.split() - except (OSError, subprocess.CalledProcessError) as e: - click.echo(f"warning: cannot resolve PR for {path}: {e}", err=True) - return "" - if len(pr) == 2: - return f" (#{pr[0]} by @{pr[1]})" - return f" ({sha[:7]})" - - -def kept_entries(names: list[str], package: str, repo: str | None) -> list[str]: - """Release-note entries for this package from changesets kept since its rc releases.""" - entries = [] - for name in names: - path = CHANGESET_DIR / name - bumps, summary = parse_changeset(path) - if summary and package in bumps: - entries.append(f"`{bumps[package]}` {summary}{changeset_origin(path, repo)}") - return entries - - -@click.command() -@click.option( - "--rc-only", - is_flag=True, - default=False, - help="Reject stable bumps (used for non-main branches).", -) -@click.option( - "--notes", - type=click.Path(dir_okay=False, path_type=pathlib.Path), - default=None, - help="Write release notes (markdown) to this file.", -) -@click.option( - "--repo", - envvar="GITHUB_REPOSITORY", - default=None, - help="owner/name used to look up the PR and author of each changeset (needs gh).", -) -@click.option( - "--check", - is_flag=True, - default=False, - help="Only validate the pending changesets; don't change any file.", -) -def main(rc_only: bool, notes: pathlib.Path | None, repo: str | None, check: bool) -> None: - pre: dict[str, list[str]] = json.loads(PRE_STATE.read_text()) if PRE_STATE.exists() else {} - kept = {name for names in pre.values() for name in names} - # A kept changeset still owes its entry to the stable release notes. - missing = sorted(name for name in kept if not (CHANGESET_DIR / name).exists()) - if missing: - raise click.ClickException( - f"changesets kept from rc releases are missing: {missing} " - f"(restore them, or remove them from {PRE_STATE} on purpose)" - ) - # Parse them now too, so a broken kept changeset fails the PR check - # instead of the stable release. - for name in sorted(kept): - parse_changeset(CHANGESET_DIR / name) - files = sorted( - p - for p in CHANGESET_DIR.glob("*.md") - if p.name.lower() != "readme.md" and p.name not in kept - ) - - kinds: dict[str, set[str]] = {} - summaries: dict[str, list[str]] = {} - packages_of: dict[str, set[str]] = {} - for path in files: - bumps, summary = parse_changeset(path) - packages_of[path.name] = set(bumps) - if summary and not check: - summary += changeset_origin(path, repo) - for package, kind in bumps.items(): - kinds.setdefault(package, set()).add(kind) - if summary: - # Each entry shows the bump type its changeset asked for. - summaries.setdefault(package, []).append(f"`{kind}` {summary}") - - resolved = {package: resolve(package, k) for package, k in kinds.items()} - if rc_only: - stable = {p: k for p, k in resolved.items() if k in STABLE or k == "promote"} - if stable: - raise click.ClickException( - f"only rc releases are allowed from non-main branches (got {stable})" - ) - # Validate everything before touching any version file. - for package, kind in resolved.items(): - validate(package, kind) - - if check: - click.echo(f"{len(files)} changeset(s) valid ({len(kept)} kept from rc releases).") - for package in PACKAGES: - if package in resolved: - cur = read_version(pathlib.Path(PACKAGES[package])) - click.echo(f" {package}: {cur} ({resolved[package]})") - return - - lines: list[str] = [] - released: list[str] = [] - for package in PACKAGES: # stable order - if package not in resolved: - continue - kind = resolved[package] - apply(package, kind) - version = read_version(pathlib.Path(PACKAGES[package])) - released.append(f"{package} v{version}") - lines.append(f"## {package} v{version} ({kind})\n") - entries = summaries.get(package, []) - if kind in RC or kind == "next-rc": - # Keep this rc's changesets for the stable release notes. - pre.setdefault(package, []).extend( - p.name for p in files if package in packages_of[p.name] - ) - else: - # A stable release (normally promote) also lists the changesets - # kept since this package's rc releases. - entries = kept_entries(pre.pop(package, []), package, repo) + entries - for summary in entries: - lines.append("- " + summary.replace("\n", "\n ")) - lines.append("") - - # Changesets are consumed once applied (including ones listing no package), - # except those still kept for a package's stable release. - still_kept = {name for names in pre.values() for name in names} - for name in {p.name for p in files} | kept: - if name not in still_kept: - (CHANGESET_DIR / name).unlink(missing_ok=True) - if pre: - PRE_STATE.write_text(json.dumps(pre, indent=2, sort_keys=True) + "\n") - else: - PRE_STATE.unlink(missing_ok=True) - - if notes is not None: - notes.write_text("\n".join(lines)) - - title = ", ".join(released) - print(f"Release: {title or '(nothing to release)'}") - if gh_output := os.environ.get("GITHUB_OUTPUT"): - with open(gh_output, "a") as f: - f.write(f"title={title}\n") - - -if __name__ == "__main__": - main() diff --git a/.github/update_versions.py b/.github/update_versions.py deleted file mode 100644 index 691fd8a54..000000000 --- a/.github/update_versions.py +++ /dev/null @@ -1,149 +0,0 @@ -import pathlib -import re -import click -from packaging.version import Version - -PACKAGES = { - "livekit": "livekit-rtc/livekit/rtc/version.py", - "livekit-api": "livekit-api/livekit/api/version.py", - "livekit-protocol": "livekit-protocol/livekit/protocol/version.py", -} - -TAG_PREFIXES = { - "livekit": "rtc", - "livekit-api": "api", - "livekit-protocol": "protocol", -} - - -def _esc(*codes: int) -> str: - return "\033[" + ";".join(str(c) for c in codes) + "m" - - -def read_version(f: pathlib.Path) -> str: - text = f.read_text() - m = re.search(r'__version__\s*=\s*[\'"]([^\'"]+)[\'"]', text) - if not m: - raise ValueError(f"could not find __version__ in {f}") - return m.group(1) - - -def write_new_version(f: pathlib.Path, new_version: str) -> None: - text = f.read_text() - new_text = re.sub( - r'__version__\s*=\s*[\'"][^\'"]*[\'"]', - f'__version__ = "{new_version}"', - text, - count=1, - ) - f.write_text(new_text) - - -def bump_version(cur: str, bump_type: str) -> str: - v = Version(cur) - if bump_type == "release": - return v.base_version - if bump_type == "patch": - return f"{v.major}.{v.minor}.{v.micro + 1}" - if bump_type == "minor": - return f"{v.major}.{v.minor + 1}.0" - if bump_type == "major": - return f"{v.major + 1}.0.0" - raise ValueError(f"unknown bump type: {bump_type}") - - -def bump_prerelease(cur: str, bump_type: str) -> str: - v = Version(cur) - base = v.base_version - if bump_type == "rc": - if v.pre and v.pre[0] == "rc": - next_rc = v.pre[1] + 1 - else: - next_rc = 1 - return f"{base}.rc{next_rc}" - raise ValueError(f"unknown prerelease bump type: {bump_type}") - - -def update_api_protocol_dependency(new_protocol_version: str) -> None: - """Update livekit-api's dependency on livekit-protocol.""" - pyproject = pathlib.Path("livekit-api/pyproject.toml") - if not pyproject.exists(): - return - old_text = pyproject.read_text() - new_text = re.sub( - r'"livekit-protocol>=[\w.\-]+,', - f'"livekit-protocol>={new_protocol_version},', - old_text, - ) - if new_text != old_text: - pyproject.write_text(new_text) - print(f"Updated livekit-api dependency on livekit-protocol to >={new_protocol_version}") - - -def do_bump(package: str, bump_type: str) -> None: - version_path = PACKAGES[package] - vf = pathlib.Path(version_path) - cur = read_version(vf) - new = bump_version(cur, bump_type) - print(f"{package}: {_esc(31)}{cur}{_esc(0)} -> {_esc(32)}{new}{_esc(0)}") - write_new_version(vf, new) - - if package == "livekit-protocol": - update_api_protocol_dependency(new) - - -def do_prerelease(package: str, prerelease_type: str) -> None: - version_path = PACKAGES[package] - vf = pathlib.Path(version_path) - cur = read_version(vf) - new = bump_prerelease(cur, prerelease_type) - print(f"{package}: {_esc(31)}{cur}{_esc(0)} -> {_esc(32)}{new}{_esc(0)}") - write_new_version(vf, new) - - if package == "livekit-protocol": - update_api_protocol_dependency(new) - - -@click.command() -@click.option( - "--package", - type=click.Choice(list(PACKAGES.keys())), - required=True, - help="Package to bump.", -) -@click.option( - "--pre", - type=click.Choice(["rc", "none"]), - default="none", - help="Pre-release type.", -) -@click.option( - "--bump-type", - type=click.Choice(["patch", "minor", "major", "release"]), - default="patch", - help="Type of version bump.", -) -@click.option( - "--print-version", - is_flag=True, - default=False, - help="Print current version and tag prefix, don't bump.", -) -def bump(package: str, pre: str, bump_type: str, print_version: bool) -> None: - if print_version: - vf = pathlib.Path(PACKAGES[package]) - version = read_version(vf) - tag_prefix = TAG_PREFIXES[package] - # Output as key=value for easy parsing - print(f"version={version}") - print(f"tag_prefix={tag_prefix}") - return - - if pre == "none": - do_bump(package, bump_type) - else: - do_prerelease(package, pre) - - -if __name__ == "__main__": - bump() diff --git a/.github/workflows/changeset-check.yml b/.github/workflows/changeset-check.yml new file mode 100644 index 000000000..b906be8a4 --- /dev/null +++ b/.github/workflows/changeset-check.yml @@ -0,0 +1,24 @@ +# Fails a contributor PR that changes a versioned package without a +# changeset, with a comment that links to a prefilled changeset file. +# The `internal` label (config: [check] exempt_label) skips the check. +name: Changeset check + +on: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] + branches: [main] + +permissions: + contents: read + pull-requests: write + +jobs: + check: + # renovate/* PRs are dependency/security updates and never carry changesets + if: "!startsWith(github.event.pull_request.head.ref, 'renovate/')" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + with: + command: check diff --git a/.github/workflows/changeset-reminder.yml b/.github/workflows/changeset-reminder.yml deleted file mode 100644 index 508fea72f..000000000 --- a/.github/workflows/changeset-reminder.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Changeset Reminder - -# Comment once with a short format guide when a PR has no .changeset file, and -# delete that comment once one is added. -on: - # Needed for a write token on fork PRs. This workflow never checks out or - # runs PR code; it only reads the PR's file list through the API. - pull_request_target: - types: [opened, synchronize, reopened] - -permissions: - contents: read - -jobs: - remind: - name: Changeset reminder - if: | - !startsWith(github.event.pull_request.head.ref, 'release/changesets-') - && !startsWith(github.event.pull_request.head.ref, 'renovate/') - && !endsWith(github.event.pull_request.user.login, '[bot]') - runs-on: ubuntu-latest - permissions: - pull-requests: write - steps: - - name: Comment when the PR has no changeset - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - REPO: ${{ github.repository }} - run: | - marker="" - - files=$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/files" \ - --jq '.[] | "\(.status) \(.filename)"') - - # Dependency-only updates (lockfiles / package.json, and the root - # pyproject.toml, which is the unpublished workspace config) don't need - # a changeset. Package pyproject.toml files declare published runtime - # dependencies, so changing them still gets the reminder. - if [ -z "$(grep -vE '^[a-z]+ ((.*/)?([^/]+\.lock|package\.json|pnpm-lock\.yaml)|pyproject\.toml)$' <<< "$files")" ]; then - echo "Only dependency files changed, skipping" - exit 0 - fi - - changesets=$(grep -v '^removed ' <<< "$files" | cut -d' ' -f2- \ - | grep -E '^\.changeset/[^/]+\.md$' | grep -viE '/readme\.md$' || true) - existing=$(gh api --paginate "repos/$REPO/issues/$PR_NUMBER/comments" \ - --jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | contains(\"$marker\"))) | .id") - - if [ -n "$changesets" ]; then - echo "Changeset found:"; echo "$changesets" - # Drop the reminder once a changeset has been added - for id in $existing; do - gh api -X DELETE "repos/$REPO/issues/comments/$id" - done - exit 0 - fi - - if [ -n "$existing" ]; then - echo "Reminder already posted" - exit 0 - fi - - cat > "$RUNNER_TEMP/reminder.md" <<'EOF' - - 👋 This PR has no changeset. If it should be released, add a markdown file under `.changeset/` (any name, e.g. `.changeset/fix-token-parsing.md`): - - ```md - --- - "livekit-rtc": patch - --- - - Short description of the change, used in the release notes. - ``` - - - **Packages:** `livekit-rtc`, `livekit-api`, `livekit-protocol` (one line per package) - - **Types:** `patch`, `minor`, `major`, `patch-rc`, `minor-rc`, `major-rc`, `next-rc`, `promote` - - If this change doesn't need a release (docs, CI, tests), you can ignore this comment. - EOF - gh pr comment "$PR_NUMBER" --repo "$REPO" --body-file "$RUNNER_TEMP/reminder.md" diff --git a/.github/workflows/changeset.yml b/.github/workflows/changeset.yml deleted file mode 100644 index b7eb99fa4..000000000 --- a/.github/workflows/changeset.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Changeset - -# Validate .changeset files on every commit of every PR, with the same rules -# the Package Release workflow applies when it bumps versions. The reminder for -# PRs without a changeset lives in changeset-reminder.yml; keeping it separate -# means this workflow never reports a skipped "Validate changesets" check that -# could satisfy a required status check. -on: - pull_request: - types: [opened, synchronize, reopened] - -permissions: - contents: read - -jobs: - validate: - name: Validate changesets - # renovate/* PRs are dependency/security updates and never carry changesets - if: "!startsWith(github.event.pull_request.head.ref, 'renovate/')" - runs-on: ubuntu-latest - steps: - # Default ref is the PR merge commit, i.e. the base branch's versions plus - # every changeset that would be pending once this PR merges. - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - - - name: Set up Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 - with: - python-version: "3.10" - - - name: Install dependencies - run: pip install click packaging - - - name: Validate changesets - env: - BASE_BRANCH: ${{ github.base_ref }} - run: | - # Only RC releases are allowed from non-main branches - args=() - if [ "$BASE_BRANCH" != "main" ]; then - args+=(--rc-only) - fi - - if ! out=$(python .github/changesets.py --check "${args[@]}" 2>&1); then - echo "$out" - echo "::error title=Invalid changeset::${out#Error: }" - exit 1 - fi - echo "$out" diff --git a/.github/workflows/manual-version-bump.yml b/.github/workflows/manual-version-bump.yml deleted file mode 100644 index a68ed5404..000000000 --- a/.github/workflows/manual-version-bump.yml +++ /dev/null @@ -1,152 +0,0 @@ -name: Manual Version Bump - -# Fallback for the changeset flow: bump one package by hand and open a release -# PR. Merging that PR publishes through the Package Release workflow. -on: - workflow_dispatch: - inputs: - package: - description: "Package to publish" - type: choice - required: true - options: - - livekit - - livekit-api - - livekit-protocol - version: - description: "What to publish" - type: choice - required: true - options: - - "patch (1.5.1 → 1.5.2)" - - "minor (1.5.1 → 1.6.0)" - - "major (1.5.1 → 2.0.0)" - - "patch-rc (1.5.1 → 1.5.2.rc1)" - - "minor-rc (1.5.1 → 1.6.0.rc1)" - - "major-rc (1.5.1 → 2.0.0.rc1)" - - "next-rc (.rc1 → .rc2)" - - "promote (1.6.0.rc2 → 1.6.0)" - branch: - description: "Branch to publish from (default: main)" - type: string - required: false - default: "main" - -permissions: - contents: write - pull-requests: write - -jobs: - bump: - name: Create release PR - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - with: - ref: ${{ inputs.branch }} - submodules: true - - - name: Guard non-main branches - env: - INPUT_VERSION: ${{ inputs.version }} - INPUT_BRANCH: ${{ inputs.branch }} - run: | - key=$(echo "$INPUT_VERSION" | awk '{print $1}') - if [ "$INPUT_BRANCH" != "main" ]; then - case "$key" in - *-rc|next-rc) ;; # allowed - *) echo "::error::Only RC releases are allowed from non-main branches (got '$key' on '$INPUT_BRANCH')"; exit 1 ;; - esac - fi - - - name: Set up Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 - with: - python-version: "3.10" - - - name: Install dependencies - run: pip install click packaging - - - name: Bump version - env: - INPUT_VERSION: ${{ inputs.version }} - INPUT_PACKAGE: ${{ inputs.package }} - run: | - key=$(echo "$INPUT_VERSION" | awk '{print $1}') - pkg="$INPUT_PACKAGE" - - case "$key" in - patch|minor|major) - python .github/update_versions.py --package "$pkg" --bump-type "$key" - ;; - patch-rc|minor-rc|major-rc) - bump="${key%-rc}" - python .github/update_versions.py --package "$pkg" --bump-type "$bump" - python .github/update_versions.py --package "$pkg" --pre rc - ;; - next-rc) - python .github/update_versions.py --package "$pkg" --pre rc - ;; - promote) - python .github/update_versions.py --package "$pkg" --bump-type release - ;; - esac - - - name: Read new version - id: version - env: - INPUT_PACKAGE: ${{ inputs.package }} - run: | - eval "$(python .github/update_versions.py --package "$INPUT_PACKAGE" --print-version)" - echo "version=$version" >> "$GITHUB_OUTPUT" - echo "tag_prefix=$tag_prefix" >> "$GITHUB_OUTPUT" - echo "Package: $INPUT_PACKAGE, New version: $version, Tag: ${tag_prefix}-v${version}" - - - name: Close existing release PRs for this package - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG_PREFIX: ${{ steps.version.outputs.tag_prefix }} - run: | - prefix="release/${TAG_PREFIX}-v" - gh pr list --state open --json number,headRefName \ - --jq ".[] | select(.headRefName | startswith(\"$prefix\")) | .number" | while read -r pr; do - echo "Superseding release PR #$pr" - gh pr comment "$pr" --body "Superseded by a new release." - gh pr close "$pr" --delete-branch || true - done - - - name: Create release PR - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION: ${{ steps.version.outputs.version }} - TAG_PREFIX: ${{ steps.version.outputs.tag_prefix }} - INPUT_BRANCH: ${{ inputs.branch }} - INPUT_PACKAGE: ${{ inputs.package }} - INPUT_VERSION: ${{ inputs.version }} - ACTOR: ${{ github.actor }} - run: | - branch="release/${TAG_PREFIX}-v${VERSION}" - key=$(echo "$INPUT_VERSION" | awk '{print $1}') - - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git checkout -b "$branch" - git add -A - git commit -m "${TAG_PREFIX}-v${VERSION}" - git push --force origin "$branch" - - # Same section format as the changeset release PR, so Package Release - # can take the GitHub release notes from it. - { - echo "Merging this PR will publish the following packages to PyPI:" - echo - echo "## ${INPUT_PACKAGE} v${VERSION} (${key})" - echo - echo "- Manual version bump by @${ACTOR}." - } > "$RUNNER_TEMP/pr-body.md" - - gh pr create \ - --base "$INPUT_BRANCH" \ - --head "$branch" \ - --title "${INPUT_PACKAGE} v${VERSION}" \ - --body-file "$RUNNER_TEMP/pr-body.md" diff --git a/.github/workflows/package-release.yml b/.github/workflows/package-release.yml deleted file mode 100644 index e728c4679..000000000 --- a/.github/workflows/package-release.yml +++ /dev/null @@ -1,497 +0,0 @@ -name: Package Release - -on: - # Step 1: A push to main (e.g. a merged PR, including from forks) or a manual - # run consumes pending .changeset files and opens/updates the release PR with - # the version bumps. This runs on `push` rather than `pull_request` so it gets - # a write-capable token for fork contributions too. - push: - branches: [main] - - workflow_dispatch: - inputs: - branch: - description: "Branch to release from (default: main)" - type: string - required: false - default: "main" - - # Step 2: Merging the release PR triggers build + publish - pull_request: - types: [closed] - -# Read-only by default; jobs that write ask for it themselves, so build jobs -# (which run third-party build code) never get a write or OIDC token. -permissions: - contents: read - -jobs: - # ── Step 1: Create / update the release PR from changesets ──── - bump: - name: Create release PR - if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - concurrency: - group: package-release-${{ inputs.branch || github.ref_name }} - cancel-in-progress: true - env: - BASE_BRANCH: ${{ inputs.branch || github.ref_name }} - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - with: - ref: ${{ env.BASE_BRANCH }} - # Full history to find the commit (and PR) that added each changeset - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 - with: - python-version: "3.10" - - - name: Install dependencies - run: pip install click packaging - - - name: Apply changesets - id: changesets - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Only RC releases are allowed from non-main branches - args=() - if [ "$BASE_BRANCH" != "main" ]; then - args+=(--rc-only) - fi - python .github/changesets.py --notes "$RUNNER_TEMP/release-notes.md" "${args[@]}" - - - name: Create or update release PR - if: steps.changesets.outputs.title != '' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TITLE: ${{ steps.changesets.outputs.title }} - run: | - branch="release/changesets-${BASE_BRANCH//\//-}" - - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git checkout -b "$branch" - git add -A - git commit -m "Release: ${TITLE}" - git push --force origin "$branch" - - { - echo "Merging this PR will publish the following packages to PyPI:" - echo - cat "$RUNNER_TEMP/release-notes.md" - } > "$RUNNER_TEMP/pr-body.md" - - existing=$(gh pr list --state open --head "$branch" --base "$BASE_BRANCH" --json number --jq '.[0].number // empty') - if [ -n "$existing" ]; then - gh pr edit "$existing" --title "Release: ${TITLE}" --body-file "$RUNNER_TEMP/pr-body.md" - else - gh pr create \ - --base "$BASE_BRANCH" \ - --head "$branch" \ - --title "Release: ${TITLE}" \ - --body-file "$RUNNER_TEMP/pr-body.md" - fi - - # Pending changesets can disappear after the release PR was opened (e.g. - # reverted); merging that stale PR would still publish. - - name: Close stale release PR - if: steps.changesets.outputs.title == '' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - branch="release/changesets-${BASE_BRANCH//\//-}" - existing=$(gh pr list --state open --head "$branch" --base "$BASE_BRANCH" --json number --jq '.[0].number // empty') - if [ -n "$existing" ]; then - gh pr comment "$existing" --body "Closing: no pending changesets left to release." - gh pr close "$existing" --delete-branch - fi - - # ── Step 2: Publish on merge ────────────────────────────────── - detect: - name: Detect packages - # Only release PRs opened by a bump job (same repo, github-actions[bot], - # release/* branch: release/changesets-* from this workflow or - # release/-v from Manual Version Bump) may trigger - # publishing; the branch name alone is not trusted. - if: | - github.event_name == 'pull_request' - && github.event.pull_request.merged == true - && startsWith(github.event.pull_request.head.ref, 'release/') - && github.event.pull_request.head.repo.full_name == github.repository - && github.event.pull_request.user.login == 'github-actions[bot]' - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: read - outputs: - rtc: ${{ steps.detect.outputs.rtc }} - api: ${{ steps.detect.outputs.api }} - protocol: ${{ steps.detect.outputs.protocol }} - tags: ${{ steps.detect.outputs.tags }} - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - with: - ref: ${{ github.event.pull_request.merge_commit_sha }} - - - name: Set up Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 - with: - python-version: "3.10" - - - name: Install dependencies - run: pip install click packaging - - - name: Detect bumped packages - id: detect - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - REPO: ${{ github.repository }} - run: | - # A package is released when the release PR changed its version.py - files=$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/files" --jq '.[].filename') - - tags=() - for entry in "rtc:livekit:livekit-rtc/livekit/rtc/version.py" \ - "api:livekit-api:livekit-api/livekit/api/version.py" \ - "protocol:livekit-protocol:livekit-protocol/livekit/protocol/version.py"; do - IFS=: read -r key package path <<< "$entry" - if grep -qxF "$path" <<< "$files"; then - eval "$(python .github/update_versions.py --package "$package" --print-version)" - tags+=("${tag_prefix}-v${version}") - echo "$key=true" >> "$GITHUB_OUTPUT" - echo "Releasing $package v$version" - else - echo "$key=false" >> "$GITHUB_OUTPUT" - fi - done - - echo "tags=${tags[*]}" >> "$GITHUB_OUTPUT" - - tag: - name: Tag & create GitHub releases - needs: detect - if: needs.detect.outputs.tags != '' - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - with: - ref: ${{ github.event.pull_request.merge_commit_sha }} - - - name: Create git tags - env: - TAGS: ${{ needs.detect.outputs.tags }} - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - for tag in $TAGS; do - git tag "$tag" - git push origin "$tag" - done - - - name: Create GitHub releases - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAGS: ${{ needs.detect.outputs.tags }} - PR_BODY: ${{ github.event.pull_request.body }} - PR_NUMBER: ${{ github.event.pull_request.number }} - run: | - printf '%s\n' "$PR_BODY" > "$RUNNER_TEMP/pr-body.md" - - for tag in $TAGS; do - prefix="${tag%%-v*}" - version="${tag#*-v}" - case "$prefix" in - rtc) package="livekit" ;; - api) package="livekit-api" ;; - protocol) package="livekit-protocol" ;; - esac - - # Take this package's "## v (...)" section from - # the release PR body (written from the consumed changesets) - notes="$RUNNER_TEMP/notes-$tag.md" - awk -v heading="## $package v$version " ' - index($0, heading) == 1 { found = 1; next } - found && /^## / { exit } - # Buffer blank lines so leading/trailing ones are dropped - found && /^[[:space:]]*$/ { if (started) blank = blank "\n"; next } - found { printf "%s%s\n", blank, $0; blank = ""; started = 1 } - ' "$RUNNER_TEMP/pr-body.md" > "$notes" - if ! grep -q '[^[:space:]]' "$notes"; then - echo "Released from #$PR_NUMBER." > "$notes" - fi - - args=() - if [[ "$version" == *rc* ]]; then - args+=(--prerelease) - fi - # Created as a draft; each publish job makes its release public - # only after the PyPI upload succeeds. - gh release create "$tag" \ - --draft \ - --verify-tag \ - --title "$package v$version" \ - --notes-file "$notes" \ - "${args[@]}" - done - - # ── RTC builds (multi-platform) ────────────────────────────── - build-rtc: - name: Build RTC wheels (${{ matrix.archs }}) - needs: detect - if: needs.detect.outputs.rtc == 'true' - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-latest - archs: x86_64 - - os: namespace-profile-default-arm64 - archs: aarch64 - - os: windows-latest - archs: AMD64 - - os: windows-11-arm - archs: ARM64 - - os: macos-latest - archs: x86_64 arm64 - defaults: - run: - working-directory: ./livekit-rtc - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - with: - submodules: true - - - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 - id: setup-python - with: - python-version: "3.11" - - - name: Build wheels - run: pipx run --python '${{ steps.setup-python.outputs.python-path }}' cibuildwheel==3.3.1 --output-dir dist - env: - CIBW_ARCHS: ${{ matrix.archs }} - - - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - name: dist-rtc-${{ matrix.os }} - path: livekit-rtc/dist/*.whl - - build-rtc-sdist: - name: Build RTC sdist - needs: detect - if: needs.detect.outputs.rtc == 'true' - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./livekit-rtc - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - with: - submodules: true - - - name: Build sdist - run: | - pip3 install build - python3 -m build --sdist - - - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - name: dist-rtc-sdist - path: livekit-rtc/dist/*.tar.gz - - publish-rtc: - name: Publish livekit (RTC) - needs: [detect, build-rtc, build-rtc-sdist, tag] - if: needs.detect.outputs.rtc == 'true' - runs-on: ubuntu-latest - environment: pypi - permissions: - contents: write - id-token: write - steps: - - name: Download build artifacts - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 - with: - pattern: dist-rtc-* - path: dist - merge-multiple: true - - - name: List distributions - run: ls -la dist/ - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 - - - name: Publish GitHub release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAGS: ${{ needs.detect.outputs.tags }} - run: | - for tag in $TAGS; do - if [[ "$tag" == rtc-v* ]]; then - gh release edit "$tag" --repo "$GITHUB_REPOSITORY" --draft=false - fi - done - - # ── API build ──────────────────────────────────────────────── - build-api: - name: Build API - needs: detect - if: needs.detect.outputs.api == 'true' - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./livekit-api - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - with: - submodules: true - - - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 - - - name: Build wheel & sdist - run: | - pip3 install build wheel - python3 -m build --wheel --sdist - - - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - name: dist-api - path: | - livekit-api/dist/*.whl - livekit-api/dist/*.tar.gz - - publish-api: - name: Publish livekit-api - needs: [detect, build-api, tag] - if: needs.detect.outputs.api == 'true' - runs-on: ubuntu-latest - environment: pypi - permissions: - contents: write - id-token: write - steps: - - name: Download build artifact - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 - with: - name: dist-api - path: dist/ - - - name: List distributions - run: ls -la dist/ - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 - - - name: Publish GitHub release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAGS: ${{ needs.detect.outputs.tags }} - run: | - for tag in $TAGS; do - if [[ "$tag" == api-v* ]]; then - gh release edit "$tag" --repo "$GITHUB_REPOSITORY" --draft=false - fi - done - - # ── Protocol build ─────────────────────────────────────────── - build-protocol: - name: Build Protocol - needs: detect - if: needs.detect.outputs.protocol == 'true' - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./livekit-protocol - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - with: - submodules: true - - - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 - - - name: Build wheel & sdist - run: | - pip3 install build wheel - python3 -m build --wheel --sdist - - - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - name: dist-protocol - path: | - livekit-protocol/dist/*.whl - livekit-protocol/dist/*.tar.gz - - publish-protocol: - name: Publish livekit-protocol - needs: [detect, build-protocol, tag] - if: needs.detect.outputs.protocol == 'true' - runs-on: ubuntu-latest - environment: pypi - permissions: - contents: write - id-token: write - steps: - - name: Download build artifact - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 - with: - name: dist-protocol - path: dist/ - - - name: List distributions - run: ls -la dist/ - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 - - - name: Publish GitHub release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAGS: ${{ needs.detect.outputs.tags }} - run: | - for tag in $TAGS; do - if [[ "$tag" == protocol-v* ]]; then - gh release edit "$tag" --repo "$GITHUB_REPOSITORY" --draft=false - fi - done - - # ── Docs ───────────────────────────────────────────────────── - docs-rtc: - name: Build RTC docs - needs: [detect, publish-rtc] - if: needs.detect.outputs.rtc == 'true' - uses: ./.github/workflows/build-docs.yml - with: - package_dir: livekit-rtc - package_name: livekit.rtc - secrets: inherit - - docs-api: - name: Build API docs - needs: [detect, publish-api] - if: needs.detect.outputs.api == 'true' - uses: ./.github/workflows/build-docs.yml - with: - package_dir: livekit-api - package_name: livekit.api - secrets: inherit - - docs-protocol: - name: Build Protocol docs - needs: [detect, publish-protocol] - if: needs.detect.outputs.protocol == 'true' - uses: ./.github/workflows/build-docs.yml - with: - package_dir: livekit-protocol - package_name: livekit.protocol - secrets: inherit diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 000000000..86debc634 --- /dev/null +++ b/.github/workflows/pre-release.yml @@ -0,0 +1,27 @@ +# On demand: open an rc PR from the branch the workflow is run on. It +# carries every package with a pending changeset, each at its own rc +# version. The levels come from the changesets. Merging the PR tags +# 1.6.0-rc.1; the next run numbers rc.2. Changesets stay pending for the +# final release. +name: Pre-release PR + +on: + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + with: + fetch-depth: 0 # the tags number the rc + - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + with: + command: pre-release + args: --target ${{ github.ref_name }} + app-client-id: ${{ secrets.VERWALTER_RELEASE_CLIENT_ID }} + app-private-key: ${{ secrets.VERWALTER_RELEASE_APP_KEY }} diff --git a/.github/workflows/release-gate.yml b/.github/workflows/release-gate.yml index 7ed81085a..00e453303 100644 --- a/.github/workflows/release-gate.yml +++ b/.github/workflows/release-gate.yml @@ -27,8 +27,8 @@ jobs: exit 0 fi - if [ "$PR_AUTHOR" != "github-actions[bot]" ]; then - echo "::error::Release PRs must be created by the publish workflow, not by '$PR_AUTHOR'" + if [ "$PR_AUTHOR" != "verwalter-release[bot]" ] && [ "$PR_AUTHOR" != "github-actions[bot]" ]; then + echo "::error::Release PRs must be created by verwalter (release-pr.yml or pre-release.yml), not by '$PR_AUTHOR'" exit 1 fi diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml new file mode 100644 index 000000000..d6a94f2c9 --- /dev/null +++ b/.github/workflows/release-pr.yml @@ -0,0 +1,30 @@ +# Keeps one release PR open while changesets are pending. Runs on every +# push to main and regenerates the release branch from main. +name: Release PRs + +on: + push: + branches: [main] + +permissions: + contents: write + pull-requests: write + +concurrency: + group: release-prs + cancel-in-progress: true + +jobs: + pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + with: + fetch-depth: 0 # the commit that added a changeset gives its changelog line the PR and author + - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + with: + command: pr + # A GitHub App token lets the release PRs trigger CI; the default + # github.token does not. Without these secrets, github.token is used. + app-client-id: ${{ secrets.VERWALTER_RELEASE_CLIENT_ID }} + app-private-key: ${{ secrets.VERWALTER_RELEASE_APP_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..3ae1c6279 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,294 @@ +# After a release PR merges: build every package, then tag and create the +# GitHub releases (drafts), then upload to PyPI and make the releases +# public. The step that cannot be undone comes last. +name: Release + +on: + # No `branches` filter: an rc PR from pre-release.yml targets the branch + # the workflow was run on. The `guard` job decides which PRs release. + pull_request: + types: [closed] + # A failed job is re-run with "Re-run failed jobs" on the run itself: + # that keeps the merge commit. This trigger is for a run that needs a + # fixed workflow file from the branch. `verwalter release` resumes from + # the current state and skips what is done. + workflow_dispatch: + inputs: + ref: + description: Commit or tag to build and publish. Set it to the release tag when the tag exists. Empty is the branch head. + required: false + default: "" + package: + description: Only this package; always reported to the publish job. + required: false + default: "" + +# Read-only by default: build jobs run third-party build code and never get +# a write or OIDC token. +permissions: + contents: read + +jobs: + guard: + # Only a release PR that verwalter opened: the branch prefix alone would + # let any pushed `release/*` branch trigger a publish. The author is the + # verwalter-release GitHub App, or github-actions[bot] without the App. + if: >- + github.event_name == 'workflow_dispatch' + || (github.event.pull_request.merged == true + && startsWith(github.event.pull_request.head.ref, 'release/') + && github.event.pull_request.head.repo.full_name == github.repository + && (github.event.pull_request.user.login == 'verwalter-release[bot]' || github.event.pull_request.user.login == 'github-actions[bot]') + && contains(github.event.pull_request.body, '')) + runs-on: ubuntu-latest + steps: + - run: echo "Release PR accepted" + + # ── Builds ─────────────────────────────────────────────────── + build-rtc: + name: Build RTC wheels (${{ matrix.archs }}) + needs: guard + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + archs: x86_64 + - os: namespace-profile-default-arm64 + archs: aarch64 + - os: windows-latest + archs: AMD64 + - os: windows-11-arm + archs: ARM64 + - os: macos-latest + archs: x86_64 arm64 + defaults: + run: + working-directory: ./livekit-rtc + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + with: + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + submodules: true + + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 + id: setup-python + with: + python-version: "3.11" + + - name: Build wheels + run: pipx run --python '${{ steps.setup-python.outputs.python-path }}' cibuildwheel==3.3.1 --output-dir dist + env: + CIBW_ARCHS: ${{ matrix.archs }} + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: dist-rtc-${{ matrix.os }} + path: livekit-rtc/dist/*.whl + + build-rtc-sdist: + name: Build RTC sdist + needs: guard + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./livekit-rtc + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + with: + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + submodules: true + + - name: Build sdist + run: | + pip3 install build + python3 -m build --sdist + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: dist-rtc-sdist + path: livekit-rtc/dist/*.tar.gz + + build: + name: Build ${{ matrix.package }} + needs: guard + runs-on: ubuntu-latest + strategy: + matrix: + package: [livekit-api, livekit-protocol] + defaults: + run: + working-directory: ./${{ matrix.package }} + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + with: + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + submodules: true + + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 + + - name: Build wheel & sdist + run: | + pip3 install build wheel + python3 -m build --wheel --sdist + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: dist-${{ matrix.package }} + path: | + ${{ matrix.package }}/dist/*.whl + ${{ matrix.package }}/dist/*.tar.gz + + # ── Tag & GitHub releases ──────────────────────────────────── + release: + needs: [build-rtc, build-rtc-sdist, build] + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + released: ${{ steps.verwalter.outputs.released }} + releases: ${{ steps.verwalter.outputs.releases }} + docs: ${{ steps.docs.outputs.packages }} + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + with: + # The merge commit itself: a push to main right after the merge + # must not move the tags. + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + fetch-depth: 0 + - id: verwalter + uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + with: + command: release + args: ${{ inputs.package && format('--package {0}', inputs.package) || '' }} + # The docs site holds one version per package: an rc must not replace + # the docs of the last final release. + - id: docs + env: + RELEASES: ${{ steps.verwalter.outputs.releases }} + run: echo "packages=$(jq -c '[.[] | select(.prerelease | not) | .package]' <<< "${RELEASES:-[]}")" >> "$GITHUB_OUTPUT" + + # ── PyPI ───────────────────────────────────────────────────── + # Uploads each released package with skip-existing, dependencies first, + # so a re-run completes a half-uploaded wheel set. `verwalter publish` + # then finds every version on PyPI and makes the draft releases public. + publish: + needs: release + if: needs.release.outputs.released == 'true' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + environment: pypi + permissions: + contents: write # the tool makes the draft releases public + id-token: write # trusted publishing + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + with: + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + fetch-depth: 0 # tags decide what is published + + - id: pkgs + env: + RELEASES: ${{ needs.release.outputs.releases }} + run: | + # A run by hand with nothing left to tag gets an empty list: then + # try every package. skip-existing skips what PyPI has. + if [ -z "$RELEASES" ] || [ "$RELEASES" = "[]" ]; then + echo 'packages=["livekit","livekit-api","livekit-protocol"]' >> "$GITHUB_OUTPUT" + else + echo "packages=$(jq -c '[.[].package]' <<< "$RELEASES")" >> "$GITHUB_OUTPUT" + fi + + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 + with: + pattern: dist-rtc-* + path: dist/livekit + merge-multiple: true + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 + with: + name: dist-livekit-api + path: dist/livekit-api + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 + with: + name: dist-livekit-protocol + path: dist/livekit-protocol + + - name: List distributions + run: ls -laR dist/ + + - name: Publish livekit-protocol + if: contains(fromJSON(steps.pkgs.outputs.packages), 'livekit-protocol') + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 + with: + packages-dir: dist/livekit-protocol/ + skip-existing: true + + - name: Publish livekit-api + if: contains(fromJSON(steps.pkgs.outputs.packages), 'livekit-api') + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 + with: + packages-dir: dist/livekit-api/ + skip-existing: true + + - name: Publish livekit + if: contains(fromJSON(steps.pkgs.outputs.packages), 'livekit') + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 + with: + packages-dir: dist/livekit/ + skip-existing: true + + - name: Make the GitHub releases public + uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + env: + GH_TOKEN: ${{ github.token }} + with: + command: publish + releases: ${{ needs.release.outputs.releases }} + + # The end state, asserted: fails when a tag is not on the remote, a GitHub + # release is missing or still a draft, or PyPI does not have the version. + verify: + needs: publish + runs-on: ubuntu-latest + permissions: + contents: write # reads only. A draft release is visible only with write access + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + with: + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + fetch-depth: 0 + - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + with: + command: status + args: --check + + # ── Docs (final versions only) ─────────────────────────────── + docs-rtc: + name: Build RTC docs + needs: [release, publish] + if: contains(fromJSON(needs.release.outputs.docs || '[]'), 'livekit') + uses: ./.github/workflows/build-docs.yml + with: + package_dir: livekit-rtc + package_name: livekit.rtc + secrets: inherit + + docs-api: + name: Build API docs + needs: [release, publish] + if: contains(fromJSON(needs.release.outputs.docs || '[]'), 'livekit-api') + uses: ./.github/workflows/build-docs.yml + with: + package_dir: livekit-api + package_name: livekit.api + secrets: inherit + + docs-protocol: + name: Build Protocol docs + needs: [release, publish] + if: contains(fromJSON(needs.release.outputs.docs || '[]'), 'livekit-protocol') + uses: ./.github/workflows/build-docs.yml + with: + package_dir: livekit-protocol + package_name: livekit.protocol + secrets: inherit diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 000000000..83a368020 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,71 @@ +# Releasing python-sdks + +This repository releases with [verwalter](https://github.com/livekit/verwalter). +The [verwalter cheat sheet](https://github.com/livekit/verwalter/blob/main/docs/cheat-sheet.md) +has the commands that every repository shares. This file holds what is +specific to this repository. + +## Packages + +| Package | Path | Tag | Goes to | +|---|---|---|---| +| `livekit` | `livekit-rtc` | `rtc-v` | PyPI: 5 wheel platforms, sdist | +| `livekit-api` | `livekit-api` | `api-v` | PyPI | +| `livekit-protocol` | `livekit-protocol` | `protocol-v` | PyPI | + +Each package keeps its version in `livekit//version.py`. + +`livekit-api` depends on `livekit-protocol`. A release of `livekit-protocol` +also releases `livekit-api` as a patch. The `livekit-protocol` floor in +`livekit-api/pyproject.toml` does not move on its own. Raise it in the PR that +needs the new protocol. + +## Workflows + +| File | Trigger | Does | +|---|---|---| +| `changeset-check.yml` | A PR opens or changes | Fails a package change with no changeset. | +| `release-pr.yml` | A push to `main` | Keeps the release PR `release/main` current. | +| `pre-release.yml` | Run by hand | Opens an rc PR from its branch. | +| `release-gate.yml` | A `release/*` PR or review | Requires the verwalter author and 2 approvals. | +| `release.yml` | The release PR merges | Builds, tags, uploads to PyPI, publishes the docs. | +| `build-docs.yml` | Called by `release.yml` | Uploads the pdoc docs of a final version to S3. | + +`changeset-check.yml` skips `renovate/*` branches. `release-gate.yml` is a +required check on `main`. + +## Release + +1. Merge the release PR. It needs 2 approvals. +2. Watch the run of `release.yml`: `gh run list --workflow release.yml --limit 1`. + +The `verify` job checks the end state. Each tag has a public GitHub release, +and PyPI has each version. For a final version, the docs job of the package +must also be green. + +## Pre-release + +Run `gh workflow run pre-release.yml --ref `. The pending changesets +decide the packages and the levels. The rc is `1.6.0-rc.1` in `version.py` and +in the tag. PyPI shows it as `1.6.0rc1`. The changesets stay pending for the +final release. + +## A release failed + +Find the cause first. The +[recovery section](https://github.com/livekit/verwalter/blob/main/docs/release-workflows.md#recovery) +has the paths by cause. + +| Situation | Command | +|---|---| +| A job failed for a transient reason | `gh run rerun --failed` | +| The workflow needed a fix, now on `main` | `gh workflow run release.yml -f ref=` | +| An rtc wheel build failed | Fix it on `main`, then `gh workflow run release.yml -f ref=` | +| The released commit is wrong | `verwalter release --abandon `, then a changeset and the next version | + +The PyPI upload skips files that PyPI has, so a re-run is safe. PyPI never +replaces a version. Yank a broken version on PyPI and release the next one. + +## Who to ask + +The owners in `.github/CODEOWNERS`. diff --git a/verwalter.toml b/verwalter.toml new file mode 100644 index 000000000..f461b4aed --- /dev/null +++ b/verwalter.toml @@ -0,0 +1,21 @@ +#:schema https://raw.githubusercontent.com/livekit/verwalter/main/schemas/v1.json + +[workspace] +members = ["livekit-rtc", "livekit-api", "livekit-protocol"] +exclude = ["python-sdks"] # the uv workspace root, never published + +[publish] +registry = "pypi" + +[packages.livekit] +versioning.files = [{ path = "livekit/rtc/version.py", regex = '__version__ = "(?[^"]+)"' }] +release.tag = "rtc-v{version}" + +[packages.livekit-api] +dependencies = ["livekit-protocol"] # the pyproject.toml requirement is not read: verwalter finds no dependency +versioning.files = [{ path = "livekit/api/version.py", regex = '__version__ = "(?[^"]+)"' }] +release.tag = "api-v{version}" + +[packages.livekit-protocol] +versioning.files = [{ path = "livekit/protocol/version.py", regex = '__version__ = "(?[^"]+)"' }] +release.tag = "protocol-v{version}" From a222430f34e590fb959a30b02d91775be53a2cfe Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 23 Nov 2026 10:20:47 +0100 Subject: [PATCH 2/6] Keep the package-release.yml name for PyPI trusted publishing Co-Authored-By: Claude Opus 5.5 --- .github/workflows/{release.yml => package-release.yml} | 2 +- RELEASING.md | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) rename .github/workflows/{release.yml => package-release.yml} (99%) diff --git a/.github/workflows/release.yml b/.github/workflows/package-release.yml similarity index 99% rename from .github/workflows/release.yml rename to .github/workflows/package-release.yml index 3ae1c6279..c24cbb716 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/package-release.yml @@ -1,7 +1,7 @@ # After a release PR merges: build every package, then tag and create the # GitHub releases (drafts), then upload to PyPI and make the releases # public. The step that cannot be undone comes last. -name: Release +name: Package Release on: # No `branches` filter: an rc PR from pre-release.yml targets the branch diff --git a/RELEASING.md b/RELEASING.md index 83a368020..85c7ddbc3 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -28,8 +28,8 @@ needs the new protocol. | `release-pr.yml` | A push to `main` | Keeps the release PR `release/main` current. | | `pre-release.yml` | Run by hand | Opens an rc PR from its branch. | | `release-gate.yml` | A `release/*` PR or review | Requires the verwalter author and 2 approvals. | -| `release.yml` | The release PR merges | Builds, tags, uploads to PyPI, publishes the docs. | -| `build-docs.yml` | Called by `release.yml` | Uploads the pdoc docs of a final version to S3. | +| `package-release.yml` | The release PR merges | Builds, tags, uploads to PyPI, publishes the docs. | +| `build-docs.yml` | Called by `package-release.yml` | Uploads the pdoc docs of a final version to S3. | `changeset-check.yml` skips `renovate/*` branches. `release-gate.yml` is a required check on `main`. @@ -37,7 +37,7 @@ required check on `main`. ## Release 1. Merge the release PR. It needs 2 approvals. -2. Watch the run of `release.yml`: `gh run list --workflow release.yml --limit 1`. +2. Watch the run of `package-release.yml`: `gh run list --workflow package-release.yml --limit 1`. The `verify` job checks the end state. Each tag has a public GitHub release, and PyPI has each version. For a final version, the docs job of the package @@ -59,8 +59,8 @@ has the paths by cause. | Situation | Command | |---|---| | A job failed for a transient reason | `gh run rerun --failed` | -| The workflow needed a fix, now on `main` | `gh workflow run release.yml -f ref=` | -| An rtc wheel build failed | Fix it on `main`, then `gh workflow run release.yml -f ref=` | +| The workflow needed a fix, now on `main` | `gh workflow run package-release.yml -f ref=` | +| An rtc wheel build failed | Fix it on `main`, then `gh workflow run package-release.yml -f ref=` | | The released commit is wrong | `verwalter release --abandon `, then a changeset and the next version | The PyPI upload skips files that PyPI has, so a re-run is safe. PyPI never From 25156d6255267e9ea68783eed30976a51c163022 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 23 Nov 2026 13:27:51 +0100 Subject: [PATCH 3/6] Update to verwalter 0.32.0-rc.1 and harden the release - Use `verwalter gate` in place of the hand-written guard. A run by hand releases only a commit on main. - Dry-run the PyPI build and `twine check` on the release PR. - Drop the explicit dependency: 0.32 reads it from pyproject.toml and moves the requirement. - Remove the tag-triggered PyPI publish from build-*.yml. - Count only approvals of the head commit in the release gate. - Build the docs from the released commit. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build-api.yml | 26 ----------- .github/workflows/build-docs.yml | 6 +++ .github/workflows/build-protocol.yml | 26 ----------- .github/workflows/build-rtc.yml | 27 ------------ .github/workflows/changeset-check.yml | 9 +++- .github/workflows/package-release.yml | 62 +++++++++++++++++++-------- .github/workflows/pre-release.yml | 2 +- .github/workflows/release-gate.yml | 14 +++--- .github/workflows/release-pr.yml | 2 +- RELEASING.md | 28 +++++++----- verwalter.toml | 5 ++- 11 files changed, 90 insertions(+), 117 deletions(-) diff --git a/.github/workflows/build-api.yml b/.github/workflows/build-api.yml index 6a0aa3c31..cccbb94e3 100644 --- a/.github/workflows/build-api.yml +++ b/.github/workflows/build-api.yml @@ -6,8 +6,6 @@ on: - main paths: - livekit-api/** - tags: - - "api-v*.*.*" pull_request: branches: - main @@ -43,27 +41,3 @@ jobs: path: | livekit-api/dist/*.whl livekit-api/dist/*.tar.gz - - publish: - name: Publish API release - needs: build_wheels - runs-on: ubuntu-latest - environment: pypi - permissions: - id-token: write - if: startsWith(github.ref, 'refs/tags/api-v') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) - steps: - - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 - with: - name: api-release - path: dist - - - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 - - docs: - needs: [publish] - uses: ./.github/workflows/build-docs.yml - with: - package_dir: "livekit-api" - package_name: "livekit.api" - secrets: inherit diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index e988444c5..d57d03752 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -21,6 +21,11 @@ on: package_name: required: true type: string + ref: + description: The commit to document. Empty is the commit of the calling run. + required: false + type: string + default: "" secrets: PYPI_API_TOKEN: required: true @@ -39,6 +44,7 @@ jobs: steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: + ref: ${{ inputs.ref || github.sha }} submodules: recursive - name: Install Package to Document diff --git a/.github/workflows/build-protocol.yml b/.github/workflows/build-protocol.yml index ae82ad7e2..e541e7fa4 100644 --- a/.github/workflows/build-protocol.yml +++ b/.github/workflows/build-protocol.yml @@ -6,8 +6,6 @@ on: - main paths: - livekit-protocol/** - tags: - - "protocol-v*.*.*" pull_request: branches: - main @@ -84,27 +82,3 @@ jobs: path: | livekit-protocol/dist/*.whl livekit-protocol/dist/*.tar.gz - - publish: - name: Publish Protocol release - needs: build_wheels - runs-on: ubuntu-latest - environment: pypi - permissions: - id-token: write - if: startsWith(github.ref, 'refs/tags/protocol-v') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) - steps: - - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 - with: - name: protocol-release - path: dist - - - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 - - docs: - needs: [publish] - uses: ./.github/workflows/build-docs.yml - with: - package_dir: "livekit-protocol" - package_name: "livekit.protocol" - secrets: inherit diff --git a/.github/workflows/build-rtc.yml b/.github/workflows/build-rtc.yml index 3eebae58d..744714c73 100644 --- a/.github/workflows/build-rtc.yml +++ b/.github/workflows/build-rtc.yml @@ -6,8 +6,6 @@ on: - main paths: - livekit-rtc/** - tags: - - "rtc-v*.*.*" pull_request: branches: - main @@ -195,28 +193,3 @@ jobs: LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }} LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }} LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }} - - publish: - name: Publish RTC release - needs: [build_wheels, make_sdist, test] - runs-on: ubuntu-latest - environment: pypi - permissions: - id-token: write - if: startsWith(github.ref, 'refs/tags/rtc-v') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) - steps: - - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 - with: - pattern: rtc-release-* - path: dist - merge-multiple: true - - - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 - - docs: - needs: [publish] - uses: ./.github/workflows/build-docs.yml - with: - package_dir: "livekit-rtc" - package_name: "livekit.rtc" - secrets: inherit diff --git a/.github/workflows/changeset-check.yml b/.github/workflows/changeset-check.yml index b906be8a4..1e53ca0f2 100644 --- a/.github/workflows/changeset-check.yml +++ b/.github/workflows/changeset-check.yml @@ -1,6 +1,9 @@ # Fails a contributor PR that changes a versioned package without a # changeset, with a comment that links to a prefilled changeset file. # The `internal` label (config: [check] exempt_label) skips the check. +# On the release PR, it runs the `[check].publish_dry_run` command of each +# package that the merge releases (build and `twine check`), and fails the +# PR when one fails, before the version reaches main. name: Changeset check on: @@ -19,6 +22,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + with: + fetch-depth: 0 # the dry run reads the tags to find what the release PR releases + submodules: true # the sdist of each package includes its submodule + - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 + - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 with: command: check diff --git a/.github/workflows/package-release.yml b/.github/workflows/package-release.yml index c24cbb716..49bc8d834 100644 --- a/.github/workflows/package-release.yml +++ b/.github/workflows/package-release.yml @@ -29,25 +29,46 @@ permissions: contents: read jobs: - guard: - # Only a release PR that verwalter opened: the branch prefix alone would - # let any pushed `release/*` branch trigger a publish. The author is the - # verwalter-release GitHub App, or github-actions[bot] without the App. - if: >- - github.event_name == 'workflow_dispatch' - || (github.event.pull_request.merged == true - && startsWith(github.event.pull_request.head.ref, 'release/') - && github.event.pull_request.head.repo.full_name == github.repository - && (github.event.pull_request.user.login == 'verwalter-release[bot]' || github.event.pull_request.user.login == 'github-actions[bot]') - && contains(github.event.pull_request.body, '')) + # Only a run by hand, or a merged release PR or rc PR that verwalter + # opened: the branch name alone would let any pushed `release/*` branch + # trigger a publish. The author is `[release].author` in verwalter.toml. + gate: runs-on: ubuntu-latest + permissions: + contents: read + outputs: + release: ${{ steps.verwalter.outputs.release }} steps: - - run: echo "Release PR accepted" + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + with: + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + fetch-depth: 0 + # `verwalter gate` answers yes for every run by hand. The release + # gate (2 approvals) covers only PRs into main, so a run by hand + # releases only a commit that is on main. + - name: Guard the run by hand + if: github.event_name == 'workflow_dispatch' + env: + REF: ${{ github.ref }} + run: | + if [ "$REF" != "refs/heads/main" ]; then + echo "::error::Run this workflow from main, not $REF. Set the commit to release with the ref input." + exit 1 + fi + if ! git merge-base --is-ancestor HEAD origin/main; then + echo "::error::$(git rev-parse HEAD) is not on main. Only a commit on main can be released by hand." + exit 1 + fi + - id: verwalter + uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 + with: + command: gate # ── Builds ─────────────────────────────────────────────────── build-rtc: name: Build RTC wheels (${{ matrix.archs }}) - needs: guard + needs: gate + if: needs.gate.outputs.release == 'true' runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -89,7 +110,8 @@ jobs: build-rtc-sdist: name: Build RTC sdist - needs: guard + needs: gate + if: needs.gate.outputs.release == 'true' runs-on: ubuntu-latest defaults: run: @@ -112,7 +134,8 @@ jobs: build: name: Build ${{ matrix.package }} - needs: guard + needs: gate + if: needs.gate.outputs.release == 'true' runs-on: ubuntu-latest strategy: matrix: @@ -158,7 +181,7 @@ jobs: ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} fetch-depth: 0 - id: verwalter - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 with: command: release args: ${{ inputs.package && format('--package {0}', inputs.package) || '' }} @@ -238,7 +261,7 @@ jobs: skip-existing: true - name: Make the GitHub releases public - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 env: GH_TOKEN: ${{ github.token }} with: @@ -257,7 +280,7 @@ jobs: with: ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} fetch-depth: 0 - - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 with: command: status args: --check @@ -271,6 +294,7 @@ jobs: with: package_dir: livekit-rtc package_name: livekit.rtc + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} secrets: inherit docs-api: @@ -281,6 +305,7 @@ jobs: with: package_dir: livekit-api package_name: livekit.api + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} secrets: inherit docs-protocol: @@ -291,4 +316,5 @@ jobs: with: package_dir: livekit-protocol package_name: livekit.protocol + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} secrets: inherit diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 86debc634..16965ff0f 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: fetch-depth: 0 # the tags number the rc - - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 with: command: pre-release args: --target ${{ github.ref_name }} diff --git a/.github/workflows/release-gate.yml b/.github/workflows/release-gate.yml index 00e453303..3d34c8582 100644 --- a/.github/workflows/release-gate.yml +++ b/.github/workflows/release-gate.yml @@ -18,6 +18,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} HEAD_REF: ${{ github.event.pull_request.head.ref }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} PR_NUMBER: ${{ github.event.pull_request.number }} REPO: ${{ github.repository }} @@ -27,15 +28,18 @@ jobs: exit 0 fi - if [ "$PR_AUTHOR" != "verwalter-release[bot]" ] && [ "$PR_AUTHOR" != "github-actions[bot]" ]; then + # The same author that `verwalter gate` accepts ([release].author) + if [ "$PR_AUTHOR" != "verwalter-release[bot]" ]; then echo "::error::Release PRs must be created by verwalter (release-pr.yml or pre-release.yml), not by '$PR_AUTHOR'" exit 1 fi - approvals=$(gh api "repos/$REPO/pulls/$PR_NUMBER/reviews" \ - --jq '[group_by(.user.login)[] | sort_by(.submitted_at) | last | select(.state == "APPROVED") | .user.login] | length') - echo "Approvals: $approvals" + # Each push to main regenerates the release branch. Only an + # approval of the current head commit counts. + approvals=$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/reviews" \ + | jq -s --arg sha "$HEAD_SHA" '[add | .[] | select(.commit_id == $sha and (.state == "APPROVED" or .state == "CHANGES_REQUESTED" or .state == "DISMISSED"))] | group_by(.user.login) | map(sort_by(.submitted_at) | last | select(.state == "APPROVED")) | length') + echo "Approvals of $HEAD_SHA: $approvals" if [ "$approvals" -lt 2 ]; then - echo "::error::Release PRs require at least 2 approvals (got $approvals)" + echo "::error::Release PRs require at least 2 approvals of the head commit (got $approvals)" exit 1 fi diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index d6a94f2c9..4a0aeef78 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: fetch-depth: 0 # the commit that added a changeset gives its changelog line the PR and author - - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 + - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 with: command: pr # A GitHub App token lets the release PRs trigger CI; the default diff --git a/RELEASING.md b/RELEASING.md index 85c7ddbc3..581b23f31 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -16,27 +16,30 @@ specific to this repository. Each package keeps its version in `livekit//version.py`. `livekit-api` depends on `livekit-protocol`. A release of `livekit-protocol` -also releases `livekit-api` as a patch. The `livekit-protocol` floor in -`livekit-api/pyproject.toml` does not move on its own. Raise it in the PR that -needs the new protocol. +also releases `livekit-api` as a patch. The release moves the +`livekit-protocol` requirement in `livekit-api/pyproject.toml` to the new +version, and to the next major for a major release. ## Workflows | File | Trigger | Does | |---|---|---| -| `changeset-check.yml` | A PR opens or changes | Fails a package change with no changeset. | +| `changeset-check.yml` | A PR opens or changes | Fails a package change with no changeset. Builds and runs `twine check` on the release PR. | | `release-pr.yml` | A push to `main` | Keeps the release PR `release/main` current. | | `pre-release.yml` | Run by hand | Opens an rc PR from its branch. | -| `release-gate.yml` | A `release/*` PR or review | Requires the verwalter author and 2 approvals. | +| `release-gate.yml` | A `release/*` PR or review | Requires the verwalter author and 2 approvals of the head commit. | | `package-release.yml` | The release PR merges | Builds, tags, uploads to PyPI, publishes the docs. | | `build-docs.yml` | Called by `package-release.yml` | Uploads the pdoc docs of a final version to S3. | `changeset-check.yml` skips `renovate/*` branches. `release-gate.yml` is a -required check on `main`. +required check on `main`. The `gate` job of `package-release.yml` releases only +a merged PR from `verwalter-release[bot]`, or a run by hand from `main`. A run +by hand releases only a commit that is on `main`. ## Release -1. Merge the release PR. It needs 2 approvals. +1. Merge the release PR. It needs 2 approvals of its head commit. A push to + `main` regenerates the PR, and the approvals then count no more. 2. Watch the run of `package-release.yml`: `gh run list --workflow package-release.yml --limit 1`. The `verify` job checks the end state. Each tag has a public GitHub release, @@ -46,9 +49,12 @@ must also be green. ## Pre-release Run `gh workflow run pre-release.yml --ref `. The pending changesets -decide the packages and the levels. The rc is `1.6.0-rc.1` in `version.py` and -in the tag. PyPI shows it as `1.6.0rc1`. The changesets stay pending for the -final release. +decide the packages and the levels. The rc is `1.6.0rc1` in `version.py` and on +PyPI, and `1.6.0-rc.1` in the tag. The changesets stay pending for the final +release. + +The release gate covers only PRs into `main`. An rc PR into another branch +needs no approval, and its merge releases the rc. ## A release failed @@ -60,7 +66,7 @@ has the paths by cause. |---|---| | A job failed for a transient reason | `gh run rerun --failed` | | The workflow needed a fix, now on `main` | `gh workflow run package-release.yml -f ref=` | -| An rtc wheel build failed | Fix it on `main`, then `gh workflow run package-release.yml -f ref=` | +| A build failed. The builds run before the tag, so no tag exists. | Merge the fix to `main` without a changeset, then `gh workflow run package-release.yml` | | The released commit is wrong | `verwalter release --abandon `, then a changeset and the next version | The PyPI upload skips files that PyPI has, so a re-run is safe. PyPI never diff --git a/verwalter.toml b/verwalter.toml index f461b4aed..af0c028a9 100644 --- a/verwalter.toml +++ b/verwalter.toml @@ -4,15 +4,18 @@ members = ["livekit-rtc", "livekit-api", "livekit-protocol"] exclude = ["python-sdks"] # the uv workspace root, never published +[check] +publish_dry_run = "uv build --out-dir dist && uvx twine check dist/*" # PyPI has no built-in dry run + [publish] registry = "pypi" [packages.livekit] versioning.files = [{ path = "livekit/rtc/version.py", regex = '__version__ = "(?[^"]+)"' }] release.tag = "rtc-v{version}" +check.publish_dry_run = "uv build --sdist --out-dir dist && uvx twine check dist/*" # the wheels need cibuildwheel and the FFI binaries [packages.livekit-api] -dependencies = ["livekit-protocol"] # the pyproject.toml requirement is not read: verwalter finds no dependency versioning.files = [{ path = "livekit/api/version.py", regex = '__version__ = "(?[^"]+)"' }] release.tag = "api-v{version}" From bbf636d62fff591a5a5975c36ddd4c7eb9a01373 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 23 Nov 2026 13:44:17 +0100 Subject: [PATCH 4/6] Address the Devin review of the release workflow - Resolve the release commit once in `gate` and check it out in every job, so a branch name in `ref` cannot move between jobs. - Reject an unknown `package` input. Upload and publish only releases whose tag exists and whose source matches the tag. Drop the fallback that uploaded every package. - Deploy docs only for the newest final tag of a package, built from that tag. - Document the extra livekit-api changeset for a major livekit-protocol rc. Co-Authored-By: Claude Opus 5.5 --- .changeset/README.md | 5 +- .github/workflows/package-release.yml | 113 ++++++++++++++++++-------- RELEASING.md | 6 ++ 3 files changed, 90 insertions(+), 34 deletions(-) diff --git a/.changeset/README.md b/.changeset/README.md index 827399aaa..34272bc50 100644 --- a/.changeset/README.md +++ b/.changeset/README.md @@ -21,5 +21,6 @@ also releases `livekit-api` as a patch, with no changeset for it. A PR that needs no release (docs, CI, tests) gets the `internal` label. -Pre-releases (`1.6.0-rc.1`) are not a changeset level: run the Pre-release PR -workflow. See [RELEASING.md](../RELEASING.md). +Pre-releases (`1.6.0rc1`) are not a changeset level: run the Pre-release PR +workflow. For a major rc of `livekit-protocol`, also add a `patch` changeset for +`livekit-api`. See [RELEASING.md](../RELEASING.md). diff --git a/.github/workflows/package-release.yml b/.github/workflows/package-release.yml index 49bc8d834..e087181cd 100644 --- a/.github/workflows/package-release.yml +++ b/.github/workflows/package-release.yml @@ -5,7 +5,7 @@ name: Package Release on: # No `branches` filter: an rc PR from pre-release.yml targets the branch - # the workflow was run on. The `guard` job decides which PRs release. + # the workflow was run on. The `gate` job decides which PRs release. pull_request: types: [closed] # A failed job is re-run with "Re-run failed jobs" on the run itself: @@ -38,11 +38,16 @@ jobs: contents: read outputs: release: ${{ steps.verwalter.outputs.release }} + sha: ${{ steps.commit.outputs.sha }} steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} fetch-depth: 0 + # Every later job checks out this commit. A branch name in `ref` + # resolves once, here, and cannot move between the jobs. + - id: commit + run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" # `verwalter gate` answers yes for every run by hand. The release # gate (2 approvals) covers only PRs into main, so a run by hand # releases only a commit that is on main. @@ -50,7 +55,12 @@ jobs: if: github.event_name == 'workflow_dispatch' env: REF: ${{ github.ref }} + PACKAGE: ${{ inputs.package }} run: | + case "$PACKAGE" in + ""|livekit|livekit-api|livekit-protocol) ;; + *) echo "::error::Unknown package '$PACKAGE'. Use livekit, livekit-api or livekit-protocol."; exit 1 ;; + esac if [ "$REF" != "refs/heads/main" ]; then echo "::error::Run this workflow from main, not $REF. Set the commit to release with the ref input." exit 1 @@ -90,7 +100,7 @@ jobs: steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: - ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + ref: ${{ needs.gate.outputs.sha }} submodules: true - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 @@ -119,7 +129,7 @@ jobs: steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: - ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + ref: ${{ needs.gate.outputs.sha }} submodules: true - name: Build sdist @@ -146,7 +156,7 @@ jobs: steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: - ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + ref: ${{ needs.gate.outputs.sha }} submodules: true - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 @@ -165,39 +175,54 @@ jobs: # ── Tag & GitHub releases ──────────────────────────────────── release: - needs: [build-rtc, build-rtc-sdist, build] + needs: [gate, build-rtc, build-rtc-sdist, build] runs-on: ubuntu-latest permissions: contents: write outputs: released: ${{ steps.verwalter.outputs.released }} releases: ${{ steps.verwalter.outputs.releases }} - docs: ${{ steps.docs.outputs.packages }} + docs: ${{ steps.docs.outputs.tags }} steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: # The merge commit itself: a push to main right after the merge # must not move the tags. - ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + ref: ${{ needs.gate.outputs.sha }} fetch-depth: 0 - id: verwalter uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 with: command: release args: ${{ inputs.package && format('--package {0}', inputs.package) || '' }} - # The docs site holds one version per package: an rc must not replace - # the docs of the last final release. + # The docs site holds one version per package. Only the newest final + # tag of a package may deploy: not an rc, and not an older version + # that a run by hand reports again. Output: {"": ""}. - id: docs env: RELEASES: ${{ steps.verwalter.outputs.releases }} - run: echo "packages=$(jq -c '[.[] | select(.prerelease | not) | .package]' <<< "${RELEASES:-[]}")" >> "$GITHUB_OUTPUT" + run: | + git fetch -q --tags --force origin + docs='{}' + while read -r pkg tag; do + [ -n "$pkg" ] || continue + newest=$(git tag --list "${tag%-v*}-v*" | grep -v -- '-rc' | sort -V | tail -n 1) + if [ "$tag" = "$newest" ]; then + docs=$(jq -c --arg p "$pkg" --arg t "$tag" '. + {($p): $t}' <<< "$docs") + else + echo "No docs for $tag: $newest is newer" + fi + done < <(jq -r '.[] | select(.prerelease | not) | "\(.package) \(.tag)"' <<< "${RELEASES:-[]}") + echo "tags=$docs" >> "$GITHUB_OUTPUT" # ── PyPI ───────────────────────────────────────────────────── # Uploads each released package with skip-existing, dependencies first, # so a re-run completes a half-uploaded wheel set. `verwalter publish` # then finds every version on PyPI and makes the draft releases public. + # The upload builds from this run's commit, so a package whose source + # changed since its tag (an older draft) is left out and fails the job. publish: - needs: release + needs: [gate, release] if: needs.release.outputs.released == 'true' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest environment: pypi @@ -207,20 +232,33 @@ jobs: steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: - ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + ref: ${{ needs.gate.outputs.sha }} fetch-depth: 0 # tags decide what is published + # Only a release whose tag exists and whose package source equals + # the source at its tag is uploaded and made public. An empty list + # uploads nothing: `verwalter publish` with an empty list would make + # every tagged draft public that PyPI has, also a half-uploaded one. - id: pkgs env: RELEASES: ${{ needs.release.outputs.releases }} run: | - # A run by hand with nothing left to tag gets an empty list: then - # try every package. skip-existing skips what PyPI has. - if [ -z "$RELEASES" ] || [ "$RELEASES" = "[]" ]; then - echo 'packages=["livekit","livekit-api","livekit-protocol"]' >> "$GITHUB_OUTPUT" - else - echo "packages=$(jq -c '[.[].package]' <<< "$RELEASES")" >> "$GITHUB_OUTPUT" - fi + ok='[]' + left_out='' + while read -r release; do + [ -n "$release" ] || continue + pkg=$(jq -r .package <<< "$release") + tag=$(jq -r .tag <<< "$release") + case "$pkg" in livekit) path=livekit-rtc ;; *) path=$pkg ;; esac + if git rev-parse -q --verify "refs/tags/$tag" >/dev/null && git diff --quiet "$tag" HEAD -- "$path"; then + ok=$(jq -c --argjson r "$release" '. + [$r]' <<< "$ok") + else + left_out="$left_out $pkg:$tag" + fi + done < <(jq -c '.[]' <<< "${RELEASES:-[]}") + echo "releases=$ok" >> "$GITHUB_OUTPUT" + echo "packages=$(jq -c '[.[].package]' <<< "$ok")" >> "$GITHUB_OUTPUT" + echo "left_out=${left_out# }" >> "$GITHUB_OUTPUT" - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: @@ -261,60 +299,71 @@ jobs: skip-existing: true - name: Make the GitHub releases public + if: steps.pkgs.outputs.releases != '[]' uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 env: GH_TOKEN: ${{ github.token }} with: command: publish - releases: ${{ needs.release.outputs.releases }} + releases: ${{ steps.pkgs.outputs.releases }} + + - name: Fail for the releases left out + if: steps.pkgs.outputs.left_out != '' + env: + LEFT_OUT: ${{ steps.pkgs.outputs.left_out }} + run: | + for entry in $LEFT_OUT; do + echo "::error::${entry%%:*}: the source changed since ${entry#*:}, or the tag is missing. Repair: gh workflow run package-release.yml -f ref=${entry#*:} -f package=${entry%%:*}" + done + exit 1 # The end state, asserted: fails when a tag is not on the remote, a GitHub # release is missing or still a draft, or PyPI does not have the version. verify: - needs: publish + needs: [gate, publish] runs-on: ubuntu-latest permissions: contents: write # reads only. A draft release is visible only with write access steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: - ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + ref: ${{ needs.gate.outputs.sha }} fetch-depth: 0 - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 with: command: status args: --check - # ── Docs (final versions only) ─────────────────────────────── + # ── Docs (the newest final version only, built from its tag) ─ docs-rtc: name: Build RTC docs - needs: [release, publish] - if: contains(fromJSON(needs.release.outputs.docs || '[]'), 'livekit') + needs: [gate, release, publish] + if: fromJSON(needs.release.outputs.docs || '{}')['livekit'] != null uses: ./.github/workflows/build-docs.yml with: package_dir: livekit-rtc package_name: livekit.rtc - ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + ref: ${{ fromJSON(needs.release.outputs.docs)['livekit'] }} secrets: inherit docs-api: name: Build API docs - needs: [release, publish] - if: contains(fromJSON(needs.release.outputs.docs || '[]'), 'livekit-api') + needs: [gate, release, publish] + if: fromJSON(needs.release.outputs.docs || '{}')['livekit-api'] != null uses: ./.github/workflows/build-docs.yml with: package_dir: livekit-api package_name: livekit.api - ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + ref: ${{ fromJSON(needs.release.outputs.docs)['livekit-api'] }} secrets: inherit docs-protocol: name: Build Protocol docs - needs: [release, publish] - if: contains(fromJSON(needs.release.outputs.docs || '[]'), 'livekit-protocol') + needs: [gate, release, publish] + if: fromJSON(needs.release.outputs.docs || '{}')['livekit-protocol'] != null uses: ./.github/workflows/build-docs.yml with: package_dir: livekit-protocol package_name: livekit.protocol - ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} + ref: ${{ fromJSON(needs.release.outputs.docs)['livekit-protocol'] }} secrets: inherit diff --git a/RELEASING.md b/RELEASING.md index 581b23f31..1028c6009 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -53,6 +53,11 @@ decide the packages and the levels. The rc is `1.6.0rc1` in `version.py` and on PyPI, and `1.6.0-rc.1` in the tag. The changesets stay pending for the final release. +An rc includes only the packages with a pending changeset. For a major rc of +`livekit-protocol`, also add a `patch` changeset for `livekit-api`. Else the rc +PR leaves `livekit-api` at `livekit-protocol<3.0.0`, which excludes the rc, and +the API tests cannot install both packages. + The release gate covers only PRs into `main`. An rc PR into another branch needs no approval, and its merge releases the rc. @@ -66,6 +71,7 @@ has the paths by cause. |---|---| | A job failed for a transient reason | `gh run rerun --failed` | | The workflow needed a fix, now on `main` | `gh workflow run package-release.yml -f ref=` | +| The publish job left out a release because its source changed since its tag | `gh workflow run package-release.yml -f ref= -f package=` | | A build failed. The builds run before the tag, so no tag exists. | Merge the fix to `main` without a changeset, then `gh workflow run package-release.yml` | | The released commit is wrong | `verwalter release --abandon `, then a changeset and the next version | From 3488c13000094a29c7f42f9283b657c082caff52 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 23 Nov 2026 14:07:07 +0100 Subject: [PATCH 5/6] Upload to PyPI through verwalter publish - Run twine with attestations as the publish command, so `publish` owns the order, blocks the dependents of a failed package, and refuses source that changed since the tag. Drop the upload filter and the pypa steps. - Check PyPI as a custom registry through the sdist, which twine uploads last, so a half upload stays a draft and a re-run completes it. - Deploy docs for each release that is public after the publish, also when another package failed. - TODOs for livekit/verwalter#137 and #138. Co-Authored-By: Claude Opus 5.5 --- .changeset/README.md | 2 +- .github/workflows/package-release.yml | 112 +++++++++----------------- RELEASING.md | 13 ++- verwalter.toml | 18 ++++- 4 files changed, 68 insertions(+), 77 deletions(-) diff --git a/.changeset/README.md b/.changeset/README.md index 34272bc50..936a5d457 100644 --- a/.changeset/README.md +++ b/.changeset/README.md @@ -23,4 +23,4 @@ A PR that needs no release (docs, CI, tests) gets the `internal` label. Pre-releases (`1.6.0rc1`) are not a changeset level: run the Pre-release PR workflow. For a major rc of `livekit-protocol`, also add a `patch` changeset for -`livekit-api`. See [RELEASING.md](../RELEASING.md). +`livekit-api`. See [RELEASING.md](../RELEASING.md). diff --git a/.github/workflows/package-release.yml b/.github/workflows/package-release.yml index e087181cd..d0fcfd1ab 100644 --- a/.github/workflows/package-release.yml +++ b/.github/workflows/package-release.yml @@ -216,11 +216,10 @@ jobs: echo "tags=$docs" >> "$GITHUB_OUTPUT" # ── PyPI ───────────────────────────────────────────────────── - # Uploads each released package with skip-existing, dependencies first, - # so a re-run completes a half-uploaded wheel set. `verwalter publish` - # then finds every version on PyPI and makes the draft releases public. - # The upload builds from this run's commit, so a package whose source - # changed since its tag (an older draft) is left out and fails the job. + # `verwalter publish` runs the publish command of verwalter.toml for each + # released package: dependencies first, a failure blocks only its + # dependents, a package whose source changed since its tag fails, and a + # draft goes public only when PyPI has its sdist, which uploads last. publish: needs: [gate, release] if: needs.release.outputs.released == 'true' || github.event_name == 'workflow_dispatch' @@ -228,38 +227,15 @@ jobs: environment: pypi permissions: contents: write # the tool makes the draft releases public - id-token: write # trusted publishing + id-token: write # trusted publishing and the attestations + outputs: + docs: ${{ steps.docs.outputs.tags }} steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: ref: ${{ needs.gate.outputs.sha }} fetch-depth: 0 # tags decide what is published - # Only a release whose tag exists and whose package source equals - # the source at its tag is uploaded and made public. An empty list - # uploads nothing: `verwalter publish` with an empty list would make - # every tagged draft public that PyPI has, also a half-uploaded one. - - id: pkgs - env: - RELEASES: ${{ needs.release.outputs.releases }} - run: | - ok='[]' - left_out='' - while read -r release; do - [ -n "$release" ] || continue - pkg=$(jq -r .package <<< "$release") - tag=$(jq -r .tag <<< "$release") - case "$pkg" in livekit) path=livekit-rtc ;; *) path=$pkg ;; esac - if git rev-parse -q --verify "refs/tags/$tag" >/dev/null && git diff --quiet "$tag" HEAD -- "$path"; then - ok=$(jq -c --argjson r "$release" '. + [$r]' <<< "$ok") - else - left_out="$left_out $pkg:$tag" - fi - done < <(jq -c '.[]' <<< "${RELEASES:-[]}") - echo "releases=$ok" >> "$GITHUB_OUTPUT" - echo "packages=$(jq -c '[.[].package]' <<< "$ok")" >> "$GITHUB_OUTPUT" - echo "left_out=${left_out# }" >> "$GITHUB_OUTPUT" - - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: pattern: dist-rtc-* @@ -277,48 +253,40 @@ jobs: - name: List distributions run: ls -laR dist/ - - name: Publish livekit-protocol - if: contains(fromJSON(steps.pkgs.outputs.packages), 'livekit-protocol') - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 - with: - packages-dir: dist/livekit-protocol/ - skip-existing: true - - - name: Publish livekit-api - if: contains(fromJSON(steps.pkgs.outputs.packages), 'livekit-api') - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 - with: - packages-dir: dist/livekit-api/ - skip-existing: true - - - name: Publish livekit - if: contains(fromJSON(steps.pkgs.outputs.packages), 'livekit') - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 - with: - packages-dir: dist/livekit/ - skip-existing: true + - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - - name: Make the GitHub releases public - if: steps.pkgs.outputs.releases != '[]' + - name: Upload to PyPI and make the GitHub releases public uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 env: GH_TOKEN: ${{ github.token }} with: command: publish - releases: ${{ steps.pkgs.outputs.releases }} + releases: ${{ needs.release.outputs.releases }} - - name: Fail for the releases left out - if: steps.pkgs.outputs.left_out != '' + # Docs only for a release that is public now: a failed or blocked + # package keeps its draft, and the others still get their docs. + - id: docs + if: always() env: - LEFT_OUT: ${{ steps.pkgs.outputs.left_out }} + GH_TOKEN: ${{ github.token }} + CANDIDATES: ${{ needs.release.outputs.docs }} run: | - for entry in $LEFT_OUT; do - echo "::error::${entry%%:*}: the source changed since ${entry#*:}, or the tag is missing. Repair: gh workflow run package-release.yml -f ref=${entry#*:} -f package=${entry%%:*}" - done - exit 1 + [ -n "$CANDIDATES" ] || CANDIDATES='{}' + docs='{}' + while read -r pkg tag; do + [ -n "$pkg" ] || continue + if [ "$(gh release view "$tag" --json isDraft -q .isDraft)" = "false" ]; then + docs=$(jq -c --arg p "$pkg" --arg t "$tag" '. + {($p): $t}' <<< "$docs") + else + echo "No docs for $tag: its release is still a draft" + fi + done < <(jq -r 'to_entries[] | "\(.key) \(.value)"' <<< "$CANDIDATES") + echo "tags=$docs" >> "$GITHUB_OUTPUT" # The end state, asserted: fails when a tag is not on the remote, a GitHub - # release is missing or still a draft, or PyPI does not have the version. + # release is missing or still a draft, or PyPI does not have the sdist. + # TODO(livekit/verwalter#138): fails for every rc until exists_url has a + # PEP 440 placeholder (see verwalter.toml). verify: needs: [gate, publish] runs-on: ubuntu-latest @@ -334,36 +302,36 @@ jobs: command: status args: --check - # ── Docs (the newest final version only, built from its tag) ─ + # ── Docs (the newest final version only, once public, built from its tag) ─ docs-rtc: name: Build RTC docs - needs: [gate, release, publish] - if: fromJSON(needs.release.outputs.docs || '{}')['livekit'] != null + needs: [gate, publish] + if: ${{ !cancelled() && fromJSON(needs.publish.outputs.docs || '{}')['livekit'] != null }} uses: ./.github/workflows/build-docs.yml with: package_dir: livekit-rtc package_name: livekit.rtc - ref: ${{ fromJSON(needs.release.outputs.docs)['livekit'] }} + ref: ${{ fromJSON(needs.publish.outputs.docs)['livekit'] }} secrets: inherit docs-api: name: Build API docs - needs: [gate, release, publish] - if: fromJSON(needs.release.outputs.docs || '{}')['livekit-api'] != null + needs: [gate, publish] + if: ${{ !cancelled() && fromJSON(needs.publish.outputs.docs || '{}')['livekit-api'] != null }} uses: ./.github/workflows/build-docs.yml with: package_dir: livekit-api package_name: livekit.api - ref: ${{ fromJSON(needs.release.outputs.docs)['livekit-api'] }} + ref: ${{ fromJSON(needs.publish.outputs.docs)['livekit-api'] }} secrets: inherit docs-protocol: name: Build Protocol docs - needs: [gate, release, publish] - if: fromJSON(needs.release.outputs.docs || '{}')['livekit-protocol'] != null + needs: [gate, publish] + if: ${{ !cancelled() && fromJSON(needs.publish.outputs.docs || '{}')['livekit-protocol'] != null }} uses: ./.github/workflows/build-docs.yml with: package_dir: livekit-protocol package_name: livekit.protocol - ref: ${{ fromJSON(needs.release.outputs.docs)['livekit-protocol'] }} + ref: ${{ fromJSON(needs.publish.outputs.docs)['livekit-protocol'] }} secrets: inherit diff --git a/RELEASING.md b/RELEASING.md index 1028c6009..3a37e8c28 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -42,8 +42,10 @@ by hand releases only a commit that is on `main`. `main` regenerates the PR, and the approvals then count no more. 2. Watch the run of `package-release.yml`: `gh run list --workflow package-release.yml --limit 1`. -The `verify` job checks the end state. Each tag has a public GitHub release, -and PyPI has each version. For a final version, the docs job of the package +`verwalter publish` uploads with twine: the wheels first, the sdist last. A +version counts as on PyPI when its sdist is there, so a half upload stays a +draft, and a re-run uploads the missing files. The `verify` job checks the end +state. Each tag has a public GitHub release, and PyPI has each sdist. For a final version, the docs job of the package must also be green. ## Pre-release @@ -53,6 +55,11 @@ decide the packages and the levels. The rc is `1.6.0rc1` in `version.py` and on PyPI, and `1.6.0-rc.1` in the tag. The changesets stay pending for the final release. + +The `verify` job fails for an rc: the PyPI check asks for the sdist +`1.6.0-rc.1`, but the file is `1.6.0rc1`. Check the rc on PyPI by hand. + + An rc includes only the packages with a pending changeset. For a major rc of `livekit-protocol`, also add a `patch` changeset for `livekit-api`. Else the rc PR leaves `livekit-api` at `livekit-protocol<3.0.0`, which excludes the rc, and @@ -71,7 +78,7 @@ has the paths by cause. |---|---| | A job failed for a transient reason | `gh run rerun --failed` | | The workflow needed a fix, now on `main` | `gh workflow run package-release.yml -f ref=` | -| The publish job left out a release because its source changed since its tag | `gh workflow run package-release.yml -f ref= -f package=` | +| `publish` failed a package with `HEAD changed the source since ` | `gh workflow run package-release.yml -f ref= -f package=` | | A build failed. The builds run before the tag, so no tag exists. | Merge the fix to `main` without a changeset, then `gh workflow run package-release.yml` | | The released commit is wrong | `verwalter release --abandon `, then a changeset and the next version | diff --git a/verwalter.toml b/verwalter.toml index af0c028a9..87b242c4b 100644 --- a/verwalter.toml +++ b/verwalter.toml @@ -7,18 +7,34 @@ exclude = ["python-sdks"] # the uv workspace root, never published [check] publish_dry_run = "uv build --out-dir dist && uvx twine check dist/*" # PyPI has no built-in dry run +# PyPI as a custom registry: the built-in `pypi` check answers yes after the +# first file of a version, so a half upload would count as published. Here a +# version exists when its sdist exists. twine uploads the wheels first and the +# sdist last, and stops at the first error, so the sdist means every file is +# there. A re-run after a half upload finds no sdist, runs the command again, +# and --skip-existing completes the missing files. +# The release workflow builds into dist// at the root. [publish] -registry = "pypi" +registry = "custom" +command = "uvx pypi-attestations@0.0.31 sign $VERWALTER_ROOT/dist/{package}/* && uvx twine@7.0.0 upload --attestations --skip-existing $VERWALTER_ROOT/dist/{package}/*" +# TODO(livekit/verwalter#138): `{version}` is the semver form (1.6.0-rc.1), but +# the sdist of an rc is 1.6.0rc1. Until a PEP 440 placeholder exists, the check +# never finds an rc: `publish` uploads it anyway (the command is safe to run +# twice), but `status --check` in the verify job fails for it. Switch each URL to +# the PEP 440 placeholder once it ships. [packages.livekit] versioning.files = [{ path = "livekit/rtc/version.py", regex = '__version__ = "(?[^"]+)"' }] release.tag = "rtc-v{version}" +publish.exists_url = "https://files.pythonhosted.org/packages/source/l/livekit/livekit-{version}.tar.gz" check.publish_dry_run = "uv build --sdist --out-dir dist && uvx twine check dist/*" # the wheels need cibuildwheel and the FFI binaries [packages.livekit-api] versioning.files = [{ path = "livekit/api/version.py", regex = '__version__ = "(?[^"]+)"' }] release.tag = "api-v{version}" +publish.exists_url = "https://files.pythonhosted.org/packages/source/l/livekit-api/livekit_api-{version}.tar.gz" [packages.livekit-protocol] versioning.files = [{ path = "livekit/protocol/version.py", regex = '__version__ = "(?[^"]+)"' }] release.tag = "protocol-v{version}" +publish.exists_url = "https://files.pythonhosted.org/packages/source/l/livekit-protocol/livekit_protocol-{version}.tar.gz" From 91e557eb456c8490802bb44e9f7773f23a38d03f Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 23 Nov 2026 14:30:22 +0100 Subject: [PATCH 6/6] Adopt verwalter 0.32.0-rc.2 - Back to the `pypi` registry: each package's `exists_url` now replaces the built-in check, with `{version}` in PEP 440 form, so the sdist check also works for an rc (livekit/verwalter#138). - Pin v0.32.0-rc.2 and remove the #138 TODOs. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/changeset-check.yml | 2 +- .github/workflows/package-release.yml | 10 ++++------ .github/workflows/pre-release.yml | 2 +- .github/workflows/release-pr.yml | 2 +- RELEASING.md | 4 ---- verwalter.toml | 18 ++++++------------ 6 files changed, 13 insertions(+), 25 deletions(-) diff --git a/.github/workflows/changeset-check.yml b/.github/workflows/changeset-check.yml index 1e53ca0f2..683c842f0 100644 --- a/.github/workflows/changeset-check.yml +++ b/.github/workflows/changeset-check.yml @@ -26,6 +26,6 @@ jobs: fetch-depth: 0 # the dry run reads the tags to find what the release PR releases submodules: true # the sdist of each package includes its submodule - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 + - uses: livekit/verwalter@14fef9bf275fb347702b083d573e4a1f09bf0ef4 # v0.32.0-rc.2 with: command: check diff --git a/.github/workflows/package-release.yml b/.github/workflows/package-release.yml index d0fcfd1ab..b2fc6a0cc 100644 --- a/.github/workflows/package-release.yml +++ b/.github/workflows/package-release.yml @@ -70,7 +70,7 @@ jobs: exit 1 fi - id: verwalter - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 + uses: livekit/verwalter@14fef9bf275fb347702b083d573e4a1f09bf0ef4 # v0.32.0-rc.2 with: command: gate @@ -191,7 +191,7 @@ jobs: ref: ${{ needs.gate.outputs.sha }} fetch-depth: 0 - id: verwalter - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 + uses: livekit/verwalter@14fef9bf275fb347702b083d573e4a1f09bf0ef4 # v0.32.0-rc.2 with: command: release args: ${{ inputs.package && format('--package {0}', inputs.package) || '' }} @@ -256,7 +256,7 @@ jobs: - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - name: Upload to PyPI and make the GitHub releases public - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 + uses: livekit/verwalter@14fef9bf275fb347702b083d573e4a1f09bf0ef4 # v0.32.0-rc.2 env: GH_TOKEN: ${{ github.token }} with: @@ -285,8 +285,6 @@ jobs: # The end state, asserted: fails when a tag is not on the remote, a GitHub # release is missing or still a draft, or PyPI does not have the sdist. - # TODO(livekit/verwalter#138): fails for every rc until exists_url has a - # PEP 440 placeholder (see verwalter.toml). verify: needs: [gate, publish] runs-on: ubuntu-latest @@ -297,7 +295,7 @@ jobs: with: ref: ${{ needs.gate.outputs.sha }} fetch-depth: 0 - - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 + - uses: livekit/verwalter@14fef9bf275fb347702b083d573e4a1f09bf0ef4 # v0.32.0-rc.2 with: command: status args: --check diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 16965ff0f..f32a3fb54 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: fetch-depth: 0 # the tags number the rc - - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 + - uses: livekit/verwalter@14fef9bf275fb347702b083d573e4a1f09bf0ef4 # v0.32.0-rc.2 with: command: pre-release args: --target ${{ github.ref_name }} diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index 4a0aeef78..39b1029a2 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: fetch-depth: 0 # the commit that added a changeset gives its changelog line the PR and author - - uses: livekit/verwalter@9da894a1e4f7d298095a961be60c818afd47905b # v0.32.0-rc.1 + - uses: livekit/verwalter@14fef9bf275fb347702b083d573e4a1f09bf0ef4 # v0.32.0-rc.2 with: command: pr # A GitHub App token lets the release PRs trigger CI; the default diff --git a/RELEASING.md b/RELEASING.md index 3a37e8c28..4999523d8 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -55,10 +55,6 @@ decide the packages and the levels. The rc is `1.6.0rc1` in `version.py` and on PyPI, and `1.6.0-rc.1` in the tag. The changesets stay pending for the final release. - -The `verify` job fails for an rc: the PyPI check asks for the sdist -`1.6.0-rc.1`, but the file is `1.6.0rc1`. Check the rc on PyPI by hand. - An rc includes only the packages with a pending changeset. For a major rc of `livekit-protocol`, also add a `patch` changeset for `livekit-api`. Else the rc diff --git a/verwalter.toml b/verwalter.toml index 87b242c4b..81940d5e5 100644 --- a/verwalter.toml +++ b/verwalter.toml @@ -7,22 +7,16 @@ exclude = ["python-sdks"] # the uv workspace root, never published [check] publish_dry_run = "uv build --out-dir dist && uvx twine check dist/*" # PyPI has no built-in dry run -# PyPI as a custom registry: the built-in `pypi` check answers yes after the -# first file of a version, so a half upload would count as published. Here a -# version exists when its sdist exists. twine uploads the wheels first and the -# sdist last, and stops at the first error, so the sdist means every file is -# there. A re-run after a half upload finds no sdist, runs the command again, -# and --skip-existing completes the missing files. +# A PyPI version has many files, and PyPI shows the version after the first +# one. So each package checks for its sdist (`publish.exists_url`), which twine +# uploads last after the wheels: a half upload stays a draft, and a re-run +# with --skip-existing uploads the missing files. `{version}` is PEP 440 there. +# The command signs PEP 740 attestations, which the built-in one does not. # The release workflow builds into dist// at the root. [publish] -registry = "custom" +registry = "pypi" command = "uvx pypi-attestations@0.0.31 sign $VERWALTER_ROOT/dist/{package}/* && uvx twine@7.0.0 upload --attestations --skip-existing $VERWALTER_ROOT/dist/{package}/*" -# TODO(livekit/verwalter#138): `{version}` is the semver form (1.6.0-rc.1), but -# the sdist of an rc is 1.6.0rc1. Until a PEP 440 placeholder exists, the check -# never finds an rc: `publish` uploads it anyway (the command is safe to run -# twice), but `status --check` in the verify job fails for it. Switch each URL to -# the PEP 440 placeholder once it ships. [packages.livekit] versioning.files = [{ path = "livekit/rtc/version.py", regex = '__version__ = "(?[^"]+)"' }] release.tag = "rtc-v{version}"