| 1 | |
| 2 | GIT_COMMIT="${GITHUB_SHA}" |
| 3 | GIT_REPO_SLUG="${GITHUB_REPOSITORY}" |
| 4 | |
| 5 | release_url="https://api.github.com/repos/${GIT_REPO_SLUG}/releases/tags/${RELEASE_TAG}" |
| 6 | echoscip-shell system . . echo. "Getting the release ID..." |
| 7 | echoscip-shell system . . echo. "release_url: ${release_url}" |
| 8 | |
| 9 | release_infos=$(curlscip-shell system . . curl. -XGET --header "Authorization: token ${GITHUB_TOKEN}" "${release_url}") |
| 10 | echoscip-shell system . . echo. "release_infos: ${release_infos}" |
| 11 | |
| 12 | release_id=$(echoscip-shell system . . echo. "${release_infos}" | grepscip-shell system . . grep. "\"id\":" | headscip-shell system . . head. -n 1 | trscip-shell system . . tr. -s " " | cutscip-shell system . . cut. -f 3 -d" " | cutscip-shell system . . cut. -f 1 -d ",") |
| 13 | echoscip-shell system . . echo. "release ID: ${release_id}" |
| 14 | |
| 15 | gitscip-shell system . . git. fetch --tags origin |
| 16 | target_commit_sha=$(gitscip-shell system . . git. rev-list -n 1 "${RELEASE_TAG}") |
| 17 | echoscip-shell system . . echo. "target_commit_sha: ${target_commit_sha}" |
| 18 | echoscip-shell system . . echo. "GIT_COMMIT: ${GIT_COMMIT}" |
| 19 | |
| 20 | if [scip-shell system . . `[`. "${GIT_COMMIT}" != "${target_commit_sha}" ] ; then |
| 21 | |
| 22 | echoscip-shell system . . echo. "GIT_COMMIT != target_commit_sha, hence deleting tag and release for '${RELEASE_TAG}'..." |
| 23 | |
| 24 | if [scip-shell system . . `[`. -n "${release_id}" ]; then |
| 25 | delete_release_url="https://api.github.com/repos/${GIT_REPO_SLUG}/releases/${release_id}" |
| 26 | echoscip-shell system . . echo. "Delete the release..." |
| 27 | echoscip-shell system . . echo. "delete_url: ${delete_release_url}" |
| 28 | curlscip-shell system . . curl. -XDELETE \ |
| 29 | --header "Authorization: token ${GITHUB_TOKEN}" \ |
| 30 | "${delete_release_url}" |
| 31 | fi |
| 32 | |
| 33 | if [scip-shell system . . `[`. "${RELEASE_TAG}" == "continuous" ] ; then |
| 34 | # if this is a continuous build tag, then delete the old tag |
| 35 | # in preparation for the new release |
| 36 | echoscip-shell system . . echo. "Delete the tag..." |
| 37 | delete_tag_url="https://api.github.com/repos/${GIT_REPO_SLUG}/git/refs/tags/${RELEASE_TAG}" |
| 38 | echoscip-shell system . . echo. "delete_url: ${delete_tag_url}" |
| 39 | curlscip-shell system . . curl. -XDELETE \ |
| 40 | --header "Authorization: token ${GITHUB_TOKEN}" \ |
| 41 | "${delete_tag_url}" |
| 42 | fi |
| 43 | |
| 44 | fi |