Skip to content

Commit e88ea3c

Browse files
committed
read old versions
1 parent f24deab commit e88ea3c

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

package/esp8266-arudino-doc.bash

+36-13
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222

2323

2424
# some variable definitions
25-
arduinoESP_src=$PWD"/../"
25+
tmp_path=$1
26+
arduinoESP_src="$tmp_path/arduino"
2627
version="$(git --work-tree=$arduinoESP_src describe --tags --always)"
2728
release_date=$(date "+%b_%d,_%Y") # format for badge link
2829
build_date=$(date "+%b %d, %Y")
29-
destinaton_path="/tmp/doc"
30+
destination_path="$tmp_path/doc"
3031
doc_template_url="https://github.com/pgollor/esp8266-arduino-docs.git"
3132
url="http://pgollor.github.io/Arduino"
3233

@@ -35,7 +36,7 @@ echo "Arduino ESP8266 source dir: "$arduinoESP_src
3536
echo " version: "$version
3637
echo " release date: "$release_date
3738
echo " build date: "$build_date
38-
echo " put documentation into: "$destinaton_path
39+
echo " put documentation into: "$destination_path
3940
echo "documentatino template url: "$doc_template_url
4041
echo " url: "$url
4142

@@ -50,22 +51,45 @@ fi
5051

5152

5253
# delete old doc dir
53-
rm -fR $destinaton_path
54+
rm -fR $destination_path
5455

5556
# create destination directories
56-
mkdir -p $destinaton_path/src
57-
mkdir -p $destinaton_path/$version
57+
mkdir -p $destination_path/src
58+
mkdir -p $destination_path/$version
5859

5960
# copy doc files to destination soruce dir
60-
cp -R $arduinoESP_src/doc/* $destinaton_path/src
61+
cp -R $arduinoESP_src/doc/* $destination_path/src
6162

6263
# download doc template
63-
git clone $doc_template_url $destinaton_path/build
64+
git clone $doc_template_url $destination_path/build
6465

66+
# create versions.html file
6567

66-
#cur_dir=$PWD
67-
#cd $destinaton_path/build
68-
pushd $destinaton_path/build
68+
# ... read verions
69+
pushd $arduinoESP_src
70+
old_versions=$(git ls-tree -d --name-only remotes/origin/gh-pages versions/ | sed -e 's/versions\///g')
71+
popd
72+
73+
echo -e "\nREAD old versions:"
74+
75+
found_current_version="false"
76+
case "${old_versions[@]}" in *"$version"*) found_current_version="true" ;; esac
77+
78+
if [ "$found_current_version" = "false" ]; then
79+
old_versions=$version" "$old_versions
80+
fi
81+
82+
# ... fill versions.html
83+
for VER in $old_versions
84+
do
85+
echo $VER
86+
echo "<li><a href=\"versions/$VER\">$VER</a></li>" >> $destination_path/build/_includes/versions.html
87+
done
88+
echo ""
89+
90+
91+
# into build dir
92+
pushd $destination_path/build
6993

7094
# link documentation source
7195
ln -s ../src doc
@@ -82,9 +106,8 @@ echo "baseurl: /Arduino/versions/$version" >> _config_local.yml
82106
jekyll build --config _config.yml,_config_local.yml
83107

84108
popd
85-
#cd $cur_dir
86109

87110

88111
# grab badge
89-
wget -q -O $destinaton_path/$version/badge.svg "https://img.shields.io/badge/updated-$release_date-blue.svg"
112+
wget -q -O $destination_path/$version/badge.svg "https://img.shields.io/badge/updated-$release_date-blue.svg"
90113

0 commit comments

Comments
 (0)