From 3b5a8b29d056ba28350d17f49ab3570b3ecc4ba5 Mon Sep 17 00:00:00 2001 From: pengtian0 Date: Thu, 17 Nov 2016 14:21:10 +0800 Subject: [PATCH 1/3] [WIP]support release: build debian package with a file which contains the package version --- HWIMO-BUILD | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/HWIMO-BUILD b/HWIMO-BUILD index 2126ab285..8b6a0c835 100755 --- a/HWIMO-BUILD +++ b/HWIMO-BUILD @@ -9,6 +9,12 @@ set -e set -x +# $1 should be a file which contains the release version. +# For example: PKG_VERSION=1.2.3-rc-abc... +if [ -f "$1" ];then + source $1 +fi + rm -rf packagebuild git clone . packagebuild pushd packagebuild @@ -18,18 +24,17 @@ rm -rf node_modules npm install --production --cache=`pwd` git log -n 1 --pretty=format:%h.%ai.%s > commitstring.txt -GITCOMMITDATE=$(git show -s --pretty="format:%ci") -DATESTRING=$(date -d "$GITCOMMITDATE" -u +"%Y-%m-%d-%H%M%SZ") - -PKG_VERSION="$DATESTRING" -if [ -n "$BUILD_NUMBER" ] -then - PKG_VERSION="${PKG_VERSION}-${BUILD_NUMBER}" -fi - export DEBEMAIL="hwimo robots " export DEBFULLNAME="The HWIMO Robots" -dch -v ${PKG_VERSION} autobuild +if [ ! -z "$PKG_VERSION" ];then + if [[ $PKG_VERSION =~ ^[0-9.]+$ ]];then + dch -r "" + else + COMMIT_STR=`git log -n 1 --oneline` + dch -v $PKG_VERSION -u low $COMMIT_STR -b -m + fi +fi + debuild --no-lintian --no-tgz-check -us -uc popd From d726de31ea693d619e83b8825baa2224f810003c Mon Sep 17 00:00:00 2001 From: pengtian0 Date: Wed, 30 Nov 2016 16:53:38 +0800 Subject: [PATCH 2/3] build debian package with version like: 1.2.3-20111012122310Z-b2f2da(nigthly release) or 1.2.3(official release) --- HWIMO-BUILD | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/HWIMO-BUILD b/HWIMO-BUILD index 8b6a0c835..cd2a82690 100755 --- a/HWIMO-BUILD +++ b/HWIMO-BUILD @@ -6,15 +6,14 @@ # apt-get install git pbuilder dh-make ubuntu-dev-tools devscripts # apt-get install nodejs nodejs-legacy npm +# Input (environment variables): +# * PKG_VERSION: The version of debian package, +# such as: 1.3.1 (official release); +# + set -e set -x -# $1 should be a file which contains the release version. -# For example: PKG_VERSION=1.2.3-rc-abc... -if [ -f "$1" ];then - source $1 -fi - rm -rf packagebuild git clone . packagebuild pushd packagebuild @@ -27,13 +26,26 @@ git log -n 1 --pretty=format:%h.%ai.%s > commitstring.txt export DEBEMAIL="hwimo robots " export DEBFULLNAME="The HWIMO Robots" -if [ ! -z "$PKG_VERSION" ];then - if [[ $PKG_VERSION =~ ^[0-9.]+$ ]];then - dch -r "" - else - COMMIT_STR=`git log -n 1 --oneline` - dch -v $PKG_VERSION -u low $COMMIT_STR -b -m - fi +# If PKG_VERSION is not set as an environment variable +# compute it as below: +if [ -z "$PKG_VERSION" ];then + GIT_COMMIT_DATE=$(git show -s --pretty="format:%ci") + DATE_STRING=$(date -d "$GIT_COMMIT_DATE" -u +"%Y%m%d%H%M%SZ") + + GIT_COMMIT_HASH=$(git show -s --pretty="format:%h") + + CHANGELOG_VERSION=$(dpkg-parsechangelog --show-field Version) + + PKG_VERSION="$CHANGELOG_VERSION-$DATE_STRING-$GIT_COMMIT_HASH" +fi + +if [[ $PKG_VERSION =~ ^[0-9.]+$ ]];then + # If version looks like 1.2.3, the build is official build. + # So update the distribution of changelog from "UNRELEASED" to "unstable" + dch -r "" +else + COMMIT_STR=`git log -n 1 --oneline` + dch -v $PKG_VERSION -u low $COMMIT_STR -b -m fi debuild --no-lintian --no-tgz-check -us -uc From afdc11e85bb573bdce7e8f3ca86579c0f071b8bb Mon Sep 17 00:00:00 2001 From: pengtian0 Date: Fri, 2 Dec 2016 13:47:38 +0800 Subject: [PATCH 3/3] fix: official version must match something like: 1.2.3 --- HWIMO-BUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HWIMO-BUILD b/HWIMO-BUILD index cd2a82690..69ed1ddf8 100755 --- a/HWIMO-BUILD +++ b/HWIMO-BUILD @@ -30,7 +30,7 @@ export DEBFULLNAME="The HWIMO Robots" # compute it as below: if [ -z "$PKG_VERSION" ];then GIT_COMMIT_DATE=$(git show -s --pretty="format:%ci") - DATE_STRING=$(date -d "$GIT_COMMIT_DATE" -u +"%Y%m%d%H%M%SZ") + DATE_STRING=$(date -d "$GIT_COMMIT_DATE" -u +"%Y%m%dUTC") GIT_COMMIT_HASH=$(git show -s --pretty="format:%h") @@ -39,7 +39,7 @@ if [ -z "$PKG_VERSION" ];then PKG_VERSION="$CHANGELOG_VERSION-$DATE_STRING-$GIT_COMMIT_HASH" fi -if [[ $PKG_VERSION =~ ^[0-9.]+$ ]];then +if [[ $PKG_VERSION =~ ^([0-9]+\.){2}[0-9]+$ ]];then # If version looks like 1.2.3, the build is official build. # So update the distribution of changelog from "UNRELEASED" to "unstable" dch -r ""