2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
13 #activate project docs versions for all supported ODL projects.
14 #This script needs to be run either manually by a docs maintainer with a valid RTD API token
15 #or automatically by Jenkins or any CI with a common hidden token.
19 echo "Usage: $0 <token>"
21 echo " token: RTD API Token"
25 # Activate project docs version in RTD
31 echo "Activating $project_name $version_name"
32 curl -X PATCH "https://readthedocs.org/api/v3/projects/$project_name/versions/$version_name/" \
33 -H "Authorization: Token $token" \
34 -H "Content-Type: application/json" \
35 --data "{\"active\": true, \"hidden\": false}"
39 # Build "latest" to force RTD to update available versions
40 update_available_versions() {
44 echo "Forcing RTD to update available versions"
45 curl -X POST "https://readthedocs.org/api/v3/projects/$project_name/versions/latest/builds/" \
46 -H "Authorization: Token $token" \
47 -H "Content-Length: 0"
51 # Build to force RTD to update available versions
57 echo "Forcing RTD to update available versions"
58 curl -X POST "https://readthedocs.org/api/v3/projects/$project_name/versions/$version_name/builds/" \
59 -H "Authorization: Token $token" \
60 -H "Content-Length: 0"
64 while getopts :h: opts; do
88 for project in $(grep -v ^# projects_list.tsv | cut -f1); do
89 update_available_versions "$token" "odl-$project"
93 echo "Waiting 60 seconds for available versions to update"
95 sleep 60 # Wait a minute for RTD to update available versions
97 for project in $(grep -v ^# projects_list.tsv | cut -f1); do
98 version_name=$(grep $project projects_list.tsv | grep -v ^# | cut -f2)
99 activate_version "$token" "odl-$project" "$version_name"
100 build_version "$token" "odl-$project" "$version_name"