Skip to content

Commit efcec48

Browse files
committed
Add script for version/copyright updates
1 parent f519baf commit efcec48

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

builds/release-helper.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
# release-helper.sh - maintainer utility script to change
4+
# the library version and update all copyright dates
5+
# by carstene1ns 2020, released under the MIT license
6+
7+
year=$(date +%Y)
8+
version=$1
9+
10+
if [[ ! -z $version ]]; then
11+
12+
if [[ ! $version =~ ^[0-9]\.[0-9]\.[0-9]$ ]]; then
13+
14+
echo "Invalid version argument. Only digits and dots allowed."
15+
exit 1
16+
17+
fi
18+
19+
echo "Updating Version in:"
20+
21+
echo " CMakeLists.txt"
22+
sed -i "/liblcf VERSION/,1 s/[0-9]\.[0-9]\.[0-9]/$version/" CMakeLists.txt
23+
24+
echo " configure.ac"
25+
sed -i "/AC_INIT/,1 s/[0-9]\.[0-9]\.[0-9]/$version/" configure.ac
26+
27+
echo " README.md"
28+
sed -i "s/\(liblcf-\)[0-9]\.[0-9]\.[0-9]/\1$version/g" README.md
29+
30+
else
31+
32+
echo "No new version argument, only updating copyright years!"
33+
34+
fi
35+
36+
echo "Updating License…"
37+
sed -i "1,1 s/2014-2[0-9][0-9][0-9]/2014-$year/" COPYING
38+
39+
# update copyright years, but filter out external sources
40+
echo "Updating source files…"
41+
42+
find src tests -maxdepth 1 -type f \
43+
-a \( -name "*.h" -o -name "*.cpp" \) \
44+
-a \! \( -name "ini*" -o -name "doctest*" \) \
45+
-exec sed -i "/liblcf\. Copyright/,1 s/2[0-9][0-9][0-9]/$year/" {} +
46+
47+
# updating header for generated source files
48+
grep -q "liblcf\. Copyright.*$year" generator/templates/copyright.tmpl ||
49+
echo " -> You need to run the generator."
50+
sed -i "/liblcf\. Copyright/,1 s/2[0-9][0-9][0-9]/$year/" generator/templates/copyright.tmpl
51+
52+
cat << EOF
53+
54+
If everything is ready and committed, use these commands to publish the git tag:
55+
$ git tag -a (-s) $version -m "Codename \"\fancy codename\""
56+
$ git push (-n) --tags upstream
57+
EOF

0 commit comments

Comments
 (0)