File: mergeall-products/unzipped/_publish.sh
#================================================================================
# Build+publish the full Mergeall source-code package [3.2]. Run anywhere with:
#
# bash _publish.sh
#
# This publishes just the source-code package. App and executable packages
# have their own build/ scripts which must be run on specific platforms; are
# each built as an atomic zip which can be uploaded in a single step; and are
# rarely updated due to flux in build tools, platforms, and Python itself.
#
# Notes:
# - This works only on Mergeall's host; paths and structure are host specific.
# - docetc/docimgs/ also has a _publish.sh to upload just its image galleries.
# - An additional image gallery in docetc/ for 3.3's changes is built here.
# - This used to all be done manually; automation makes changes much easier.
#================================================================================
# Get common defs - host specific
source ~/MY-STUFF/Websites/_admin/BUILD-THUMBSPAGE-CLIENTS/common.sh
Pause=y
function announce() {
echo
echo $1
if [ $Pause == 'y' ]; then
read -p 'Press enter/return to continue'
fi
}
#------------------------------------------------------------------------------
# 1) Update three image galleries in $C first, iff not already current.
# They usually are up to date, because thumbspage changes more often.
#------------------------------------------------------------------------------
read -p "Make galleries now in $C (y or n)? " userreply
if [[ -n $userreply && $userreply == 'y' ]]
then
cd $C/mergeall/docetc/docimgs
platforms='macosx windows linux'
for platform in $platforms; do
py3 $C/thumbspage/thumbspage.py $platform <<-EOF
EOF
done
# feb22: plus a new one in docetc for 3.3's GUI mods (== _generate.sh)
cd $C/mergeall/docetc
py3 $C/thumbspage/thumbspage.py GUI-changes-3.3 \
useDynamicIndexLayout=True \
inputCleanThumbsFolder=True inputThumbMaxSize=128,128 inputUseViewerPages=True
fi
#------------------------------------------------------------------------------
# 2) Make source-package zip in Code/, copy to Websites/, and unzip.
# The build.py script does some housecleaning, and runs a zip-create.py.
#------------------------------------------------------------------------------
announce 'Making source-package zip'
pubdir=$W/Programs/Current/Complete/mergeall-products
cd $C/mergeall/build/build-source
py3 build.py
cp -p Mergeall-source.zip $pubdir
cp -p Mergeall-source.zip ../../_private_/Mergeall-source--$stamp.zip
cd $pubdir
rm -rf unzipped
py3 $Z/zip-extract.py Mergeall-source.zip . -permissions
mv Mergeall-source unzipped
#------------------------------------------------------------------------------
# 3) Add analytics code, and assume image galleries are current.
# Else, run thumbspage first (step 1); analytics are anonymized ahead.
#------------------------------------------------------------------------------
announce 'Adding analytics'
cd unzipped
# main/newest guide
py3 $M/insert-analytics.py UserGuide.html
# screenshot galleries
py3 $M/insert-analytics.py docetc/docimgs/index.html
py3 $M/insert-analytics.py docetc/docimgs/macosx/index.html
py3 $M/insert-analytics.py docetc/docimgs/windows/index.html
py3 $M/insert-analytics.py docetc/docimgs/linux/index.html
py3 $M/insert-analytics.py docetc/GUI-changes-3.3/index.html
# old docs: is it eol yet?
py3 $M/insert-analytics.py docetc/MoreDocs/Revisions.html
py3 $M/insert-analytics.py docetc/MoreDocs/Whitepaper.html
# embedded ziptools: decouple me? (has analytics but can change) [has no more!]
py3 $M/insert-analytics.py test/ziptools/_README.html
#------------------------------------------------------------------------------
# 4) Copy the .zip and unzipped/ folder to union, zip as a combo for upload.
# The _PUBLISH.py step adds IP-anonymize code in analytics, and fixes readmes.
#------------------------------------------------------------------------------
announce 'Building site and upload zip'
cd $W
py3 _PUBLISH.py | tail -n 20
cd UNION/mergeall-products
py3 $Z/zip-create.py macombo.zip unzipped Mergeall-source.zip -skipcruft
#------------------------------------------------------------------------------
# 5) Upload combo zip to site and unzip there: remakes .zip+unzipped/.
#------------------------------------------------------------------------------
announce 'Uploading and unzipping on server'
SCP macombo.zip htdocs/mergeall-products
SSH <<-EOF
cd htdocs/mergeall-products
rm -rf unzipped Mergeall-source.zip
unzip -d . macombo.zip
rm macombo.zip
exit
EOF
rm macombo.zip # local UNION copy
#--------------------------------------------
# 6) Download and verify zip: live to local
#--------------------------------------------
cd $temp
rm -rf UserGuide.html Mergeall-source.zip Mergeall-source diffallm mergeallm
# content
printf '\n** Diff: there should be 1 diff in UserGuide for analytics\n'
curl -O https://learning-python.com/mergeall-products/unzipped/UserGuide.html
diff UserGuide.html $C/mergeall/UserGuide.html
# zipfile
printf '\n** Cmp: there should be no cmp output for zip\n'
curl -O https://learning-python.com/mergeall-products/Mergeall-source.zip
cmp -bl Mergeall-source.zip $C/mergeall/_private_/Mergeall-source--$stamp.zip
# unzippped content
py3 $Z/zip-extract.py Mergeall-source.zip . > /dev/null # makes Mergeall-source/
printf '\n** Diffall: there should be 7 for unzip = -top, +andr, -zt/private/, 4 pkgs~strips\n'
py3 $C/mergeall/diffall.py Mergeall-source $C/mergeall -skipcruft > diffallm
tail -n 13 diffallm
printf '\n** Diffall: search for *UNIQ to see diffs\n'
grep --context=8 '*UNIQ' diffallm
printf '\n** Mergeall: there should be 20 uniqueto 17 uniquefrom\n'
py3 $C/mergeall/mergeall.py $C/mergeall Mergeall-source -skipcruft -report > mergeallm
tail -n 10 mergeallm
printf '\n** Mergeall: these should mirror the diffall diffs\n'
tail -n 78 mergeallm
# keep to eyeball: rm -rf UserGuide.html Mergeall-source.zip Mergeall-source diffall mergeall
echo 'Bye.'