#!/bin/sh set -e rev=${1:-HEAD} revname=$(git describe $rev) # revname could be 0.7.5 or 0.7.5-NNN-gHASH # turn that into 0.7.5 or 0.7.5+NNN.gHASH case "$revname" in *-*) revname=$(echo "$revname" | sed -e 's/-/+/' -e 's/-/./') esac archive_base="cloud-init-$revname" # when building an archiving from HEAD, ensure that there aren't any # uncomitted changes in the working directory (because these would not # end up in the archive). if [ "$rev" = HEAD ] && ! git diff-index --quiet HEAD --; then if [ -z "$SKIP_UNCOMITTED_CHANGES_CHECK" ]; then echo "ERROR: There are uncommitted changes in your working directory." >&2 exit 1 else echo "WARNING: There are uncommitted changes in your working directory." >&2 echo " This changes will not be included in the archive." >&2 fi fi git archive \ --format=tar.gz \ --prefix="$archive_base/" "$rev" \ "--output=$archive_base.tar.gz" echo "${archive_base}.tar.gz"