Skip to content

Commit 49e59c3

Browse files
committed
ci: make Ant verification portable
1 parent 995b79d commit 49e59c3

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,41 @@ jobs:
6969
for attempt in 1 2 3; do
7070
echo "Downloading Ant from $base_url (attempt $attempt)"
7171
if curl --fail --location --retry 3 --retry-all-errors \
72-
--output "$ant_archive" \
73-
"$base_url/apache-ant-${ant_version}-bin.zip" &&
74-
printf '%s %s\n' "$expected_checksum" "$ant_archive" |
75-
sha512sum --check --status; then
76-
verified=true
77-
break 2
72+
--output "$ant_archive" \
73+
"$base_url/apache-ant-${ant_version}-bin.zip"; then
74+
actual_checksum=$(sha512sum "$ant_archive" | awk '{print $1}')
75+
if [[ "$actual_checksum" == "$expected_checksum" ]]; then
76+
echo "Verified Apache Ant ${ant_version} archive"
77+
verified=true
78+
break 2
79+
fi
80+
echo "::warning::Ant download failed verification; SHA-512=$actual_checksum"
81+
else
82+
echo "::warning::Unable to download Ant from $base_url"
7883
fi
79-
80-
actual_checksum=$(sha512sum "$ant_archive" 2>/dev/null |
81-
awk '{print $1}')
82-
echo "::warning::Ant download failed verification; SHA-512=${actual_checksum:-unavailable}"
8384
done
8485
done
8586
8687
if [[ "$verified" != true ]]; then
8788
echo "::error::Unable to download a verified Apache Ant ${ant_version} archive"
8889
exit 1
8990
fi
91+
echo "Extracting Apache Ant ${ant_version}"
9092
unzip -q "$ant_archive" -d "$RUNNER_TEMP"
9193
export PATH="$ant_home/bin:$PATH"
9294
echo "ANT_HOME=$ant_home" >> "$GITHUB_ENV"
9395
echo "$ant_home/bin" >> "$GITHUB_PATH"
94-
ant -version 2>&1 | grep -F "version ${ant_version}"
96+
if ant_version_output=$(ant -version 2>&1); then
97+
echo "$ant_version_output"
98+
else
99+
echo "::error::Apache Ant failed to start"
100+
echo "$ant_version_output"
101+
exit 1
102+
fi
103+
if ! grep -Fq "version ${ant_version}" <<< "$ant_version_output"; then
104+
echo "::error::Unexpected Apache Ant version"
105+
exit 1
106+
fi
95107
96108
- name: Set up DTDDoc 1.1.0
97109
run: |

0 commit comments

Comments
 (0)