diff --git a/scripts/run-prebuilt-tdlib.sh b/scripts/run-prebuilt-tdlib.sh index 8a737b0..16a6f6d 100755 --- a/scripts/run-prebuilt-tdlib.sh +++ b/scripts/run-prebuilt-tdlib.sh @@ -1,25 +1,34 @@ #!/usr/bin/env bash - # Requires gh, jq -version=$1 -npm_patch="${2:-0}" +set -euo pipefail -if [ -z "$version" ]; then - echo "Not enough arguments: expected TDLib version" +if [ $# -lt 1 ]; then + echo "Too few arguments: expected TDLib version" exit 1 fi -commit=$(gh search commits "Update version to $version" -R tdlib/td --json sha --jq '.[0].sha') +version=$1 +npm_patch="${2:-0}" + +if [ "$version" = "latest" ]; then + commit=$(gh api repos/tdlib/td/commits) +else + commit=$(gh search commits "Update version to $version" -R tdlib/td --json commit,sha) +fi -if [ -z "$commit" ]; then +if [ "$commit" = "[]" ]; then echo "Cannot find version $version" exit 1 fi -command="gh workflow run prebuilt-tdlib.yml --ref develop -f tdlib=$commit -f npm-patch=$npm_patch" +message=$(echo $commit | jq -r '.[0].commit.message') +sha=$(echo $commit | jq -r '.[0].sha') + +command="gh workflow run prebuilt-tdlib.yml --ref develop -f tdlib=$sha -f npm-patch=$npm_patch" -echo "TDLib commit: https://github.com/tdlib/td/commit/$commit" +echo "TDLib commit: https://github.com/tdlib/td/commit/$sha" +echo "Message: \"$message\"" echo "Command: $command" read -p "Run? (Ctrl-c or n to exit) " answer case $answer in