mirror of https://github.com/grafana/grafana
Automation: Verify release artifacts on grafana.com (#89197)
* baldm0mma/verify_release/ create verify_release_for_download function * baldm0mma/verify_release/ add name, image, env * baldm0mma/verify_release/ add initial commands * baldm0mma/verify_release/ add deps? * baldm0mma/verify_release/ update location * baldm0mma/verify_release/ add anno to lib-star * bald0mma/verify_release/ update func name to verify_grafanacom_step * baldm0mma/verify_release/ add verify shell script * baldm0mma/verify_release/ add script content, first attempt * baldm0mma/verify_release/ add node image to verify_grafanacom_step * baldm0mma/verify_release/ add gcom secret note * baldm0mma/verify_release/ add sudo to apt-get * baldm0mma/verify_release/ add anno * baldm0mma/verify_release/ add anno to secrets * baldm0mma/verify_release/ update commands to reflect node env image * baldm0mma/verify_release/ update annos * baldm0mma/verify_release/ update tag variable * baldm0mma/verify release/ add whitespace * baldm0mma/verify_releases/ update with no bash loops * baldm0mma/verify_release/ update exit logic * baldm0mma/verify_release/ remove annos * baldm0mma/verify_releasse/ resign and build yml * baldm0mma/verify_release/ remove annos * baldm0mma/verify_release/ update signature * baldm0mma/verify_release/ download curl * baldm0mma/verify_release/ remove temp key folder removal * baldm0mma/verify_release/ account for artifact download time * baldm0mma/verify_release/ add anno * baldm0mma/verify_release/ update location * baldm0mma/verify_release/ update script * baldm0mma/verify_release/ make drone * baldm0mma/verify_release/ update script for oss or ent * baldm0mma/verify_release/ add promotion option * baldm0mma/verify_release/ make drone * Update scripts/drone/events/release.star Co-authored-by: Kevin Minehart <5140827+kminehart@users.noreply.github.com> * Update scripts/drone/steps/lib.star Co-authored-by: Kevin Minehart <5140827+kminehart@users.noreply.github.com> * Update scripts/drone/steps/lib.star Co-authored-by: Kevin Minehart <5140827+kminehart@users.noreply.github.com> * baldm0mma/verify_release/ update drone * Update scripts/drone/events/release.star Co-authored-by: Kevin Minehart <5140827+kminehart@users.noreply.github.com> * baldm0mma/verify_release/ update drone * Update scripts/drone/steps/lib.star Co-authored-by: Kevin Minehart <5140827+kminehart@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Kevin Minehart <5140827+kminehart@users.noreply.github.com> * baldm0mma/update drone * baldm0mma/verify_release/ update path * baldm0mma/verify_release/ make drone * baldm0mma/update drone * Apply suggestions from code review Co-authored-by: Kevin Minehart <5140827+kminehart@users.noreply.github.com> * baldm0mma/verify_release/ update for loop to account for failure * baldm0mma/verify_release/ make drone * baldm0mma/verify_release/ make format-drone * baldm0mma/verify_release/ rem unused var --------- Co-authored-by: Kevin Minehart <5140827+kminehart@users.noreply.github.com>pull/89522/head
parent
b075926202
commit
491101bc8c
@ -0,0 +1,51 @@ |
||||
#!/bin/bash |
||||
|
||||
version=${1:-$TAG} |
||||
|
||||
# Construct the URL based on the provided version and edition |
||||
if [ "$EDITION" = "enterprise" ]; then |
||||
url="https://grafana.com/api/downloads/grafana-enterprise/versions/$version" |
||||
else |
||||
url="https://grafana.com/api/downloads/grafana/versions/$version" |
||||
fi |
||||
|
||||
# Make a request to the GCOM API to retrieve the artifacts for the specified version. Exit if the request fails. |
||||
if ! artifacts=$(curl "$url"); then |
||||
echo "Failed to retrieve artifact URLs from Grafana.com API. Please check the API key, authentication, edition, and version." |
||||
exit 1 |
||||
fi |
||||
|
||||
# Use Node.js to parse the JSON response and extract the download URLs |
||||
url_string=$(node -e " |
||||
const artifacts = JSON.parse(JSON.stringify($artifacts)); |
||||
const downloadUrls = artifacts.packages.map((package) => package.links.find((link) => link.rel === 'download').href); |
||||
console.log(downloadUrls.join(' ')); |
||||
") |
||||
|
||||
# Convert the url_string to a Bash array |
||||
read -r -a urls <<< "$url_string" |
||||
|
||||
# If empty, no artifact URLs were found for the specified version. Exit with an error. |
||||
if [ ${#urls[@]} -eq 0 ]; then |
||||
echo "No artifact URLs found for version $version. Please check the provided version." |
||||
exit 1 |
||||
fi |
||||
|
||||
# Iterate over the URLs and check the status code of each. If any URL does not return a 200 status code, add it to the failed_urls string. |
||||
failed_urls="" |
||||
for url in "${urls[@]}"; do |
||||
status_code=$(curl -L -s -o /dev/null -w "%{http_code}" "$url") |
||||
if [ "$status_code" -ne 200 ]; then |
||||
failed_urls+="$url\n" |
||||
fi |
||||
done |
||||
|
||||
# If any URLs failed, print them and exit with an error. |
||||
if [ -n "$failed_urls" ]; then |
||||
echo "The following URLs did not return a 200 status code:" |
||||
echo "$failed_urls" |
||||
exit 1 |
||||
else |
||||
echo "All URLs returned a 200 status code. Download links are valid for version $version." |
||||
exit 0 |
||||
fi |
||||
Loading…
Reference in new issue