File: new_release.sh

package info (click to toggle)
cppad 2026.00.00.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,584 kB
  • sloc: cpp: 112,960; sh: 6,146; ansic: 179; python: 71; sed: 12; makefile: 10
file content (318 lines) | stat: -rwxr-xr-x 8,565 bytes parent folder | download
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#! /usr/bin/env bash
set -e -u
# !! EDITS TO THIS FILE ARE LOST DURING UPDATES BY xrst.git/bin/dev_tools.sh !!
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2020-25 Bradley M. Bell
# -----------------------------------------------------------------------------
# bin/new_release.sh  [--skip_stable_check_all]
# Creates and check a release for the year and release number specified below.
#
# bin/check_all.sh [--skip_external_links]
# is used by new_release.sh to check the stable branch
# corresponding to this release (unless skipped by new_release.sh flags).
#
# bin/check_all.sh [--skip_external_links]
# is used by new_release to skip checking external links.
# new_release.sh skips this when testing before the new release (tag)  exists.
# -----------------------------------------------------------------------------
year='2025' # Year for this stable version
release='3' # first release for each year starts with 0
# -----------------------------------------------------------------------------
if [ "$0" != 'bin/new_release.sh' ]
then
   echo 'bin/new_release.sh: must be executed from its parent directory'
   exit 1
fi
if [ ! -e './.git' ]
then
   echo 'bin/new_release.sh: cannot find ./.git'
   exit 1
fi
if [[ "$year" =~ ^[0-9]{4}$ ]]
then
   echo "year = $year"
else
   echo "new_release.sh: year = $year is not valid"
   exit 1
fi
if [[ "$release" =~ ^[0-9]{1,2}$ ]]
then
   echo "release = $release"
else
   echo "new_release.sh: release = $release is not valid"
   exit 1
fi
#
# skip_stable_check_all
skip_stable_check_all='no'
while [ $# != 0 ]
do
   if [ "$1" == '--skip_stable_check_all' ]
   then
      skip_stable_check_all='yes'
   else
      echo 'bin/new_release.sh [--skip_stable_check_all]'
      echo "$1 is not a valid argument"
      exit 1
   fi
   shift
done
# -----------------------------------------------------------------------------
# bash function that echos and executes a command
echo_eval() {
   echo $*
   eval $*
}
# -----------------------------------------------------------------------------
#
# main_branch
main_branch=$(git branch --show-current)
if [ "$main_branch" != 'master' ] && [ "$main_branch" != 'main' ]
then
   echo 'bin/new_release.sh: execute using master or main branch'
   exit 1
fi
#
# sed
source bin/grep_and_sed.sh
#
# version_file_list
source bin/dev_settings.sh
#
# first_version_file
first_version_file=$(echo $version_file_list | $sed -e 's|^ *||' -e 's| .*||')
#
# version_type
cat << EOF > temp.sed
/["'][0-9]{8}["']/b one
/["'][0-9]{8}[.][0-9]{1,2}["']/b one
/["'][0-9]{4}[.][0-9]{1,2}[.][0-9]{1,2}["']/b one
b end
#
: one
s|.*["']([0-9]{8})["'].*|\\1|
s|.*["']([0-9]{8}[.][0-9]{1,2})["'].*|\\1|
s|.*["']([0-9]{4}[.][0-9]{1,2}[.][0-9]{1,2})["'].*|\\1|
p
#
: end
EOF
version=$($sed -n -r -f temp.sed $first_version_file)
if [[ "$version" =~ ^[0-9]{8}$ ]]
then
   version_type=1
elif [[ "$version" =~ ^[0-9]{8}[.][0-9]{1,2}$ ]]
then
   version_type=2
elif [[ "$version" =~ ^[0-9]{4}[.][0-9]{1,2}[.][0-9]{1,2}$ ]]
then
   version_type=3
fi
#
# tag
if [ "$version_type" == 1 ] || [ "$version_type" == 2 ]
then
   tag="${year}0000.$release"
else
   tag=$year.0.$release
fi
#
# tag_committed
tag_committed='no'
if git tag --list | grep "$tag" > /dev/null
then
   tag_committed='yes'
fi
#
# stable_branch
stable_branch=stable/$year
#
# stable_local_hash
stable_local_hash=$(git show-ref --hash "heads/$stable_branch" )
#
# stable_remote_hash
stable_remote_hash=$(git show-ref --hash "origin/$stable_branch" )
#
# main_local_hash
main_local_hash=$(git show-ref --hash "heads/$main_branch" )
#
# main_remote_hash
main_remote_hash=$(git show-ref --hash "origin/$main_branch" )
#
# ----------------------------------------------------------------------------
# Changes to main_branch
# ----------------------------------------------------------------------------
#
# version_file_list
cat << EOF > temp.sed
s|stable-[0-9]{4}|stable-$year|g
s|release-[0-9]{4}|release-$year|g
#
s|archive/[0-9]{4}[.][0-9]*[.][0-9]*[.]tar[.]gz|archive/$tag.tar.gz|
s|archive/[0-9]{8}[.]tar[.]gz|archive/$tag.tar.gz|
s|archive/[0-9]{8}[.][0-9]*[.]tar[.]gz|archive/$tag.tar.gz|
#
s|tags/[0-9]{4}[.][0-9]*[.][0-9]*>|tags/$tag>|
s|tags/[0-9]{8}>|tags/$tag>|
s|tags/[0-9]{8}[.][0-9]*>|tags/$tag>|
#
s|tags/[0-9]{4}[.][0-9]*[.][0-9]* *\$|tags/$tag|
s|tags/[0-9]{8} *\$|tags/$tag|
s|tags/[0-9]{8}[.][0-9]* *\$|tags/$tag|
#
EOF
for file in $version_file_list
do
   $sed -r -i $file -f temp.sed
done
#
# run_xrst.sh
if [ "$tag_committed" == 'yes' ]
then
   echo_eval bin/run_xrst.sh --external_links
else
   echo_eval bin/run_xrst.sh
fi
#
# git_status
git_status=$(git status --porcelain)
if [ "$git_status" != '' ]
then
   echo "bin/new_release: git status is not empty for $main_branch branch"
   echo 'use bin/git_commit.sh to commit its changes ?'
   exit 1
fi
# ----------------------------------------------------------------------------
# Changes to stable branch
# ----------------------------------------------------------------------------
if ! git show-ref $stable_branch > /dev/null
then
   echo "bin/new_release: neither local or remove $stable_branch exists."
   echo 'Use the following to create it ?'
   echo "   git branch $stable_branch"
   exit 1
fi
if ! git checkout $stable_branch
then
   echo "bin/new_release: should be able to checkout $stable_branch"
   exit 1
fi
#
# version_file_list
cat << EOF > temp.sed
s|stable-[0-9]{4}|stable-$year|g
s|release-[0-9]{4}|release-$year|g
#
s|archive/[0-9]{4}[.][0-9]*[.][0-9]*[.]tar[.]gz|archive/$tag.tar.gz|
s|archive/[0-9]{8}[.]tar[.]gz|archive/$tag.tar.gz|
s|archive/[0-9]{8}[.][0-9]*[.]tar[.]gz|archive/$tag.tar.gz|
#
s|tags/[0-9]{4}[.][0-9]*[.][0-9]*>|tags/$tag>|
s|tags/[0-9]{8}>|tags/$tag>|
s|tags/[0-9]{8}[.][0-9]*>|tags/$tag>|
#
s|tags/[0-9]{4}[.][0-9]*[.][0-9]* *\$|tags/$tag|
s|tags/[0-9]{8} *\$|tags/$tag|
s|tags/[0-9]{8}[.][0-9]* *\$|tags/$tag|
#
EOF
for file in $version_file_list
do
   $sed -r -i $file -f temp.sed
done
#
# first_version_file
cat << EOF > temp.sed
s|(["'])[0-9]{8}(["'])|\\1$tag\\2|
s|(["'])[0-9]{8}[.][0-9]{1,2}(["'])|\\1$tag\\2|
s|(["'])[0-9]{4}[.][0-9]{1,2}[.][0-9]{1,2}(["'])|\\1$tag\\2|
EOF
$sed -r -f temp.sed -i $first_version_file
if ! grep "['\"]$tag['\"]" $first_version_file > /dev/null
then
   echo "bin/rew_release: branch = $stable_branch"
   echo "Version number should be $tag in $first_version_file"
   exit 1
fi
#
# check_version
# changes to version ?
if ! bin/check_version.sh
then
   echo 'Continuing even thought bin/check_version made changes.'
fi
#
# check_all.sh
if [ "$skip_stable_check_all" == 'no' ]
then
   if [ "$tag_committed" == 'yes' ]
   then
      echo_eval bin/check_all.sh --suppress_spell_warnings
   else
      echo_eval bin/check_all.sh \
         --suppress_spell_warnings --skip_external_links
   fi
fi
#
# git_status
git_status=$(git status --porcelain)
if [ "$git_status" != '' ]
then
   echo "bin/new_release: git status --porcelean not empty for $stable_branch"
   echo 'use bin/git_commit.sh to commit its changes ?'
   exit 1
fi
# -----------------------------------------------------------------------------
#
# stable_remote
if [ "$stable_remote_hash" == '' ]
then
   empty_hash='yes'
   echo "bin/new_release: remote $stable_branch does not exist."
   echo 'Use the following to create it ?'
   echo "   git push origin $stable_branch"
   exit 1
fi
if [ "$stable_local_hash" != "$stable_remote_hash" ]
then
   empty_hash='yes'
   echo "bin/new_release: local and remote $stable_branch differ."
   echo "local  $stable_local_hash"
   echo "remote $stable_remote_hash"
   echo 'Use git push to fix this ?'
   exit 1
fi
#
# push tag
if [ "$tag_committed" == 'no' ]
then
   read -p 'commit release or abort [c/a] ?' response
   if [ "$response" == 'a' ]
   then
      exit 1
   fi
   echo "git tag -a -m 'created by new_release.sh' $tag $stable_remote_hash"
   git tag -a -m 'created by new_release.sh' $tag $stable_remote_hash
   #
   echo "git push origin $tag"
   git push origin $tag
   #
   echo 'bin/new_release.sh: must be re-run to check external links'
   exit 1
fi
#
# main_remote
git checkout $main_branch
if [ "$main_local_hash" != "$main_remote_hash" ]
then
   empty_hash='yes'
   echo "bin/new_release: local and remote $main_branch differ."
   echo "local  $main_local_hash"
   echo "remote $main_remote_hash"
   echo 'Use git push to fix this ?'
   exit 1
fi
# ----------------------------------------------------------------------------
echo 'bin/new_release.sh: OK'
exit 0