Skip to content

Commit

Permalink
Compatibility with BSD sed
Browse files Browse the repository at this point in the history
  • Loading branch information
keeganwitt committed Nov 13, 2024
1 parent 1929700 commit d035779
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions update.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail

_sed() {
if sed --version; then
# GNU sed
sed --regexp-extended --in-place "$@"
else
# BSD sed
sed -Ei '' "$@"
fi
}

groovyVersion=$(curl -s 'https://api.github.com/repos/apache/groovy/tags' | grep -Eo 'GROOVY_4.[0-9]{1,2}.[0-9]{1,2}' | head -n 1 | sed -e 's/GROOVY_//' -e 's/_/./g')
echo "Updating to Groovy $groovyVersion"

sed --regexp-extended --in-place "s/ENV GROOVY_VERSION=.+/ENV GROOVY_VERSION=${groovyVersion}/" ./*/Dockerfile
sed --regexp-extended --in-place "s/expectedGroovyVersion: .+$/expectedGroovyVersion: ${groovyVersion}/" .github/workflows/ci.yaml
_sed "s/ENV GROOVY_VERSION=.+/ENV GROOVY_VERSION=${groovyVersion}/" ./*/Dockerfile
_sed "s/expectedGroovyVersion: .+$/expectedGroovyVersion: ${groovyVersion}/" .github/workflows/ci.yaml

0 comments on commit d035779

Please sign in to comment.