publish.bash
#!/bin/bash
#***************************************************************************************************
#                                                                                                  *
# publish.bash: transfer web to your webserver and create tar.gz in you pub dir.                   *
#                                                                                                  *
#***************************************************************************************************

#***************************************************************************************************
#                                                                                                  *
#     Copyright (C) 2003, 2004 Joerg Kunze                                                         *
#                                                                                                  *
#     This file is part of siliconBrain.                                                           *
#                                                                                                  *
#     siliconBrain is free software; you can redistribute it and/or modify                         *
#     it under the terms of the GNU General Public License as published by                         *
#     the Free Software Foundation; either version 2 of the License, or                            *
#     (at your option) any later version.                                                          *
#                                                                                                  *
#     siliconBrain is distributed in the hope that it will be useful,                              *
#     but WITHOUT ANY WARRANTY; without even the implied warranty of                               *
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                *
#     GNU General Public License for more details.                                                 *
#                                                                                                  *
#     You should have received a copy of the GNU General Public License                            *
#     along with this program; if not, write to the Free Software                                  *
#     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                    *
#                                                                                                  *
#***************************************************************************************************
siliconBrainRelease='$siliconBrainRelease: 0.2.3 $'
siliconBrainRcsIdentifier='$Id: publish.bash,v 1.47 2004/12/14 23:31:26 joerg Exp $'
siliconBrainSaveStamp='$siliconBrainSaveStamp: 2004/12/14 22:26:44, Joerg Kunze$'

eval "$(siliconBrain.configurationReader -- --bash)"

#***************************************************************************************************
#                                                                                                  *
# createNewRelease:                                                                                *
#                                                                                                  *
#***************************************************************************************************
make   distribution/data/releaseInformation
source distribution/data/releaseInformation

#-----------------------------#
# calculate new realse number #
#-----------------------------#
newRelease=${release%.*}.$(( ${release##*.} + 1 ))
echo $newRelease > $releaseFile

#-------------------------------------------------------------#
# without this `rm' `make' has not remade what it should (?). #
#-------------------------------------------------------------#
rm     distribution/data/releaseInformation
make   distribution/data/releaseInformation
source distribution/data/releaseInformation

#-----------------------------------------------#
# update release identifier in all sourcs files #
#-----------------------------------------------#
identifier="siliconBrainRelease"

allSources=$(find * | grep -v 'CVS\|'$siliconBrainTemporary)

for sourceFile in $allSources; do
   if [ ! -d "$sourceFile" ]; then
      sed --expression="1,\$s/\\\$$identifier:[^\\\$]*\\\$/\\\$$identifier: $release \\\$/g" $sourceFile > $sourceFile.new
      chmod --reference=$sourceFile $sourceFile.new
      rm $sourceFile
      mv $sourceFile.new $sourceFile
   fi
done

#---------------------------------------------------------#
# prepend a ChangeLog entry, which documents this publish #
#---------------------------------------------------------#
emacs                                                                      \
   -batch                                                                  \
   --eval="(setq load-path (append $siliconBrainEmacsLoadPath load-path))" \
   -l publishUpdate 2> /dev/null

#***************************************************************************************************
#                                                                                                  *
# tag the file in CVS:                                                                             *
#                                                                                                  *
#***************************************************************************************************
cvs commit -m "published for new release $release"
cvs tag release_$releaseWithUnderscores

#***************************************************************************************************
#                                                                                                  *
# renew the generated web (to reflect the new release number)                                      *
#                                                                                                  *
#***************************************************************************************************
make web

#***************************************************************************************************
#                                                                                                  *
# prepareTarGz:                                                                                    *
#                                                                                                  *
#***************************************************************************************************
(
   tarSource=/tmp/$releasePackageName

   rm --recursive --force $tarSource
   mkdir $tarSource

   cp                            \
      --parents --recursive      \
      $allSources                \
      distribution               \
      $tarSource

   cd /tmp
   tar --create $releasePackageName | gzip > /tmp/$releaseArchive
)

#***************************************************************************************************
#                                                                                                  *
# FTP:                                                                                             *
#                                                                                                  *
#***************************************************************************************************
web=distribution/documentation/web

cd $web

{
   echo "prompt"

   echo "bin"
   echo "put /tmp/$releaseArchive $publishTargetArchive/$releaseArchive"

   echo "ascii"
   echo "cd $publishTargetWeb"
   echo "mkdir $siliconBrainPackageName"
   echo "cd $siliconBrainPackageName"

   for file in $(find .); do
      if [ -d "$file" ]; then
         echo "mkdir $file"
      else
         echo "put $file"
      fi
   done

   echo "bye"

} | ftp -v $publishTargetHost | grep "^local"

# $Log: publish.bash,v $
# Revision 1.47  2004/12/14 23:31:26  joerg
# published for new release 0.2.3
#
# Revision 1.46  2004/12/14 23:17:05  joerg
# published for new release 0.2.2
#
# Revision 1.45  2004/12/14 22:42:23  joerg
# allFiles: all sources have a Log CVS keyword at the end now.
#