From a0a7580a99c8083a998a57675b24d891a74ef153 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Mon, 24 Sep 2018 18:26:45 -0400 Subject: [PATCH] update Signed-off-by: Jess Frazelle --- github-dev/upload-assets | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/github-dev/upload-assets b/github-dev/upload-assets index b374120..b16349e 100755 --- a/github-dev/upload-assets +++ b/github-dev/upload-assets @@ -40,10 +40,18 @@ main(){ tag_name=$(echo $tag_response | jq -e --raw-output .[0].name) tag_id=$(echo $tag_response | jq -e --raw-output .[0].id) - # Create the release. - echo "Creating release for tag name: ${tag_name}" - response=$(curl -XPOST -sSL -H "${AUTH_HEADER}" -H "${API_HEADER}" "${URI}/repos/${GITHUB_REPOSITORY}/release" --data '{"tag_name": "'${tag_name}'","name":"'${tag_name}'","draft":false,"prerelease":false}') - release_id=$(echo $response | jq -e --raw-output .id) + # Get the latest release. + latest_response=$(curl -sSL -H "${AUTH_HEADER}" -H "${API_HEADER}" "${URI}/repos/${GITHUB_REPOSITORY}/releases/latest") + latest_release=$(echo "$latest_response" | jq -e --raw-output .tag_name) + release_id=$(echo "$latest_response" | jq -e --raw-output .id) + + if [[ "$tag_name" != "$latest_release" ]]; then + # Create the release. + echo "Creating release for tag name: ${tag_name}" + response=$(curl -XPOST -sSL -H "${AUTH_HEADER}" -H "${API_HEADER}" "${URI}/repos/${GITHUB_REPOSITORY}/release" --data '{"tag_name": "'${tag_name}'","name":"'${tag_name}'","draft":false,"prerelease":false}') + release_id=$(echo $response | jq -e --raw-output .id) + fi + # Upload the files. echo "Uploading files: ${files[@]}"