-
-
Notifications
You must be signed in to change notification settings - Fork 244
/
update_wiki.sh
executable file
·34 lines (32 loc) · 1.2 KB
/
update_wiki.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
#!/bin/bash
read -p "Enter the old version: " oldVersion
read -p "Enter the new version: " newVersion
tmpFolderRootName=/tmp/$RANDOM
folderName=${tmpFolderRootName}/awaitility.wiki
updateFiles() {
if [[ -z "$filesToUpdate" ]]
then
echo "Couldn't find any files to update."
exit 0
fi
for file in ${filesToUpdate}
do
echo "Updating $file" &&
sed -i "" "s/${oldVersion}/${newVersion}/g" "$file"
done
}
git clone https://github.com/awaitility/awaitility.wiki.git ${folderName} && cd ${folderName} &&
filesToUpdate=$(find * ! -name "ReleaseNotes*.md" ! -name "Release-Notes*.md" ! -name "OldNews.md" ! -name "How_to_release.md" -name "*.md" -type f -print) &&
updateFiles &&
read -p "Would you like to commit the changes? [y/N]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Committing and pushing changes" &&
git commit -am "Updating docs for version ${newVersion}" && git push && echo "Changes pushed.." &&
echo "Cleaning up temporary files" &&
rm -rf ${tmpFolderRootName}
else
echo "Changes not committed, do \"cd ${folderName} && git commit -am \"Updating docs for version ${newVersion}\" && git push\" when ready"
fi
echo "Note that you need to update README.md manually"
cd -