2023-04-22 18:54:41 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
2023-12-15 05:59:36 -05:00
|
|
|
GOOGLE_JAVA_FORMAT_VERSION="$(
|
|
|
|
set -euo pipefail
|
2024-09-27 03:59:31 -04:00
|
|
|
awk -F "[:']" '/google-java-format/ {print $4}' "google-java-format/build.gradle"
|
2023-12-15 05:59:36 -05:00
|
|
|
)"
|
2023-11-30 03:20:19 -05:00
|
|
|
echo "Installing Google Java Format: ${GOOGLE_JAVA_FORMAT_VERSION}"
|
|
|
|
|
2023-12-15 05:59:36 -05:00
|
|
|
url=$(
|
|
|
|
set -euo pipefail
|
|
|
|
curl -s \
|
|
|
|
-H "Accept: application/vnd.github+json" \
|
|
|
|
-H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \
|
|
|
|
"https://api.github.com/repos/google/google-java-format/releases/tags/v${GOOGLE_JAVA_FORMAT_VERSION}" |
|
|
|
|
jq --arg name "google-java-format-${GOOGLE_JAVA_FORMAT_VERSION}-all-deps.jar" -r '.assets | .[] | select(.name==$name) | .url'
|
|
|
|
)
|
2023-04-22 18:54:41 -04:00
|
|
|
curl --retry 5 --retry-delay 5 -sL -o /usr/bin/google-java-format \
|
|
|
|
-H "Accept: application/octet-stream" \
|
|
|
|
-H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \
|
|
|
|
"${url}"
|
|
|
|
chmod a+x /usr/bin/google-java-format
|