Skip to content

Instantly share code, notes, and snippets.

@diniremix
Last active February 27, 2017 20:07
Show Gist options
  • Save diniremix/5252058 to your computer and use it in GitHub Desktop.
Save diniremix/5252058 to your computer and use it in GitHub Desktop.
a bash script to generate a tarball file from git repo
#!/usr/bin/bash
clear
dirproy=$(basename "`pwd`")
versionapp=$dirproy\_$(date +%d)_$(date +%b)
echo
echo -e 'Generando archivo tarball del proyecto: \e[1;33m'\"$dirproy\"'\e[0m'
echo -e 'Nombre para la Version: \e[1;36m'\"$versionapp\"'\e[0m'
rama=$(git br| sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \1/')
brname=$(git rev-parse --abbrev-ref HEAD)
echo -e 'Rama actual: \e[1;32m' $rama '\e[0m'
arch=$dirproy\_$(date +%d)$(date +%b)\($brname\)
echo -e 'Archivo a generar: \e[1;31m' \"$arch.tar.gz\" '\e[0m'
echo
echo Linea de configuracion:
echo -e "git archive --format=tar --prefix=$versionapp/$rama | gzip >$arch.tar.gz"
echo
echo Generando Tarball espere...
echo
git archive --format=tar --prefix=$versionapp/$rama | gzip >$arch.tar.gz
if [ -e $arch.tar.gz ]
then
echo -e 'Archivo Tarball: \e[1;31m'$arch.tar.gz'\e[0m creado satisfactoriamente.'
else
echo -e '\e[1;31m Ocurrio un error al crear el archivo: '$arch.tar.gz'\e[0m'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment