1#!/bin/bash 2 3set -eu 4set -o pipefail 5 6function set_cmake_version { 7 sed -i "s/\(set(PROJECT_VERSION \"\).*\")/\1${1}\")/g" CMakeLists.txt 8} 9 10# We start from master (that has the beta tag). 11git checkout master 12 13# Something like: kdisplay@5.XX.0 14LAST_TAG=$(git describe --abbrev=0) 15LAST_BETA_VERSION=$(echo $LAST_TAG | sed -e 's,kdisplay@\(\),\1,g') 16 17echo "Last beta version was: $LAST_BETA_VERSION" 18 19# We always release from stable branch. 20BRANCH_NAME="Plasma/$(echo $LAST_BETA_VERSION | sed -e 's,^\(\w*\.\w*\)\..*,\1,g')" 21echo "Stable branch name: $BRANCH_NAME" 22git checkout $BRANCH_NAME 23 24# Now get current patch level 25LAST_STABLE_TAG=$(git describe --abbrev=0) 26LAST_STABLE_VERSION=$(echo $LAST_STABLE_TAG | sed -e 's,kdisplay@\(\),\1,g') 27 28echo "Last stable version was: $LAST_STABLE_VERSION" 29 30# This updates patch level 31PATCH_VERSION=$(semver -i patch $LAST_STABLE_VERSION) 32 33# The CMake project version is the same as the release version. 34CMAKE_VERSION=$PATCH_VERSION 35 36echo "Next stable version: '${PATCH_VERSION}' Corresponding CMake project version: '${PATCH_VERSION}'" 37 38# This creates the changelog. 39standard-version -t kdisplay\@ --skip.commit true --skip.tag true --preMajor --release-as $PATCH_VERSION 40 41# Set CMake version. 42set_cmake_version $CMAKE_VERSION 43 44# Now we have all changes ready. 45git add CMakeLists.txt CHANGELOG.md 46 47# Commit and tag it. 48git commit -m "build: create patch release ${PATCH_VERSION}" -m "Update changelog and raise CMake project version to ${CMAKE_VERSION}." 49git tag -a "kdisplay@${PATCH_VERSION}" -m "Create patch release ${PATCH_VERSION}." 50 51# Go back to master branch and update changelog. 52git checkout master 53git checkout $BRANCH_NAME CHANGELOG.md 54git commit -m "docs: update changelog" -m "Update changelog from branch $BRANCH_NAME at patch release ${PATCH_VERSION}." 55 56echo "Changes applied. Check integrity of master and $BRANCH_NAME branches. Then issue 'git push --follow-tags' on both." 57