From: Zofia Grzelewska Date: Wed, 20 Nov 2019 13:04:25 +0000 (+0100) Subject: Add release script X-Git-Tag: submit/tizen/20191128.101053~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb61c90291f46ea264c41aba2e93601c8fc59cba;p=platform%2Fcore%2Fsecurity%2Fsecurity-manager.git Add release script Change-Id: I199a2333c989bed23a8eee47a5ba9b645363fd2d --- diff --git a/release.sh b/release.sh new file mode 100755 index 00000000..2cc75572 --- /dev/null +++ b/release.sh @@ -0,0 +1,121 @@ +#!/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_TOP=($(cat packaging/security-manager.spec | grep Version | awk -F ":" '{print $2}' | awk -F "." '{print $1}')) +CURRENT_MAJOR=($(cat packaging/security-manager.spec | grep Version | awk -F ":" '{print $2}' | awk -F "." '{print $2}')) +CURRENT_MINOR=($(cat packaging/security-manager.spec | grep Version | awk -F ":" '{print $2}' | awk -F "." '{print $3}')) +CURRENT_VERSION="$CURRENT_TOP.$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 security-manager 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="$CURRENT_TOP.$NEW_MAJOR.$NEW_MINOR" + +read -p "Update security-manager release from $CURRENT_VERSION to $NEW_VERSION? [y/n]" -n 1 -r +echo + + +if [[ $REPLY =~ ^[Yy]$ ]] +then + echo "Updating *.spec files..." + find . -name "*.spec" -type f -print0 | xargs -0 sed -i "s/${CURRENT_VERSION}/${NEW_VERSION}/g" + echo "Updating pc.in files..." + find . -name "*.pc.in" -type f -print0 | xargs -0 sed -i "s/${CURRENT_VERSION}/${NEW_VERSION}/g" + + echo "Checking left files..." + left_files=($(git grep "${CURRENT_VERSION}" | awk -F ":" '{print $1}' | sort -u)) + + CHANGELOG_FILE="packaging/security-manager.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..." + + 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 ${NEW_VERSION}" + DATE=`date +%Y.%m.%d` + + echo "Release: ${NEW_VERSION} +Date: ${DATE} +Name: ${COMMIT_TITLE} +Description: +${COMMIT_LIST[*]} + +############################### + +$(cat ${CHANGELOG_FILE})" > ${CHANGELOG_FILE} + + echo "Generating commit msg..." + NEWLINE=$'\n' + COMMIT_MSG="${COMMIT_TITLE}${NEWLINE}" + for COMMIT in ${COMMIT_LIST[@]} + do + COMMIT_MSG="${COMMIT_MSG}${NEWLINE}* ${COMMIT}" + done + + git commit "*pc.in" "*spec" ${CHANGELOG_FILE} -m "${COMMIT_MSG}" + unset IFS + +fi + + +exit +