push-release: use curl -fSs

Best practice when using curl in scripts.
This commit is contained in:
Erik Arvstedt 2023-07-08 15:33:06 +02:00
parent 40c5419a75
commit 0ce3fb1c94
No known key found for this signature in database
GPG Key ID: 33312B944DD97846

View File

@ -36,7 +36,7 @@ fi
cd "${BASH_SOURCE[0]%/*}" cd "${BASH_SOURCE[0]%/*}"
RESPONSE=$(curl https://api.github.com/repos/$REPO/releases/latest 2> /dev/null) RESPONSE=$(curl -fsS https://api.github.com/repos/$REPO/releases/latest)
echo "Latest release" "$(echo "$RESPONSE" | jq -r '.tag_name' | tail -c +2)" echo "Latest release" "$(echo "$RESPONSE" | jq -r '.tag_name' | tail -c +2)"
if [[ ! $DRY_RUN ]]; then if [[ ! $DRY_RUN ]]; then
@ -75,7 +75,7 @@ if [[ $DRY_RUN ]]; then
fi fi
POST_DATA="{ \"tag_name\": \"v$releaseVersion\", \"name\": \"nix-bitcoin-$releaseVersion\", \"body\": \"nix-bitcoin-$releaseVersion\", \"target_comitish\": \"$BRANCH\" }" POST_DATA="{ \"tag_name\": \"v$releaseVersion\", \"name\": \"nix-bitcoin-$releaseVersion\", \"body\": \"nix-bitcoin-$releaseVersion\", \"target_comitish\": \"$BRANCH\" }"
RESPONSE=$(curl -H "Authorization: token $OAUTH_TOKEN" -d "$POST_DATA" https://api.github.com/repos/$REPO/releases 2> /dev/null) RESPONSE=$(curl -fsS -H "Authorization: token $OAUTH_TOKEN" -d "$POST_DATA" https://api.github.com/repos/$REPO/releases)
ID=$(echo "$RESPONSE" | jq -r '.id') ID=$(echo "$RESPONSE" | jq -r '.id')
if [[ $ID == null ]]; then if [[ $ID == null ]]; then
echo "Failed to create release with $POST_DATA" echo "Failed to create release with $POST_DATA"
@ -84,8 +84,8 @@ fi
post_asset() { post_asset() {
GH_ASSET="https://uploads.github.com/repos/$REPO/releases/$ID/assets?name=" GH_ASSET="https://uploads.github.com/repos/$REPO/releases/$ID/assets?name="
curl -H "Authorization: token $OAUTH_TOKEN" --data-binary "@$1" -H "Content-Type: application/octet-stream" \ curl -fsS -H "Authorization: token $OAUTH_TOKEN" --data-binary "@$1" -H "Content-Type: application/octet-stream" \
"$GH_ASSET/$(basename "$1")" &> /dev/null "$GH_ASSET/$(basename "$1")"
} }
post_asset nar-hash.txt post_asset nar-hash.txt
post_asset nar-hash.txt.asc post_asset nar-hash.txt.asc