From: Zofia Grzelewska Date: Thu, 6 Jun 2019 16:57:27 +0000 (+0200) Subject: Add release script X-Git-Tag: submit/tizen/20190607.051000~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=79d491291acd92dfbeb8c09ae05e8de8914ffb8f;p=platform%2Fcore%2Fsecurity%2Faskuser.git Add release script Change-Id: I1fdd8cef497a0d5dda517696ddeda0250975eedc --- diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..755cf29 --- /dev/null +++ b/release.sh @@ -0,0 +1,120 @@ +#!/bin/bash +# Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# @file release.sh +# @author Zofia Grzelewska +# @brief Helper script for preparing release commit +# + +echo "Alfa-version of release script. Use on your own responsibility ;)" + +CURRENT_MAJOR=($(cat packaging/askuser-notification.spec | grep Version | awk -F ":" '{print $2}' | awk -F "." '{print $2}')) +CURRENT_MINOR=($(cat packaging/askuser-notification.spec | grep Version | awk -F ":" '{print $2}' | awk -F "." '{print $3}')) +CURRENT_VERSION="$CURRENT_MAJOR.$CURRENT_MINOR" + +# A POSIX variable +OPTIND=1 # Reset in case getopts has been used previously in the shell. + +# Initialize our own variables: +UPDATE_MAJOR=0 + +while getopts "h?m" opt; do + case "$opt" in + h) + echo "Release script for updating askuser-notification version (default: minor version is updated)" + echo "Usage: $0 [-m Update major option instead of minor]" + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + m) UPDATE_MAJOR=1 + ;; + esac +done + +if ((UPDATE_MAJOR)) +then + NEW_MAJOR=$((CURRENT_MAJOR + 1)) + NEW_MINOR=0 +else + NEW_MAJOR=$CURRENT_MAJOR + NEW_MINOR=$((CURRENT_MINOR + 1)) +fi + +NEW_VERSION="$NEW_MAJOR.$NEW_MINOR" + +read -p "Update askuser release from $CURRENT_VERSION to $NEW_VERSION? [y/n]" -n 1 -r +echo + + +if [[ $REPLY =~ ^[Yy]$ ]] +then + echo "Updating CMakeLists.txt files..." + find . -name "CMakeLists.txt" -type f -print0 | xargs -0 sed -i "s/${CURRENT_VERSION}/${NEW_VERSION}/g" + echo "Updating spec files..." + find . -name "*.spec" -type f -print0 | xargs -0 sed -i "s/${CURRENT_VERSION}/${NEW_VERSION}/g" + + echo "Checking left files..." + left_files=($(git grep -IF "${CURRENT_VERSION}" | awk -F ":" '{print $1}' | sort -u)) + + CHANGELOG_FILE="packaging/askuser.changes" + if [ ${#left_files[*]} -ne 1 ] + then + echo "WARNING! Unexpected files left with old version still present :" + echo "${left_files[*]}" + fi + + if [ "${left_files}" != "${CHANGELOG_FILE}" ] + then + echo "WARNING! Unexpected file left with old version still present : ${left_files}" + fi + + echo "Updating changelog..." + + AUTHOR_NAME=`git config user.name` + AUTHOR_EMAIL=`git config user.email` + COMMIT_DATE=`date "+%a %b %d %Y"` + + RELEASE_COMMIT=`git log --pretty=oneline --abbrev-commit | grep "Release.*${CURRENT_VERSION}" | awk {'print $1'}` + IFS=$'\n' + COMMIT_LIST=($(git log --pretty=oneline --abbrev-commit ${RELEASE_COMMIT}..HEAD | awk {'first = $1; $1=""; print $0'}|sed 's/^ //g')) +#COMMIT_LIST=`git log --pretty=oneline --abbrev-commit ${RELEASE_COMMIT}..HEAD | awk {'first = $1; $1=""; print $0'}|sed 's/^ //g'` + + COMMIT_TITLE="Release version 0.${NEW_VERSION}" + COMMIT_MSG_LIST="" + NEWLINE=$'\n' + for COMMIT in ${COMMIT_LIST[@]} + do + COMMIT_MSG_LIST="${COMMIT_MSG_LIST}- ${COMMIT}${NEWLINE}" + done + + echo "${COMMIT_DATE} ${AUTHOR_NAME} <${AUTHOR_EMAIL}> +${COMMIT_TITLE} +${COMMIT_MSG_LIST} +$(cat ${CHANGELOG_FILE})" > ${CHANGELOG_FILE} + + echo "Generating commit msg..." + COMMIT_MSG="${COMMIT_TITLE}${NEWLINE}${NEWLINE}${COMMIT_MSG_LIST}" + + git commit "*CMakeLists.txt" "*spec" $CHANGELOG_FILE -m "${COMMIT_MSG}" + + unset IFS + +fi + +exit +