-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare_release.sh
More file actions
executable file
·97 lines (84 loc) · 4.65 KB
/
Copy pathprepare_release.sh
File metadata and controls
executable file
·97 lines (84 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
###############################################################################
# #
# Copyright 2025-2026 Simon Brandt #
# #
# 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. #
# #
###############################################################################
# Author: Simon Brandt
# E-Mail: simon.brandt@uni-greifswald.de
# Last Modification: 2026-03-25
# Usage: Run this script with
# "bash prepare_release.sh version_number codename".
# Purpose: Prepare a release for the Argparser.
# Define the arguments.
# shellcheck disable=SC2190 # Indexed, not associative array.
declare codename
declare version_number
args=(
"id | val_names | type | arg_no | arg_group | help "
"version_number | version_number | str | 1 | Positional arguments | the version number "
"codename | codename | str | 1 | Positional arguments | the version's codename"
)
source argparser -- "$@"
# Strip the leading "v" from the version number, if given with it.
version_number="${version_number#v}"
# Define the pattern and replacement text for the modification date.
# Both are always the same, unlike the patterns for the version info.
printf -v current_date '%(%F)T' -1
pattern_date='# Last Modification: [0-9]{4}-[0-9]{2}-[0-9]{2}'
replacement_date='# Last Modification: '"${current_date}"
# Replace the modification date and version info in the Argparser.
pattern_version='argparser_version="[1-9][0-9]*\.[0-9]+\.[0-9]+ '
pattern_version+='\\"[[:alpha:]]+ [[:alpha:]]+\\""'
replacement_version='argparser_version="'"${version_number}"
replacement_version+=' \\"'"${codename}"'\\""'
sed --in-place --regexp-extended \
--expression="s/${pattern_date}/${replacement_date}/" \
--expression="s/${pattern_version}/${replacement_version}/" \
argparser
# Replace the modification date and version info in the test suite.
pattern_version='Version: argparser v[1-9][0-9]*\.[0-9]+\.[0-9]+ '
pattern_version+='"[[:alpha:]]+ [[:alpha:]]+"'
replacement_version='Version: argparser v'"${version_number}"' "'
replacement_version+="${codename}"'"'
sed --in-place --regexp-extended \
--expression="s/${pattern_date}/${replacement_date}/" \
--expression="s/${pattern_version}/${replacement_version}/" \
tests/run_tests.sh
# Add the version info to the list of Argparser releases in the issue
# template for bugs.
pattern_version=' - v[1-9][0-9]*\.[0-9]+\.[0-9]+ "[[:alpha:]]+ '
pattern_version+='[[:alpha:]]+"'
replacement_version=' - v'"${version_number}"' "'"${codename}"'"'
sed --in-place --regexp-extended \
--expression="0,/${pattern_version}/s//${replacement_version}\n&/" \
.github/ISSUE_TEMPLATE/bug.yaml
# Add the version info to the list of Argparser releases in the
# documentation and replace the version info for the exemplary --version
# call.
# shellcheck disable=SC2016 # Literal backticks in single quotes.
pattern_version_1='\| `v[1-9][0-9]*\.[0-9]+\.[0-9]+` +\| '
pattern_version_1+='\*[[:alpha:]]+ [[:alpha:]]+\* +\| '
pattern_version_1+='[0-9]{4}-[0-9]{2}-[0-9]{2} +\|'
replacement_version_1='| `v'"${version_number}"'` | *'"${codename}"'* | '
replacement_version_1+="${current_date}"' |'
pattern_version_2='Version: argparser v[1-9][0-9]*\.[0-9]+\.[0-9]+ '
pattern_version_2+='"[[:alpha:]]+ [[:alpha:]]+"'
replacement_version_2='Version: argparser v'"${version_number}"' "'
replacement_version_2+="${codename}"'"'
sed --in-place --regexp-extended \
--expression="0,/${pattern_version_1}/s//${replacement_version_1}\n&/" \
--expression="s/${pattern_version_2}/${replacement_version_2}/" \
docs/.src.md