Apr/080
Sourceforge.net subversion export, tag and upload script
Today I am writing about a small shell script I wrote cause I hated it to do the routine steps which are needed to get a packed release of NagVis out.
The basic steps to create a new release are documented on NagVis.org.
The script completes the following steps for me:
- Tagging the current revision of the selected branch/trunk
- Exporting the current revision
- Creating code statistics (For details see NagVis code statistic script)
- Setting owner/group of the files
- Packing the files to a tar.gz archive
- Uploading file via FTP to Sourceforge.net
It’s save to say that this script is not perfect. There are several things which could be done much better. The script could also be extended easily. For example the version definition in the NagVis source code could be changed automatically before tagging the revision. Be careful – this script is quick ‘n dirty and not very error-proof.
But that’s enough for now … here is the script:
#!/bin/bash ############################################################################# # # create-release.sh - Script for packing and uploading NagVis releases # # Copyright (c) 2004-2008 NagVis Project (Contact: lars@vertical-visions.de) # # License: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program 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., 675 Mass Ave, Cambridge, MA 02139, USA. # ############################################################################# svnRoot="https://nagvis.svn.sourceforge.net/svnroot/nagvis/nagvis/" ftpServer="upload.sourceforge.net" uploadMail="lars@vertical-visions.de" uploadDir="incoming" localReleasePath="/home/lami/Daten/nagvis-tools/releases" localToolsPath="/home/lami/Daten/nagvis-tools" echo "#########################################################################" echo "# create-release.sh" echo "#" echo "# This is a Script for automaticaly export, tag and upload" echo "# a new version of NagVis to sourceforge.net" echo "#" echo "# This script is written for personal use. If it is useful" echo "# for you, feel free to use/modify it for your needs." echo "#" echo "# Licenced under the terms and conditions of the GPL Licence" echo "#########################################################################" echo "" echo "Start creating a new release. You have to set two Properties." echo "" echo "1.) Select the source from subversion repository:" echo -n "From (1: Trunk, 2: 1.0-Branch, 3: 1.1-Branch, 4: 1.2-Branch): " read source echo "2.) Insert the new version name:" echo -n "New Version: " read dest if [ ! -d $localReleasePath ]; then echo "Error: The specified release directory (${localReleasePath}) does not exist" exit 1 fi cd $localReleasePath if [ -e ${localReleasePath}/nagvis-${dest} ]; then echo "Error: This version already exist in release directory" exit 1 fi case "$source" in 1) svnUrl=${svnRoot}trunk/ ;; 2) svnUrl=${svnRoot}branches/1.0/ ;; 3) svnUrl=${svnRoot}branches/1.1/ ;; 4) svnUrl=${svnRoot}branches/1.2/ ;; *) echo "Error" exit 1 ;; esac # Create tag for this version svn copy ${svnUrl} ${svnRoot}tags/${dest} -m "Creating ${dest} tag" # Export current code from SVN to local directory svn export ${svnUrl} ${localReleasePath}/nagvis-$dest if [ -f ${localToolsPath}/analyze-nagvis-code.sh ]; then # Create stats for this version and save to file ${localToolsPath}/analyze-nagvis-code.sh ${localReleasePath}/nagvis-$dest $dest >> ${localToolsPath}/nagvis-stats.csv fi # Set permissions of all files to web user chown www-data:www-data ${localReleasePath}/nagvis-${dest} -R # Pack the version tar -cvzf ${localReleasePath}/nagvis-${dest}.tar.gz nagvis-${dest} # Upload to SF.net FTP server ftp -n ${ftpServer} <<End-Of-Session user anonymous "${uploadMail}" binary bell cd ${uploadDir} pwd put "${localReleasePath}/nagvis-${dest}.tar.gz" "nagvis-${dest}.tar.gz" bye End-Of-Session echo "Upload complete." exit 0
The script is being called directly in terminal. When started it asks for two informations:
1. source (branches/trunk)
2. new version name (1.3b1, 1.3, …)







