diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-10-20 03:44:00 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-20 06:46:30 -0400 |
commit | f7c8d65add1a4b46e847e905bb4ac73e94f9e75a (patch) | |
tree | eab9a14c290fccccb9f40f57f5713b13011ca6b9 /.github/actions | |
parent | fdfcbd0315d04580bf10d7b9129fa32665dfeaae (diff) | |
download | subsurface-f7c8d65add1a4b46e847e905bb4ac73e94f9e75a.tar.gz |
GitHub Actions: fix logic error for new tags
It is clear why this wasn't caught in my testing, but the bug should
have been really obvious simply reading through the code.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to '.github/actions')
-rwxr-xr-x | .github/actions/release/upload | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/.github/actions/release/upload b/.github/actions/release/upload index b9eda923a..758fc1bc4 100755 --- a/.github/actions/release/upload +++ b/.github/actions/release/upload @@ -48,14 +48,19 @@ echo "information received for tag $TAG" echo $tag_infos existing_tag_sha=$(echo $tag_infos | jq --raw-output .object.sha) +need_new_release="0" if [[ "$existing_tag_sha" != "null" ]] ; then echo "existing tag on SHA $existing_tag_sha" existing_release=$(curl -XGET --header "Authorization: token ${GITHUB_TOKEN}" "${release_url}") release_id=$(echo $existing_release | jq --raw-output .id ) echo "information received for the release with release ID \"$release_id\"" echo $existing_release + if [[ "$release_id" == "null" ]] ; then + need_new_release="1" + fi if [[ "$existing_tag_sha" != "$COMMIT" ]] ; then + need_new_release="1" echo "tag was on different SHA, delete it and the corresponding release (if it exists)" echo "deleting tag $TAG" curl -XDELETE --header "Authorization: token ${GITHUB_TOKEN}" "${tag_url}" @@ -64,13 +69,17 @@ if [[ "$existing_tag_sha" != "null" ]] ; then delete_url="https://api.github.com/repos/$GITHUB_REPO/releases/$release_id" curl -XDELETE --header "Authorization: token ${GITHUB_TOKEN}" "${delete_url}" fi - echo "create a new release and implicitly a new tag" - release=$(curl -H "Authorization: token ${GITHUB_TOKEN}" --data '{"tag_name": "'"$TAG"'","target_commitish": "'"$COMMIT"'","name": "'"$TAG"'","body": "'"$body"'","draft": false,"prerelease": true}' "https://api.github.com/repos/$GITHUB_REPO/releases") - echo "response to release creation" - echo "$release" fi else echo "this is a new tag" + need_new_release="1" +fi + +if [[ "$need_new_release" = "1" ]] ; then + echo "create a new release and implicitly a new tag" + release=$(curl -H "Authorization: token ${GITHUB_TOKEN}" --data '{"tag_name": "'"$TAG"'","target_commitish": "'"$COMMIT"'","name": "'"$TAG"'","body": "'"$body"'","draft": false,"prerelease": true}' "https://api.github.com/repos/$GITHUB_REPO/releases") + echo "response to release creation" + echo "$release" fi # get the upload URL @@ -79,6 +88,11 @@ echo "release info for $TAG" echo $release_info upload_url=$(echo $release_info | jq --raw-output .upload_url | cut -d '{' -f 1) +if [[ "$upload_url" = "null" ]] ; then + echo "error determining release upload URL, aborting" + exit 1 +fi + # accept up to 9 binaries via environment variables for FILENAME in $BIN1 $BIN2 $BIN3 $BIN4 $BIN5 $BIN6 $BIN7 $BIN8 $BIN9 do |