Skip to content

Instantly share code, notes, and snippets.

@larsks
Created April 11, 2011 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsks/914214 to your computer and use it in GitHub Desktop.
Save larsks/914214 to your computer and use it in GitHub Desktop.
#!/bin/bash
pkg=$(basename $(pwd))
tag=HEAD
while getopts 'n:t:' ch; do
case $ch in
(n) pkg=$OPTARG;;
(t) tag=$OPTARG;;
esac
done
shift $(( $OPTIND - 1 ))
[ "$1" ] && version=$1 ||
version=$(cat VERSION 2>/dev/null) ||
version=$(awk '/^Version:/ {print $2}' $pkg.spec 2>/dev/null)
[ "$version" ] || {
echo "missing version." >&2
exit 1
}
[ -d .git ] || {
echo "this does not look like a git repository." >&2
exit 1
}
echo "+ Generating version $version release from $tag."
git archive --prefix="$pkg-$version/" $tag |
gzip > $pkg-$version.tar.gz
ls -l $pkg-$version.tar.gz
echo "+ All done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment