diff --git a/plugins/github-release.sh b/plugins/github-release.sh index 8aace15..4ff1b51 100644 --- a/plugins/github-release.sh +++ b/plugins/github-release.sh @@ -12,16 +12,16 @@ release() { log_verbose "GitHub release hash: $CHECKOUT_SHA!" if ! $IS_DRY_RUN; then - curl -s -o /dev/null \ - -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "https://api.github.com/repos/$GIT_REPO_NAME/releases" \ - -d "{\"tag_name\":\"$NEXT_RELEASE_TAG\",\"name\":\"$NEXT_RELEASE_TAG\",\"body\":\"$RELEASE_BODY\",\"draft\":false,\"prerelease\":$PRE_RELEASE_VERSION,\"generate_release_notes\":false,\"make_latest\":\"true\"}" - log "Created GitHub release [$NEXT_RELEASE_TAG]!" - log "GitHub release available at https://github.com/$GIT_REPO_NAME/releases/tag/$NEXT_RELEASE_TAG" + if ! command -v gh; then + echo "GitHub CLI not found your machine" + return 1 + fi + + if $PRE_RELEASE_VERSION; then + printf "%b" "${RELEASE_BODY-}" | gh release create "${NEXT_RELEASE_TAG-}" --title "${NEXT_RELEASE_TAG-}" --prerelease --notes-file - + else + printf "%b" "${RELEASE_BODY-}" | gh release create "${NEXT_RELEASE_TAG-}" --title "${NEXT_RELEASE_TAG-}" --latest --notes-file - + fi else log "Skipped GitHub release [$NEXT_RELEASE_TAG] in DRY-RUN mode." fi