forked from orbisgis/h2gis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_doc.sh
36 lines (29 loc) · 936 Bytes
/
release_doc.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
#!/bin/bash
if [[ -z "$1" ]]; then
echo "Please enter a version."
exit
fi
cd "$(dirname "$0")/docs"
oldVersion=""
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ $line == *"latest release" ]] && [[ $line != "* [$1] : latest release" ]]; then
oldVersion=$(echo $line| cut -d'[' -f 2| cut -d']' -f 1)
echo "* [$1] : latest release" >> "Home.md.new"
echo "${line/latest release/former release}" >> "Home.md.new"
elif [[ $line == "[dev]: ../dev/home" ]]; then
echo "$line" >> "Home.md.new"
echo "[$1]: ../$1/home" >> "Home.md.new"
elif [[ $line != "[$1]: ../$1/home" ]]; then
echo "$line" >> "Home.md.new"
fi
done < "Home.md"
rm "Home.md"
mv "Home.md.new" "Home.md"
cp -r "dev" "$1"
cd "$1"
oldStr="permalink: /docs/dev/"
newStr="permalink: /docs/$1/"
sed -i -e 's%'"$oldStr"'%'"$newStr"'%g' *.md
sed -i -e 's%'"$oldStr"'%'"$newStr"'%g' */*.md
cd "../.."
sed -i -e 's%'"$oldVersion"'%'"$1"'%g' index.html