tf-a-lts-docs-watcher.sh: Convert Git tag to RTD slug once
Make RTD-related functions to accept a slug, and convert incoming Git tag
to RTD slug once at the beginning and then pass around.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: Ie5b8424d0acf75d978440ad6b3e532e032f14feb
diff --git a/scripts/tf-a-lts-docs-watcher.sh b/scripts/tf-a-lts-docs-watcher.sh
index e3850ef..29ef47b 100755
--- a/scripts/tf-a-lts-docs-watcher.sh
+++ b/scripts/tf-a-lts-docs-watcher.sh
@@ -35,17 +35,18 @@
RTD_VER_API="${RTD_API}/versions"
new_tag=""
+new_slug=""
refname=${GERRIT_REFNAME##*/}
lts_branch=${refname}
if echo ${GERRIT_REFNAME} | grep -q "refs/tags/"; then
new_tag=${GERRIT_REFNAME#refs/tags/}
+ # Convert tag to ReadTheDocs version slug
+ new_slug=$(echo ${new_tag} | tr '[A-Z]/' '[a-z]-')
lts_branch=${refname%.*}
fi
function activate_version() {
version=$1
- # Convert tag to ReadTheDocs version slug
- version=$(echo ${version} | tr '[A-Z]/' '[a-z]-')
max_retry_time=20
retry=0
@@ -73,8 +74,6 @@
function wait_for_build() {
version=$1
- # Convert tag to ReadTheDocs version slug
- version=$(echo ${version} | tr '[A-Z]/' '[a-z]-')
while true; do
status=$(curl -s -H "Authorization: Token ${RTD_API_TOKEN}" "${RTD_API}/builds/" | \
jq -r ".results | map(select(.version==\"$version\")) | .[0].state.code")
@@ -100,7 +99,7 @@
# Triggered by a new tag
if [ -n "${new_tag}" ]; then
- echo -e "\nNew release tag: ${new_tag}"
+ echo -e "\nNew release tag: ${new_tag}, slug: ${new_slug}"
# Hide the current active and unhidden tags
old_tags=$(curl -s -H "Authorization: Token ${RTD_API_TOKEN}" "${RTD_VER_API}/?slug=${lts_branch}&type=tag&active=true" | \
jq -r '.results | map(select(.hidden == false) | .slug) | .[]')
@@ -111,7 +110,7 @@
-d "{\"hidden\": true}" ${RTD_VER_API}/${t}/
done
# Active the new version
- echo "Active new version: ${new_tag}"
- activate_version ${new_tag}
+ echo "Active new version: ${new_slug}"
+ activate_version ${new_slug}
fi