]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/opentelemetry-cpp/buildscripts/pre_release.sh
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / buildscripts / pre_release.sh
CommitLineData
1e59de90
TL
1#!/bin/bash
2
3# Copyright The OpenTelemetry Authors
4# SPDX-License-Identifier: Apache-2.0
5
6usage() { echo "Usage: $0 -t <tag>" 1>&2; exit 1; }
7
8while getopts ":t:" o; do
9 case "${o}" in
10 t)
11 tag=${OPTARG}
12 ;;
13 *)
14 usage
15 ;;
16 esac
17done
18if [ ! -z "${t}" ]; then
19 usage
20fi
21
22#validate tag
23semver_regex="^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
24if [[ ${tag} =~ ${semver_regex} ]]; then
25 echo "${tag} is valid semver tag"
26else
27 echo "Error: ${tag} is not a valid semver tag. Exiting"
28 exit -1
29fi
30
31#ensure tag doesn't exits
32if [[ $(git tag --list ${tag}) ]]; then
33 echo "Error: Tag ${tag} already exists. Exiting"
34 exit -1
35fi
36
37if ! git diff --quiet; then \
38 echo "Error: Working tree is not clean, can't proceed with the release process\n"
39 git status
40 git diff
41 exit 1
42fi
43
44# check changelog exists
45changelog_file="./CHANGELOG.md"
46if [ ! -f $changelog_file ]; then
47 echo "Error: $changelog_file doesn't exist. Ensure that you are running this script from repo root directory "
48 exit 1
49fi
50
51if [ ! grep -q "^\#\# \[Unreleased\]$" $changelog_file ]; then
52 echo "Error: $changelog_file doesn't contain Unreleased information. Please update the file with changes and run this script again."
53 exit 1
54fi
55
56git checkout -b pre_release_${tag} main
57if [ $? -ne 0 ]; then
58 echo "Error: Cannot create release branch. Ensure you have sufficient permissions to repo and try again."
59 exit 1
60fi
61
62# update CHANGELOG.md
63date=$(date '+%Y-%m-%d')
64sed -i "/\#\# \[Unreleased\]/a\\ \n\#\# \[${tag}\] ${date}" $changelog_file
65if [ $? -ne 0 ]; then
66 echo "Error: Cannot update CHANGELOG.md file. Update it manually, create the ${tag} and push changes to upstream"
67 exit 1
68fi
69
70git add CHANGELOG.md
71git commit -m "Prepare for releasing ${tag}"
72
73echo "Now validate the changes using git diff main, create the ${tag} and push changes to upstream"
74echo