forked from cosmos/cosmos-sdk-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync_script.sh
executable file
·78 lines (61 loc) · 2.42 KB
/
sync_script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
set -e -o pipefail
# Set the remote repository URL to clone from
REMOTE_REPO_URL="https://github.com/cosmos/cosmos-sdk.git"
# Store the current working directory in WORK_DIR
WORK_DIR=$(pwd)
# Remove any existing 'cosmos-sdk' directory and clone the remote repository
rm -rf ./cosmos-sdk
git clone "$REMOTE_REPO_URL" cosmos-sdk
# Read the versions from a JSON file and remove the 'v' prefix
VERSIONS=($(jq -r '.[]' versions.json))
VERSIONS+=("main")
# Iterate over each version
for version in "${VERSIONS[@]}"; do
echo "$version"
if [ "$version" == "main" ]; then
branch="main" # Set the branch to 'main'
version_directory="" # For 'main', the version directory is empty
else
version="${version#v}" # Remove the 'v' prefix from the version number
branch="release/v$version.x" # Determine the branch name
version_directory="version-$version" # Create a directory name based on the version
fi
# Skip the '0.47' branch until docs backported
if [ "$branch" = "release/v0.47.x" ]; then
echo "Skipping branch $branch..."
continue
fi
# Change to the 'cosmos-sdk' directory
cd $WORK_DIR/cosmos-sdk
# Fetch the branch from the remote repository and switch to it
git fetch origin "$branch"
git checkout "$branch"
# Check if the branch exists in the remote repository
if ! git show-ref --verify "refs/remotes/origin/$branch" &>/dev/null; then
echo "Branch $branch does not exist in the remote repository."
continue
else
echo "Branch $branch exists, continuing..."
fi
# Run the pre.sh script
cd docs && sh ./pre.sh
for folder in "build" "learn"; do
if [ "$version" == "main" ]; then
cp -r "$WORK_DIR/cosmos-sdk/docs/$folder" "$WORK_DIR/docs/"
else
cp -r "$WORK_DIR/cosmos-sdk/docs/docs/$folder" "$WORK_DIR/versioned_docs/$version_directory/"
fi
done
if [ "$version" == "main" ]; then
cp -r "$WORK_DIR/cosmos-sdk/client/docs/swagger-ui/swagger.yaml" "$WORK_DIR/openapi/"
fi
done
# Leave the 'cosmos-sdk' directory after processing
cd "$WORK_DIR"
# This is copied to ensure main and 0.50 are up to date with one another
cp -a "docs/user" "versioned_docs/version-0.50"
wget -O "docs/user/run-node/04-rosetta.md" "https://raw.githubusercontent.com/cosmos/rosetta/main/README.md"
cp -r "docs/user/run-node/04-rosetta.md" "versioned_docs/version-0.50/user/run-node/04-rosetta.md"
# Remove the 'cosmos-sdk' directory if needed
rm -rf ./cosmos-sdk