From 07a1bffc608aee54d277c1be7c82e4524f15b8c4 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Tue, 18 Aug 2015 12:35:42 -0600 Subject: [PATCH] Updating the packaging script to assume tag has already been set --- package.sh | 99 +++++------------------------------------------------- 1 file changed, 9 insertions(+), 90 deletions(-) diff --git a/package.sh b/package.sh index 61f4e6632..881b71b78 100755 --- a/package.sh +++ b/package.sh @@ -10,13 +10,12 @@ # https://github.com/jordansissel/fpm # http://aws.amazon.com/cli/ # -# Packaging process: to package a build, simple execute: +# Packaging process: to package a build, simply execute: # -# package.sh +# package.sh # -# where is the desired version. If generation of a debian and RPM -# package is successful, the script will offer to tag the repo using the -# supplied version string. +# The script will automatically determined the version number from git using +# `git describe --always --tags` # # AWS upload: the script will also offer to upload the packages to S3. If # this option is selected, the credentials should be present in the file @@ -61,7 +60,7 @@ BINS=( # usage prints simple usage information. usage() { - echo -e "$0 [] [-h]\n" + echo -e "$0\n" cleanup_exit $1 } @@ -107,54 +106,6 @@ check_clean_tree() { echo "Git tree is clean." } -# update_tree ensures the tree is in-sync with the repo. -update_tree() { - git pull origin master - if [ $? -ne 0 ]; then - echo "Failed to pull latest code -- aborting." - cleanup_exit 1 - fi - git fetch --tags - if [ $? -ne 0 ]; then - echo "Failed to fetch tags -- aborting." - cleanup_exit 1 - fi - echo "Git tree updated successfully." -} - -# check_tag_exists checks if the existing release already exists in the tags. -check_tag_exists () { - version=$1 - git tag | grep -q "^v$version$" - if [ $? -eq 0 ]; then - echo "Proposed version $version already exists as a tag -- aborting." - cleanup_exit 1 - fi -} - -# make_dir_tree creates the directory structure within the packages. -make_dir_tree() { - work_dir=$1 - version=$2 - mkdir -p $work_dir/$INSTALL_ROOT_DIR/versions/$version/scripts - if [ $? -ne 0 ]; then - echo "Failed to create installation directory -- aborting." - cleanup_exit 1 - fi - mkdir -p $work_dir/$CONFIG_ROOT_DIR - if [ $? -ne 0 ]; then - echo "Failed to create configuration directory -- aborting." - cleanup_exit 1 - fi - mkdir -p $work_dir/$LOGROTATE_DIR - if [ $? -ne 0 ]; then - echo "Failed to create configuration directory -- aborting." - cleanup_exit 1 - fi - -} - - # do_build builds the code. The version and commit must be passed in. do_build() { version=$1 @@ -211,27 +162,19 @@ EOF ########################################################################### # Start the packaging process. -if [ $# -ne 1 ]; then - usage 1 -elif [ "$1" == "-h" ]; then +if [ "$1" == "-h" ]; then usage 0 -else - VERSION=$1 fi -echo -e "\nStarting package process...\n" +VERSION=`git describe --always --tags` + +echo -e "\nStarting package process, version: $VERSION\n" if [ "$CIRCLE_BRANCH" == "" ]; then check_gvm fi check_gopath -if [ "$CIRCLE_BRANCH" == "" ]; then - check_clean_tree - update_tree -fi -check_tag_exists $VERSION do_build $VERSION -make_dir_tree $TMP_WORK_DIR $VERSION ########################################################################### # Copy the assets to the installation directories. @@ -309,30 +252,6 @@ if [ $? -ne 0 ]; then fi echo "Debian package created successfully." -########################################################################### -# Offer to tag the repo. - -if [ "$CIRCLE_BRANCH" == "" ]; then - echo -n "Tag source tree with v$VERSION and push to repo? [y/N] " - read response - response=`echo $response | tr 'A-Z' 'a-z'` - if [ "x$response" == "xy" ]; then - echo "Creating tag v$VERSION and pushing to repo" - git tag v$VERSION - if [ $? -ne 0 ]; then - echo "Failed to create tag v$VERSION -- aborting" - cleanup_exit 1 - fi - git push origin v$VERSION - if [ $? -ne 0 ]; then - echo "Failed to push tag v$VERSION to repo -- aborting" - cleanup_exit 1 - fi - else - echo "Not creating tag v$VERSION." - fi -fi - ########################################################################### # Offer to publish the packages.