diff --git a/hack/update-copyright-year.sh b/hack/update-copyright-year.sh index cde6561c2..9002475b7 100755 --- a/hack/update-copyright-year.sh +++ b/hack/update-copyright-year.sh @@ -1,15 +1,10 @@ #!/bin/bash -# Copyright 2021-2024 the Pinniped contributors. All Rights Reserved. +# Copyright 2021-2026 the Pinniped contributors. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail -if [[ "$OSTYPE" != "darwin"* ]]; then - echo "This script was only written for MacOS (due to differences with Linux sed flags)" - exit 1 -fi - files=$(git diff --cached --name-only) year=$(date +"%Y") @@ -29,10 +24,19 @@ if [[ "${#missing_copyright_files[@]}" -gt "0" ]]; then echo " $f" # The rule when updating copyrights is to always keep the starting year, # and to replace the ending year with the current year. - # This uses MacOS sed flags to replace "XXXX-YYYY" with "XXXX-year" in the copyright notice. - sed -E -e 's/Copyright ([0-9]{4})-([0-9]{4}) the Pinniped contributors/Copyright \1-'"$year"' the Pinniped contributors/' -i '' "$f" - # This uses MacOS sed flags to replace "XXXX" with "XXXX-year" in the copyright notice. - sed -E -e 's/Copyright ([0-9]{4}) the Pinniped contributors/Copyright \1-'"$year"' the Pinniped contributors/' -i '' "$f" + if [[ "$(uname -s)" == "Linux" ]]; then + # sed on Linux uses -i'' (no space in between). + # Replace "XXXX-YYYY" with "XXXX-year" in the copyright notice. + sed -E -e 's/Copyright ([0-9]{4})-([0-9]{4}) the Pinniped contributors/Copyright \1-'"$year"' the Pinniped contributors/' -i'' "$f" + # Replace "XXXX" with "XXXX-year" in the copyright notice. + sed -E -e 's/Copyright ([0-9]{4}) the Pinniped contributors/Copyright \1-'"$year"' the Pinniped contributors/' -i'' "$f" + else + # sed on MacOS uses -i '' (with space in between). + # Replace "XXXX-YYYY" with "XXXX-year" in the copyright notice. + sed -E -e 's/Copyright ([0-9]{4})-([0-9]{4}) the Pinniped contributors/Copyright \1-'"$year"' the Pinniped contributors/' -i '' "$f" + # Replace "XXXX" with "XXXX-year" in the copyright notice. + sed -E -e 's/Copyright ([0-9]{4}) the Pinniped contributors/Copyright \1-'"$year"' the Pinniped contributors/' -i '' "$f" + fi done echo "Done!" exit 1 diff --git a/hack/update-go-mod/update-majors.sh b/hack/update-go-mod/update-majors.sh index 7e0038dc5..bfd7e8f1f 100755 --- a/hack/update-go-mod/update-majors.sh +++ b/hack/update-go-mod/update-majors.sh @@ -36,10 +36,19 @@ for m in $modules; do found_new_version=$? if [[ $found_new_version == 0 ]]; then echo "Found new version $next_version. Replacing imports..." - find . -wholename './.*' -prune -o \ - -path ./generated -prune -o \ - -type f -name '*.go' -print0 | - xargs -0 sed -i '' "s#${m}#${next_version}#g" + if [[ "$(uname -s)" == "Linux" ]]; then + # sed on Linux uses -i'' (no space in between). + find . -wholename './.*' -prune -o \ + -path ./generated -prune -o \ + -type f -name '*.go' -print0 | + xargs -0 sed -i'' "s#${m}#${next_version}#g" + else + # sed on MacOS uses -i '' (with space in between). + find . -wholename './.*' -prune -o \ + -path ./generated -prune -o \ + -type f -name '*.go' -print0 | + xargs -0 sed -i '' "s#${m}#${next_version}#g" + fi fi set -e done