Skip to content

Commit 9e0436e

Browse files
authored
ci: fix publish workflow version reading (#603)
1 parent bda3452 commit 9e0436e

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

.github/update_versions.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
"livekit-protocol": "livekit-protocol/livekit/protocol/version.py",
1010
}
1111

12+
TAG_PREFIXES = {
13+
"livekit": "rtc",
14+
"livekit-api": "api",
15+
"livekit-protocol": "protocol",
16+
}
17+
1218

1319
def _esc(*codes: int) -> str:
1420
return "\033[" + ";".join(str(c) for c in codes) + "m"
@@ -117,7 +123,22 @@ def do_prerelease(package: str, prerelease_type: str) -> None:
117123
default="patch",
118124
help="Type of version bump.",
119125
)
120-
def bump(package: str, pre: str, bump_type: str) -> None:
126+
@click.option(
127+
"--print-version",
128+
is_flag=True,
129+
default=False,
130+
help="Print current version and tag prefix, don't bump.",
131+
)
132+
def bump(package: str, pre: str, bump_type: str, print_version: bool) -> None:
133+
if print_version:
134+
vf = pathlib.Path(PACKAGES[package])
135+
version = read_version(vf)
136+
tag_prefix = TAG_PREFIXES[package]
137+
# Output as key=value for easy parsing
138+
print(f"version={version}")
139+
print(f"tag_prefix={tag_prefix}")
140+
return
141+
121142
if pre == "none":
122143
do_bump(package, bump_type)
123144
else:

.github/workflows/publish.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ permissions:
4040
pull-requests: write
4141
id-token: write
4242

43-
env:
44-
# Map PyPI package names to tag prefixes
45-
# livekit -> rtc, livekit-api -> api, livekit-protocol -> protocol
46-
TAG_PREFIX_MAP: '{"livekit":"rtc","livekit-api":"api","livekit-protocol":"protocol"}'
47-
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"}'
48-
4943
jobs:
5044
# ── Step 1: Create a version bump PR ──────────────────────────
5145
bump:
@@ -109,17 +103,10 @@ jobs:
109103
env:
110104
INPUT_PACKAGE: ${{ inputs.package }}
111105
run: |
112-
pkg="$INPUT_PACKAGE"
113-
version_file=$(echo '${{ env.VERSION_FILE_MAP }}' | jq -r --arg pkg "$pkg" '.[$pkg]')
114-
version=$(python -c "
115-
import re, pathlib
116-
m = re.search(r'__version__\s*=\s*[\"'\''](.*?)[\"'\'']', pathlib.Path('${version_file}').read_text())
117-
print(m.group(1))
118-
")
119-
tag_prefix=$(echo '${{ env.TAG_PREFIX_MAP }}' | jq -r --arg pkg "$pkg" '.[$pkg]')
106+
eval "$(python .github/update_versions.py --package "$INPUT_PACKAGE" --print-version)"
120107
echo "version=$version" >> "$GITHUB_OUTPUT"
121108
echo "tag_prefix=$tag_prefix" >> "$GITHUB_OUTPUT"
122-
echo "Package: $pkg, New version: $version, Tag: ${tag_prefix}-v${version}"
109+
echo "Package: $INPUT_PACKAGE, New version: $version, Tag: ${tag_prefix}-v${version}"
123110
124111
- name: Close existing release PRs for this package
125112
env:

0 commit comments

Comments
 (0)