Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/update_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"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"
Expand Down Expand Up @@ -117,7 +123,22 @@ def do_prerelease(package: str, prerelease_type: str) -> None:
default="patch",
help="Type of version bump.",
)
def bump(package: str, pre: str, bump_type: str) -> None:
@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:
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ permissions:
pull-requests: write
id-token: write

env:
# Map PyPI package names to tag prefixes
# livekit -> rtc, livekit-api -> api, livekit-protocol -> protocol
TAG_PREFIX_MAP: '{"livekit":"rtc","livekit-api":"api","livekit-protocol":"protocol"}'
VERSION_FILE_MAP: '{"livekit":"livekit-rtc/livekit/rtc/version.py","livekit-api":"livekit-api/livekit/api/version.py","livekit-protocol":"livekit-protocol/livekit/protocol/version.py"}'

jobs:
# ── Step 1: Create a version bump PR ──────────────────────────
bump:
Expand Down Expand Up @@ -109,17 +103,10 @@ jobs:
env:
INPUT_PACKAGE: ${{ inputs.package }}
run: |
pkg="$INPUT_PACKAGE"
version_file=$(echo '${{ env.VERSION_FILE_MAP }}' | jq -r --arg pkg "$pkg" '.[$pkg]')
version=$(python -c "
import re, pathlib
m = re.search(r'__version__\s*=\s*[\"'\''](.*?)[\"'\'']', pathlib.Path('${version_file}').read_text())
print(m.group(1))
")
tag_prefix=$(echo '${{ env.TAG_PREFIX_MAP }}' | jq -r --arg pkg "$pkg" '.[$pkg]')
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: $pkg, New version: $version, Tag: ${tag_prefix}-v${version}"
echo "Package: $INPUT_PACKAGE, New version: $version, Tag: ${tag_prefix}-v${version}"

- name: Close existing release PRs for this package
env:
Expand Down
Loading