@@ -18,7 +18,6 @@ set -euo pipefail
1818
1919script_dir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd -P) "
2020repo_root=" $( cd " ${script_dir} /.." && pwd -P) "
21- rust_dir=" ${repo_root} /client-sdk-rust"
2221rust_repo=" livekit/client-sdk-rust"
2322rust_remote=" https://github.com/${rust_repo} .git"
2423
@@ -35,8 +34,9 @@ Options:
3534 -h, --help
3635 Show this help and exit.
3736
38- When --hash is omitted, the script uses the commit tagged by the most recent
39- published, non-draft GitHub release in livekit/client-sdk-rust (requires gh).
37+ When --hash is omitted, the script uses the commit tagged by the most recently
38+ published, non-draft GitHub release (including prereleases) in
39+ livekit/client-sdk-rust (requires gh).
4040EOF
4141}
4242
@@ -77,98 +77,31 @@ if [[ "$hash_provided" == true && ! "$requested_hash" =~ ^[0-9a-fA-F]{7,40}$ ]];
7777 exit 2
7878fi
7979
80- if ! command -v git > /dev/null 2>&1 ; then
81- echo " ERROR: git not found in PATH" >&2
82- exit 1
83- fi
84-
85- if ! git -C " $repo_root " rev-parse --show-toplevel > /dev/null 2>&1 ; then
86- echo " ERROR: ${repo_root} is not a Git worktree" >&2
87- exit 1
88- fi
89-
90- if [[ ! -e " ${rust_dir} /.git" ]]; then
91- echo " ==> Initializing client-sdk-rust"
92- git -C " $repo_root " submodule update --init client-sdk-rust
93- fi
94-
95- if ! git -C " $rust_dir " diff --quiet ||
96- ! git -C " $rust_dir " diff --cached --quiet; then
97- echo " ERROR: client-sdk-rust has tracked changes; commit or stash them first" >&2
98- exit 1
99- fi
100-
101- fetch_ref=" $requested_hash "
102- release_tag=" "
80+ # Shared checkout logic keeps the two dependency updaters consistent.
81+ source " ${script_dir} /update-submodule-common.sh"
82+ check_update_prerequisites
10383
10484if [[ " $hash_provided " == false ]]; then
10585 if ! command -v gh > /dev/null 2>&1 ; then
10686 echo " ERROR: gh not found in PATH; install GitHub CLI or provide --hash" >&2
10787 exit 1
10888 fi
109-
110- echo " ==> Finding the most recent published Rust SDK release "
111- release_tags= " $(
112- gh api --paginate " repos/ ${rust_repo} /releases?per_page=100 " \
113- --jq ' .[] | select(.draft == false) | .tag_name '
114- ) "
115- release_tag= " ${release_tags %% $' \n ' * } "
89+ echo " ==> Finding the most recently published Rust SDK release "
90+ # Sort across every page by publication time, including prereleases. API
91+ # list order and GitHub's designated "latest" release are different concepts.
92+ release_tag= " $( gh api --hostname github.com -- paginate --slurp \
93+ " repos/ ${rust_repo} /releases?per_page=100 " \
94+ --jq ' [.[][] | select(.draft == false and .published_at != null)] |
95+ sort_by(.published_at, .id) | last | .tag_name // empty ' ) "
11696 if [[ -z " $release_tag " ]]; then
11797 echo " ERROR: no published release found for ${rust_repo} " >&2
11898 exit 1
11999 fi
120-
121- tag_refs=" $(
122- git ls-remote " $rust_remote " \
123- " refs/tags/${release_tag} " " refs/tags/${release_tag} ^{}"
124- ) "
125- while read -r tag_hash tag_ref; do
126- if [[ " $tag_ref " == " refs/tags/${release_tag} ^{}" ]]; then
127- requested_hash=" $tag_hash "
128- break
129- fi
130- if [[ " $tag_ref " == " refs/tags/${release_tag} " ]]; then
131- requested_hash=" $tag_hash "
132- fi
133- done <<< " $tag_refs"
134-
135- if [[ -z " $requested_hash " ]]; then
136- echo " ERROR: release tag '${release_tag} ' was not found in ${rust_repo} " >&2
137- exit 1
138- fi
100+ git check-ref-format " refs/tags/${release_tag} " > /dev/null
139101 fetch_ref=" refs/tags/${release_tag} "
140- echo " ==> Latest release: ${release_tag} (${requested_hash} )"
141- else
142- requested_hash=" $( printf ' %s' " $requested_hash " | tr ' [:upper:]' ' [:lower:]' ) "
143- echo " ==> Requested Rust SDK commit: ${requested_hash} "
144- fi
145-
146- echo " ==> Fetching client-sdk-rust"
147- if [[ " $hash_provided " == false ]]; then
148- git -C " $rust_dir " fetch --quiet origin " $fetch_ref "
149- elif [[ ${# requested_hash} -eq 40 ]]; then
150- if ! git -C " $rust_dir " fetch --quiet origin " $fetch_ref " ; then
151- git -C " $rust_dir " fetch --quiet origin
152- fi
102+ echo " ==> Selected release: ${release_tag} "
153103else
154- git -C " $rust_dir " fetch --quiet origin
104+ fetch_ref= " "
155105fi
156106
157- if ! resolved_hash=" $( git -C " $rust_dir " rev-parse --verify " ${requested_hash} ^{commit}" 2> /dev/null) " ; then
158- echo " ERROR: '${requested_hash} ' does not resolve to a client-sdk-rust commit" >&2
159- exit 1
160- fi
161-
162- current_hash=" $( git -C " $rust_dir " rev-parse HEAD) "
163- if [[ " $current_hash " == " $resolved_hash " ]]; then
164- echo " ==> client-sdk-rust is already at ${resolved_hash} "
165- else
166- git -C " $rust_dir " checkout --quiet --detach " $resolved_hash "
167- echo " ==> Updated client-sdk-rust: ${current_hash} -> ${resolved_hash} "
168- fi
169-
170- echo " ==> Synchronizing nested Rust SDK submodules"
171- git -C " $rust_dir " submodule sync --recursive
172- git -C " $rust_dir " submodule update --init --recursive --checkout
173-
174- echo " ==> Done. Review and commit the client-sdk-rust gitlink change."
107+ update_submodule client-sdk-rust " $rust_remote " " $fetch_ref "
0 commit comments