Skip to content

Commit bbf4ef1

Browse files
authored
Merge pull request #632 from MaxThevenet/release_script
Add script to update version number in all source files
2 parents d1d8ec2 + 9b65c2d commit bbf4ef1

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

Docs/source/developers/developers.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ Our Doxygen API documentation in classic formatting `is located here <../_static
2020
portability
2121
profiling
2222
documentation
23+
workflow
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. _developers-workflow:
2+
3+
Workflow
4+
========
5+
6+
Make a new Github release
7+
-------------------------
8+
9+
WarpX has one release per month. To make the release, you need to:
10+
11+
* Update the version number in all source files. There is a script for that, so you can do:
12+
13+
.. code-block:: sh
14+
cd Tools/
15+
./update_release.sh
16+
17+
* Merge ``dev`` branch into ``master`` branch.
18+
19+
* Click the `Draft a new release` button at https://github.com/ECP-WarpX/WarpX/releases and follow instructions.

Tools/update_release.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
# This script updates release version number in all source files.
4+
#
5+
# updates occurences like "version = '??.??'" where ??.?? is the version number
6+
# updates occurences like "WarpX v??.??" where ??.?? is the version number
7+
#
8+
# Requirements:
9+
# - gnu grep (default grep on MacOS does not have same -P option)
10+
# - gnu sed (default grep on MacOS does not have same -i option)
11+
12+
set -e
13+
14+
# Get old tag number from git
15+
git_tag=`git describe --tags`
16+
old_release_number="${git_tag%%-*}"
17+
18+
# Construct new tag number from current date
19+
d=`date +%Y.%m`
20+
new_release_number=${d:2}
21+
22+
echo "Replace release number $old_release_number by $new_release_number"
23+
24+
# Loop over files and sed patterns with version number
25+
pattern="\.c$|\.cpp$|\.F90$|\.h$|\.H$|\.ini$|\.md$|\.py$|"\
26+
"\.rst$|\.sh$|\.tex$|\.txt$|\.xml$|\.yml$|"\
27+
"CMakeLists\.txt|inputs"
28+
for i in $(find .. \
29+
-not -path "../.git/*" \
30+
-not -path "../.idea/*" \
31+
-not -path "../Docs/source/api/*" \
32+
-not -path "../Docs/build/*" \
33+
-not -path "../Docs/doxyxml/*" \
34+
-not -path "*wp_parse*" \
35+
-not -path "../tmp_build_dir/*" \
36+
-type f | \
37+
grep -P "${pattern}")
38+
do
39+
echo $i
40+
# update occurences like "version = '??.??'" where ??.?? is the version number
41+
# Note: sleep is required due to a bug in sed: without, the file
42+
# permissions are modified
43+
sed -i "s/version = "\'"$old_release_number"\'"/version = "\'"$new_release_number"\'"/g" $i && sleep .001
44+
# update occurences like "WarpX v??.??" where ??.?? is the version number
45+
sed -i "s/WarpX v$old_release_number/WarpX v$new_release_number/g" $i && sleep .001
46+
done
47+
48+
echo ""
49+
echo "WARNING: Remaining occurences of $old_release_number are listed below."
50+
echo " Is this expected? Or should these be updated too?"
51+
echo ""
52+
git grep "$old_release_number" .

0 commit comments

Comments
 (0)