Add more logging to CI script

This commit is contained in:
Joseph Donofry 2023-02-28 10:59:47 -05:00
parent b4148d9ca5
commit 4fc14b62cf
No known key found for this signature in database
GPG key ID: E8A1D78EF044B0CB

View file

@ -5,7 +5,7 @@ if [ -z "$CI_COMMIT_TAG" ]; then
exit 1 exit 1
fi fi
echo "Checking if release exists for ${CI_COMMIT_TAG}"
# check if we already have a release for the current tag or not # check if we already have a release for the current tag or not
http_code=$(curl \ http_code=$(curl \
-s \ -s \
@ -18,7 +18,10 @@ http_code=$(curl \
"https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG") "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG")
if [ "$http_code" = "404" ]; then if [ "$http_code" = "404" ]; then
echo "Release does not exist... getting notes from CHANGELOG.md"
release_notes="$(perl -0777 -ne '/.*?(## .*?)\n(## |\Z)/s && print $1' CHANGELOG.md | jq -R -s '.')" release_notes="$(perl -0777 -ne '/.*?(## .*?)\n(## |\Z)/s && print $1' CHANGELOG.md | jq -R -s '.')"
echo "Creating new release for ${CI_COMMIT_TAG}"
# Doing a 'fresh' release, not just updating the assets. # Doing a 'fresh' release, not just updating the assets.
release_json="$(curl \ release_json="$(curl \
-X POST \ -X POST \
@ -28,6 +31,7 @@ if [ "$http_code" = "404" ]; then
https://api.github.com/repos/Nheko-Reborn/nheko/releases \ https://api.github.com/repos/Nheko-Reborn/nheko/releases \
-d "{\"tag_name\":\"${CI_COMMIT_TAG}\",\"target_commitish\":\"master\",\"name\":\"${CI_COMMIT_TAG}\",\"body\":\"${release_notes}\",\"draft\":true,\"prerelease\":true,\"generate_release_notes\":false}")" -d "{\"tag_name\":\"${CI_COMMIT_TAG}\",\"target_commitish\":\"master\",\"name\":\"${CI_COMMIT_TAG}\",\"body\":\"${release_notes}\",\"draft\":true,\"prerelease\":true,\"generate_release_notes\":false}")"
elif [ "$http_code" = "200" ]; then elif [ "$http_code" = "200" ]; then
echo "Release already exists for ${CI_COMMIT_TAG}; Updating"
# Updating a release (probably because of cirrus-ci or so) # Updating a release (probably because of cirrus-ci or so)
release_json=$(curl \ release_json=$(curl \
-s \ -s \
@ -37,12 +41,16 @@ elif [ "$http_code" = "200" ]; then
"https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG") "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG")
fi fi
echo "Getting upload URL..."
upload_url="$(echo "$release_json" | jq '."upload-url"')" upload_url="$(echo "$release_json" | jq '."upload-url"')"
# get rid of the 'hypermedia' stuff at the end and use a 'real' URL # get rid of the 'hypermedia' stuff at the end and use a 'real' URL
echo "Upload URL (hypermedia): ${upload_url}"
upload_url="$(echo "$upload_url" | sed 's/{?name,label\}/?name/g')" upload_url="$(echo "$upload_url" | sed 's/{?name,label\}/?name/g')"
echo "Uploading artifacts"
for file in ./artifacts/*; do for file in ./artifacts/*; do
name="${file##*/}" name="${file##*/}"
echo "Uploading ${name}"
[ -e "$file" ] && curl \ [ -e "$file" ] && curl \
-X POST \ -X POST \
-H "Accept: application/vnd.github+json" \ -H "Accept: application/vnd.github+json" \
@ -50,7 +58,7 @@ for file in ./artifacts/*; do
-H "X-GitHub-Api-Version: 2022-11-28" \ -H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \ -H "Content-Type: application/octet-stream" \
"${upload_url}=$name" \ "${upload_url}=$name" \
--data-binary "@$name" --data-binary "@$file"
done done