-
Notifications
You must be signed in to change notification settings - Fork 8
/
newVersion.sh
executable file
·122 lines (101 loc) · 3.35 KB
/
newVersion.sh
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
#!/usr/bin/env bash
#
# Copyright 2017-2018 Axel Huebl
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# This file is a maintainer tool to bump the versions inside the
# openPMD-validator repository at all places where necessary.
# Maintainer Inputs ###########################################################
echo "Hi there, this is a openPMD-validator maintainer tool to update the"
echo "source code of openPMD-validator to a new version number on all places"
echo "where necessary."
echo "For it to work, you need write access on the source directory and"
echo "you should be working in a clean git branch without ongoing"
echo "rebase/merge/conflict resolves and without unstaged changes."
# check source dir
REPO_DIR=$(cd $(dirname $BASH_SOURCE) && pwd)
echo
echo "Your current source directory is: $REPO_DIR"
echo
read -p "Are you sure you want to continue? [y/N] " -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "You did not confirm with 'y', aborting."
exit 1
fi
echo "We will now run a few sed commands on your source directory."
echo "Please answer the following questions about the version number"
echo "you want to set first:"
echo
read -p "openPMD STANDARD MAJOR version? (e.g. 1) " -r
MAJOR=$REPLY
echo
read -p "openPMD STANDARD MINOR version? (e.g. 1) " -r
MINOR=$REPLY
echo
read -p "openPMD STANDARD PATCH version? (e.g. 0) " -r
PATCH=$REPLY
echo
read -p "openPMD VALIDATOR running version? (e.g. 5) " -r
VALIV=$REPLY
echo
if [[ -n "$SUFFIX" ]]
then
SUFFIX_STR="-$SUFFIX"
fi
VERSION_STR="$MAJOR.$MINOR.$PATCH.$VALIV"
echo
echo "Your new version is: $VERSION_STR"
echo
read -p "Is this information correct? Will now start updating! [y/N] " -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "You did not confirm with 'y', aborting."
exit 1
fi
# Updates #####################################################################
# regex for a 4 digit version number
regv="\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)"
# setup files
# setuptools
sed -i "s/"\
"\(.*version='\)"$regv"\('.*\)/"\
"\1"$VERSION_STR"\3/" \
$REPO_DIR/setup.py
# example creator scripts
# hdf5
sed -i 's/'\
'\("softwareVersion".*\)'$regv'\(")\)/'\
'\1'$VERSION_STR'\3/' \
$REPO_DIR/openpmd_validator/createExamples_h5.py
# documentation
sed -i 's/'\
'\(.*validator==\)'$regv'\(.*\)/'\
'\1'$VERSION_STR'\3/' \
$REPO_DIR/README.md
sed -i 's/'\
'\(.*validator[@-]\)'$regv'\(.*\)/'\
'\1'$VERSION_STR'\3/' \
$REPO_DIR/README.md
sed -i 's/'\
'\(.*\)'$regv'\(\.tar\.gz\)/'\
'\1'$VERSION_STR'\3/' \
$REPO_DIR/README.md
# Epilog ######################################################################
echo
echo "Done. Please check your source, e.g. via"
echo " git diff"
echo "now and commit the changes if no errors occured."