@@ -6,26 +6,47 @@ set -euo pipefail
6
6
# - creates a release branch
7
7
# - pushes the release branch
8
8
9
- # Check if a version argument is provided
10
- if [ -z " $1 " ]; then
11
- echo " Please provide a version as a command-line argument (major.minor.patch)."
12
- exit 1
9
+ # ------------------------------
10
+ # Args parsing
11
+ # ------------------------------
12
+
13
+ version=" "
14
+ push=false
15
+
16
+ while [[ " $# " -gt 0 ]]; do
17
+ case $1 in
18
+ -v|--version) version=" $2 " ; shift ;;
19
+ -p|--push) push=true ;;
20
+ * ) echo " Unknown parameter passed: $1 " ; exit 1 ;;
21
+ esac
22
+ shift
23
+ done
24
+
25
+ # Check if the required version argument is provided
26
+ if [ -z " $version " ]; then
27
+ echo " Usage: your_script.sh -v <version> [-p]"
28
+ echo " The version needs to be provided as major.minor.patch."
29
+ exit 1
13
30
fi
14
31
15
32
# Validate the version format (major.minor.patch)
16
- if [[ ! " $1 " =~ ^[0-9]+\. [0-9]+\. [0-9]+$ ]]; then
33
+ if [[ ! " $version " =~ ^[0-9]+\. [0-9]+\. [0-9]+$ ]]; then
17
34
echo " Invalid version format. Please use the major.minor.patch format."
18
35
exit 1
19
36
fi
20
37
38
+ echo " Settings: Version: $version , Push: $push "
39
+
21
40
docs_dir=" $( dirname " $0 " ) /.."
22
41
antora_yaml=$docs_dir /antora.yml
23
42
24
- version=" $1 "
25
-
26
43
# Extract major.minor part of the version
27
44
docs_version=$( echo " $version " | cut -d. -f1,2)
28
45
46
+ # ------------------------------
47
+ # Checking prerequisites
48
+ # ------------------------------
49
+
29
50
# Ask the user if they have written release notes and merged them into main
30
51
echo " Release notes for the new version should already be written and commited to the main branch,"
31
52
echo " so the show up in both the nightly and future versions, as well as the new release branch"
63
84
64
85
echo " All checks passed. You are on the main branch, up to date with the origin, and the working directory is clean."
65
86
87
+ # ------------------------------
88
+ # Updating the antora.yaml
89
+ # ------------------------------
90
+
66
91
# Set version key to docs_version
67
92
sed -i " s/^version:.*/version: \" $docs_version \" /" " $antora_yaml "
68
93
@@ -75,6 +100,10 @@ sed -i "s/^\(\s*\)crd-docs-version:.*/\1crd-docs-version: \"$version\"/" "$antor
75
100
# Display changes using git diff
76
101
git diff " $antora_yaml "
77
102
103
+ # ------------------------------
104
+ # Wrap up: commit and push
105
+ # ------------------------------
106
+
78
107
# Ask the user whether to proceed
79
108
read -p " Do you want to proceed with these changes? (yes/no): " proceed_answer
80
109
@@ -96,5 +125,10 @@ git checkout -b "$branch_name"
96
125
git add " $antora_yaml "
97
126
git commit -m " Update version in antora.yml to $version "
98
127
99
- # Push the branch
100
- git push origin " $branch_name "
128
+ # Push the branch if requested
129
+ if [ " $push " = true ]; then
130
+ echo " Pushing changes to origin ..."
131
+ git push origin " $branch_name "
132
+ else
133
+ echo " Skipping push to origin."
134
+ fi
0 commit comments