Skip to content

Commit 25e07ba

Browse files
committed
Merge remote-tracking branch 'origin' into ladvoc/upgrade-ffi-0.12.53
2 parents 249b3ab + 03744fb commit 25e07ba

70 files changed

Lines changed: 8598 additions & 4536 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/update_versions.py

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
import pathlib
2+
import re
3+
import click
4+
from packaging.version import Version
5+
6+
PACKAGES = {
7+
"livekit": "livekit-rtc/livekit/rtc/version.py",
8+
"livekit-api": "livekit-api/livekit/api/version.py",
9+
"livekit-protocol": "livekit-protocol/livekit/protocol/version.py",
10+
}
11+
12+
TAG_PREFIXES = {
13+
"livekit": "rtc",
14+
"livekit-api": "api",
15+
"livekit-protocol": "protocol",
16+
}
17+
18+
19+
def _esc(*codes: int) -> str:
20+
return "\033[" + ";".join(str(c) for c in codes) + "m"
21+
22+
23+
def read_version(f: pathlib.Path) -> str:
24+
text = f.read_text()
25+
m = re.search(r'__version__\s*=\s*[\'"]([^\'"]+)[\'"]', text)
26+
if not m:
27+
raise ValueError(f"could not find __version__ in {f}")
28+
return m.group(1)
29+
30+
31+
def write_new_version(f: pathlib.Path, new_version: str) -> None:
32+
text = f.read_text()
33+
new_text = re.sub(
34+
r'__version__\s*=\s*[\'"][^\'"]*[\'"]',
35+
f'__version__ = "{new_version}"',
36+
text,
37+
count=1,
38+
)
39+
f.write_text(new_text)
40+
41+
42+
def bump_version(cur: str, bump_type: str) -> str:
43+
v = Version(cur)
44+
if bump_type == "release":
45+
return v.base_version
46+
if bump_type == "patch":
47+
return f"{v.major}.{v.minor}.{v.micro + 1}"
48+
if bump_type == "minor":
49+
return f"{v.major}.{v.minor + 1}.0"
50+
if bump_type == "major":
51+
return f"{v.major + 1}.0.0"
52+
raise ValueError(f"unknown bump type: {bump_type}")
53+
54+
55+
def bump_prerelease(cur: str, bump_type: str) -> str:
56+
v = Version(cur)
57+
base = v.base_version
58+
if bump_type == "rc":
59+
if v.pre and v.pre[0] == "rc":
60+
next_rc = v.pre[1] + 1
61+
else:
62+
next_rc = 1
63+
return f"{base}.rc{next_rc}"
64+
raise ValueError(f"unknown prerelease bump type: {bump_type}")
65+
66+
67+
def update_api_protocol_dependency(new_protocol_version: str) -> None:
68+
"""Update livekit-api's dependency on livekit-protocol."""
69+
pyproject = pathlib.Path("livekit-api/pyproject.toml")
70+
if not pyproject.exists():
71+
return
72+
old_text = pyproject.read_text()
73+
new_text = re.sub(
74+
r'"livekit-protocol>=[\w.\-]+,',
75+
f'"livekit-protocol>={new_protocol_version},',
76+
old_text,
77+
)
78+
if new_text != old_text:
79+
pyproject.write_text(new_text)
80+
print(f"Updated livekit-api dependency on livekit-protocol to >={new_protocol_version}")
81+
82+
83+
def do_bump(package: str, bump_type: str) -> None:
84+
version_path = PACKAGES[package]
85+
vf = pathlib.Path(version_path)
86+
cur = read_version(vf)
87+
new = bump_version(cur, bump_type)
88+
print(f"{package}: {_esc(31)}{cur}{_esc(0)} -> {_esc(32)}{new}{_esc(0)}")
89+
write_new_version(vf, new)
90+
91+
if package == "livekit-protocol":
92+
update_api_protocol_dependency(new)
93+
94+
95+
def do_prerelease(package: str, prerelease_type: str) -> None:
96+
version_path = PACKAGES[package]
97+
vf = pathlib.Path(version_path)
98+
cur = read_version(vf)
99+
new = bump_prerelease(cur, prerelease_type)
100+
print(f"{package}: {_esc(31)}{cur}{_esc(0)} -> {_esc(32)}{new}{_esc(0)}")
101+
write_new_version(vf, new)
102+
103+
if package == "livekit-protocol":
104+
update_api_protocol_dependency(new)
105+
106+
107+
@click.command()
108+
@click.option(
109+
"--package",
110+
type=click.Choice(list(PACKAGES.keys())),
111+
required=True,
112+
help="Package to bump.",
113+
)
114+
@click.option(
115+
"--pre",
116+
type=click.Choice(["rc", "none"]),
117+
default="none",
118+
help="Pre-release type.",
119+
)
120+
@click.option(
121+
"--bump-type",
122+
type=click.Choice(["patch", "minor", "major", "release"]),
123+
default="patch",
124+
help="Type of version bump.",
125+
)
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+
142+
if pre == "none":
143+
do_bump(package, bump_type)
144+
else:
145+
do_prerelease(package, pre)
146+
147+
148+
if __name__ == "__main__":
149+
bump()

.github/workflows/build-api.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ jobs:
2626
run:
2727
working-directory: ${{ env.PACKAGE_DIR }}
2828
steps:
29-
- uses: actions/checkout@v4
29+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
3030
with:
3131
submodules: true
3232

33-
- uses: actions/setup-python@v4
33+
- uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
3434

3535
- name: Build wheel & sdist
3636
run: |
3737
pip3 install build wheel
3838
python3 -m build --wheel --sdist
3939
40-
- uses: actions/upload-artifact@v4
40+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
4141
with:
4242
name: api-release
4343
path: |
@@ -52,12 +52,12 @@ jobs:
5252
id-token: write
5353
if: startsWith(github.ref, 'refs/tags/api-v') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false)
5454
steps:
55-
- uses: actions/download-artifact@v4
55+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
5656
with:
5757
name: api-release
5858
path: dist
5959

60-
- uses: pypa/gh-action-pypi-publish@release/v1
60+
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
6161

6262
docs:
6363
needs: [publish]

.github/workflows/build-docs.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
8-
91
name: Build Docs
102

113
on:
@@ -45,29 +37,36 @@ jobs:
4537
runs-on: ubuntu-latest
4638

4739
steps:
48-
- uses: actions/checkout@v4
40+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
4941
with:
5042
submodules: recursive
5143

5244
- name: Install Package to Document
53-
run: python -m pip install ${{ inputs.package_dir }}/
45+
env:
46+
PACKAGE_DIR: ${{ inputs.package_dir }}
47+
run: python -m pip install "$PACKAGE_DIR/"
5448

5549
- name: Download ffi
50+
env:
51+
PACKAGE_NAME: ${{ inputs.package_name }}
5652
run: |
57-
if [[ '${{ inputs.package_name }}' = 'livekit.rtc' ]]; then
53+
if [[ "$PACKAGE_NAME" = 'livekit.rtc' ]]; then
5854
pip install requests
59-
python livekit-rtc/rust-sdks/download_ffi.py --output $(python -m site --user-site)/livekit/rtc/resources
55+
python livekit-rtc/rust-sdks/download_ffi.py --output "$(python -m site --user-site)/livekit/rtc/resources"
6056
fi
6157
6258
- name: Install pdoc
6359
run: pip install --upgrade pdoc
6460

6561
- name: Build Docs
66-
run: python -m pdoc ${{ inputs.package_name }} --docformat=google --output-dir docs
62+
env:
63+
PACKAGE_NAME: ${{ inputs.package_name }}
64+
run: python -m pdoc "$PACKAGE_NAME" --docformat=google --output-dir docs
6765

6866
- name: S3 Upload
69-
run: aws s3 cp docs/ s3://livekit-docs/${{ inputs.package_dir }} --recursive
7067
env:
68+
PACKAGE_DIR: ${{ inputs.package_dir }}
7169
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }}
7270
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }}
7371
AWS_DEFAULT_REGION: "us-east-1"
72+
run: aws s3 cp docs/ "s3://livekit-docs/$PACKAGE_DIR" --recursive

.github/workflows/build-protocol.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ jobs:
2828
run:
2929
working-directory: ${{ env.PACKAGE_DIR }}
3030
steps:
31-
- uses: actions/checkout@v4
31+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
3232
with:
3333
submodules: true
3434
ref: ${{ github.event.pull_request.head.ref }}
3535

36-
- uses: actions/setup-python@v4
36+
- uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
3737

3838
- name: Install Protoc
39-
uses: arduino/setup-protoc@v3
39+
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3
4040
with:
4141
version: "25.1"
4242
repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -45,7 +45,7 @@ jobs:
4545
run: ./generate_proto.sh
4646

4747
- name: Add changes
48-
uses: EndBug/add-and-commit@v9
48+
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9
4949
with:
5050
add: '["livekit-protocol/"]'
5151
default_author: github_actions
@@ -58,18 +58,18 @@ jobs:
5858
run:
5959
working-directory: ${{ env.PACKAGE_DIR }}
6060
steps:
61-
- uses: actions/checkout@v4
61+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
6262
with:
6363
submodules: true
6464

65-
- uses: actions/setup-python@v4
65+
- uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
6666

6767
- name: Build wheel & sdist
6868
run: |
6969
pip3 install build wheel
7070
python3 -m build --wheel --sdist
7171
72-
- uses: actions/upload-artifact@v4
72+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
7373
with:
7474
name: protocol-release
7575
path: |
@@ -84,12 +84,12 @@ jobs:
8484
id-token: write
8585
if: startsWith(github.ref, 'refs/tags/protocol-v') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false)
8686
steps:
87-
- uses: actions/download-artifact@v4
87+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
8888
with:
8989
name: protocol-release
9090
path: dist
9191

92-
- uses: pypa/gh-action-pypi-publish@release/v1
92+
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
9393

9494
docs:
9595
needs: [publish]

.github/workflows/build-rtc.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ jobs:
2828
run:
2929
working-directory: ${{ env.PACKAGE_DIR }}
3030
steps:
31-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
3232
with:
3333
submodules: true
3434
ref: ${{ github.event.pull_request.head.ref }}
3535

36-
- uses: actions/setup-python@v4
36+
- uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
3737

3838
- name: Install Protoc
39-
uses: arduino/setup-protoc@v3
39+
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3
4040
with:
4141
version: "25.1"
4242
repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -49,7 +49,7 @@ jobs:
4949
run: ./generate_proto.sh
5050

5151
- name: Add changes
52-
uses: EndBug/add-and-commit@v9
52+
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9
5353
with:
5454
add: '["livekit-rtc/"]'
5555
default_author: github_actions
@@ -75,11 +75,11 @@ jobs:
7575
run:
7676
working-directory: ${{ env.PACKAGE_DIR }}
7777
steps:
78-
- uses: actions/checkout@v4
78+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
7979
with:
8080
submodules: true
8181

82-
- uses: actions/setup-python@v5
82+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
8383
id: setup-python
8484
with:
8585
python-version: "3.11"
@@ -89,7 +89,7 @@ jobs:
8989
env:
9090
CIBW_ARCHS: ${{ matrix.archs }}
9191

92-
- uses: actions/upload-artifact@v4
92+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
9393
with:
9494
name: rtc-release-${{ matrix.os }}
9595
path: livekit-rtc/dist/*.whl
@@ -101,7 +101,7 @@ jobs:
101101
run:
102102
working-directory: ${{ env.PACKAGE_DIR }}
103103
steps:
104-
- uses: actions/checkout@v4
104+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
105105
with:
106106
submodules: true
107107

@@ -110,7 +110,7 @@ jobs:
110110
pip3 install build
111111
python3 -m build --sdist
112112
113-
- uses: actions/upload-artifact@v4
113+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
114114
with:
115115
name: rtc-release-sdist
116116
path: livekit-rtc/dist/*.tar.gz
@@ -180,13 +180,13 @@ jobs:
180180
id-token: write
181181
if: startsWith(github.ref, 'refs/tags/rtc-v') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false)
182182
steps:
183-
- uses: actions/download-artifact@v4
183+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
184184
with:
185185
pattern: rtc-release-*
186186
path: dist
187187
merge-multiple: true
188188

189-
- uses: pypa/gh-action-pypi-publish@release/v1
189+
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
190190

191191
docs:
192192
needs: [publish]

0 commit comments

Comments
 (0)