ci: update copyright year as part of CMake Nightly Date Stamp

Extend commit 0f82d07266 (ci: add job to update CMake Nightly Date
Stamp, 2024-12-17) to update the year range in `Copyright.txt` on
January 1 so we don't have to update it manually once per year.
Our `CMake.Copyright` test verifies that these match.
This commit is contained in:
Brad King
2024-12-18 09:04:14 -05:00
parent 5c7bb0bfd9
commit 1f3eb6c4d4
2 changed files with 12 additions and 2 deletions

View File

@@ -25,7 +25,7 @@ for try in $(seq $n); do
git reset -q --hard FETCH_HEAD
Source/CMakeVersion.bash
git update-index -q --ignore-missing --refresh
modified=$(git diff-index --name-only HEAD -- "Source/CMakeVersion.cmake")
modified=$(git diff-index --name-only HEAD -- "Source/CMakeVersion.cmake" "Copyright.txt")
if test -n "$modified"; then
echo "version changed"
git add -u

View File

@@ -1,7 +1,17 @@
#!/usr/bin/env bash
# Update the version component if it looks like a date or -f is given.
version_file="${BASH_SOURCE%/*}/CMakeVersion.cmake"
if test "x$1" = "x-f"; then shift ; n='*' ; else n='\{8\}' ; fi
if test "$#" -gt 0; then echo 1>&2 "usage: CMakeVersion.bash [-f]"; exit 1; fi
sed -i -e '
s/\(^set(CMake_VERSION_PATCH\) [0-9]'"$n"'\(.*\)/\1 '"$(date +%Y%m%d)"'\2/
' "${BASH_SOURCE%/*}/CMakeVersion.cmake"
' "$version_file"
# Update the copyright notice to match the version date's year.
if version_patch_line=$(grep -E '^set\(CMake_VERSION_PATCH [0-9]{8}\)' "$version_file"); then
version_patch_year="${version_patch_line:24:4}"
if [[ "$version_patch_year" =~ ^[0-9][0-9][0-9][0-9]$ ]] ; then
sed -i -e '
s/\(^Copyright 2000-\)[0-9][0-9][0-9][0-9]\( .*\)/\1'"$version_patch_year"'\2/
' "${BASH_SOURCE%/*}/../Copyright.txt"
fi
fi