From ad90cd22a6be6718aff8149db171c02195d33000 Mon Sep 17 00:00:00 2001 From: changev Date: Thu, 12 Jan 2017 11:13:31 +0800 Subject: [PATCH] modify version number of deb build in travis --- .bintray-deb.json.in | 2 +- debian/changelog | 5 ++--- extra/gen-debbranch.sh | 49 ----------------------------------------- extra/gen-debversion.sh | 24 ++++++++++++++++++++ extra/make-cfg.sh | 11 +++------ extra/make-deb.sh | 18 +++++---------- 6 files changed, 35 insertions(+), 74 deletions(-) mode change 100755 => 100644 .bintray-deb.json.in delete mode 100755 extra/gen-debbranch.sh create mode 100755 extra/gen-debversion.sh diff --git a/.bintray-deb.json.in b/.bintray-deb.json.in old mode 100755 new mode 100644 index f974edf..3d40e08 --- a/.bintray-deb.json.in +++ b/.bintray-deb.json.in @@ -1,6 +1,6 @@ { "package": { - "name": "on-image", + "name": "on-imagebuilder", "repo": "debian", "subject": "rackhd", "vcs_url": "https://github.com/RackHD/on-imagebuilder.git", diff --git a/debian/changelog b/debian/changelog index 7abce0a..2346ff5 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,5 @@ -on-imagebuilder (1.1-1) UNRELEASED; urgency=low +on-imagebuilder (0.9.0) UNRELEASED; urgency=low - [ Alan Wei ] * Initial release - -- Alan Wei Fri, 14 Oct 2016 03:52:50 +0000 + -- rackhd Fri, 14 Oct 2016 03:52:50 +0000 diff --git a/extra/gen-debbranch.sh b/extra/gen-debbranch.sh deleted file mode 100755 index 55c3764..0000000 --- a/extra/gen-debbranch.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -set -ex - -# -# This script will generate var DEBRANCH -# DEBRANCH format is ${SYMBOL}-${DATESTRING} -# - -DEBDIR="./debian" -if [ ! -d "${DEBDIR}" ]; then - echo "no such debian directory ${DEBDIR}" - exit 1 -fi - -# Use the TRAVIS_BRANCH var if defined as -# travis vm doesn't run the git symbolic-ref command. -if [ -n "$TRAVIS_BRANCH" ]; then - BRANCH=${TRAVIS_BRANCH} -else - BRANCH=$(git symbolic-ref --short -q HEAD) -fi - -#Generate SYMBOL according to branch or tag -if [[ "${BRANCH}" == *"master"* ]]; then - SYMBOL=devel -elif [[ "${BRANCH}" == *"release"* ]]; then - SYMBOL=rc -fi - -#When a tag like "release-1.2.3" is pushed, do release -if [ -n "$TRAVIS_TAG" ] && [[ "$TRAVIS_TAG" =~ ^release\/([0-9.]+) ]]; then - SYMBOL=release -fi - -#Generate var DEBBRANCH -#Version in changelog will be assigned when branch created -#The version in pushed tag will be exactly the same with that in changelog -VERSION=$(dpkg-parsechangelog | grep ^Version | cut -d' ' -f2 | cut -d'-' -f1) -GITCOMMITDATE=$(git show -s --pretty="format:%ci") -DATESTRING=$(date -d "$GITCOMMITDATE" -u +"%Y%m%d%H%M%SZ") -HASH=$(git rev-parse --short HEAD) -if [ -z "$DEBBRANCH" ]; then - if [ "$SYMBOL" != "release" ]; then - DEBBRANCH=`echo "${VERSION}~${SYMBOL}-${DATESTRING}-${HASH}" | sed 's/[\/\_]/-/g'` - else - DEBBRANCH=`echo "${VERSION}" | sed 's/[\/\_]/-/g'` - fi -fi -echo $DEBBRANCH \ No newline at end of file diff --git a/extra/gen-debversion.sh b/extra/gen-debversion.sh new file mode 100755 index 0000000..21620fb --- /dev/null +++ b/extra/gen-debversion.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -ex + +# +# This script will generate var DEBRANCH +# DEBRANCH format is ${SYMBOL}-${DATESTRING} +# + +DEBDIR="./debian" +if [ ! -d "${DEBDIR}" ]; then + echo "Debian directory ${DEBDIR} doesn't exist" + exit 1 +fi + +# Version in changelog will be assigned when branch created +# The version in pushed tag will be exactly the same with that in changelog +VERSION=$(dpkg-parsechangelog | grep ^Version | cut -d' ' -f2 | cut -d' ' -f1) +GIT_COMMIT_DATE=$(git show -s --pretty="format:%ci") +DATE_STRING=$(date -d "$GIT_COMMIT_DATE" -u +"%Y%m%dUTC") +GIT_COMMIT_HASH=$(git show -s --pretty="format:%h") +if [ -z "$DEBVERSION" ]; then + DEBVERSION=${VERSION}-${DATE_STRING}-${GIT_COMMIT_HASH} +fi +echo $DEBVERSION diff --git a/extra/make-cfg.sh b/extra/make-cfg.sh index fb32092..251db39 100755 --- a/extra/make-cfg.sh +++ b/extra/make-cfg.sh @@ -8,12 +8,7 @@ cd $SCRIPT_DIR/.. #Modify bintray cfg #Use different COMPONENT to differ the apt source of release and ci-builds -DEBBRANCH=$(./extra/gen-debbranch.sh) -if [[ $DEBBRANCH =~ ^[0-9.]+$ ]]; then - COMPONENT=release -else - COMPONENT=main -fi -sed -e "s/#REVERSION#/${DEBBRANCH}/g" \ - -e "s/#COMPONENT#/${COMPONENT}/g" \ +VERSION=$(./extra/gen-debversion.sh) + +sed -e "s/#REVERSION#/${VERSION}/g" \ .bintray-deb.json.in > .bintray-deb.json \ No newline at end of file diff --git a/extra/make-deb.sh b/extra/make-deb.sh index 115ec86..3ed9bee 100755 --- a/extra/make-deb.sh +++ b/extra/make-deb.sh @@ -17,8 +17,8 @@ if [ -z "$DEBEMAIL" ]; then export DEBEMAIL=`git log -n 1 --pretty=format:%ae` fi -if [ -z "$DEBBRANCH" ]; then - export DEBBRANCH=$(./extra/gen-debbranch.sh) +if [ -z "$DEBVERSION" ]; then + export DEBVERSION=$(./extra/gen-debversion.sh) fi if [ -z "$DEBPKGVER" ]; then @@ -26,21 +26,13 @@ if [ -z "$DEBPKGVER" ]; then fi if [ -z "$DCHOPTS" ]; then - if [[ $DEBBRANCH =~ ^[0-9.]+$ ]]; then - #Use "dch -r" do release, "UNRELEASED" in changelog will be set to "unstable" - #or any other predefined distribution, the timestamp will be updated too. - export DCHOPTS="-r \"\"" - else - #Use "dch -v -u -b" do ci-builds - export DCHOPTS="-v ${DEBBRANCH} -u low ${DEBPKGVER} -b" - fi - + export DCHOPTS="-v ${DEBVERSION} -u low ${DEBPKGVER} -b -m" fi echo "DEBDIR: $DEBDIR" echo "DEBFULLNAME: $DEBFULLNAME" echo "DEBEMAIL: $DEBEMAIL" -echo "DEBBRANCH: $DEBBRANCH" +echo "DEBVERSION: $DEBVERSION" echo "DEBPKGVER: $DEBPKGVER" echo "DCHOPTS: $DCHOPTS" @@ -64,4 +56,4 @@ if [ ! -d deb ]; then mkdir deb fi -cp -a *.deb deb/ \ No newline at end of file +cp -a *.deb deb/