release.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. set -e
  3. if [[ -z "${GITHUB_TOKEN}" ]]; then
  4. echo "Will not release because no GITHUB_TOKEN defined"
  5. exit
  6. fi
  7. npm install -g github-release-cli
  8. if [[ $( gh release view "${MS_TAG}" 2>&1 ) =~ "release not found" ]]; then
  9. echo "Creating release '${MS_TAG}'"
  10. gh release create "${MS_TAG}"
  11. fi
  12. cd artifacts
  13. set +e
  14. OWNER="${GITHUB_REPOSITORY_OWNER:-"VSCodium"}"
  15. REPO_NAME="${GITHUB_REPOSITORY:(${#OWNER}+1)}"
  16. REPOSITORY="${REPO_NAME:-"vscodium"}"
  17. # git workaround
  18. git config --global --add safe.directory /__w/vscodium/vscodium
  19. for FILE in *
  20. do
  21. if [[ -f "${FILE}" ]] && [[ "${FILE}" != *.sha1 ]] && [[ "${FILE}" != *.sha256 ]]; then
  22. echo "::group::Uploading '${FILE}' at $( date "+%T" )"
  23. gh release upload "${MS_TAG}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  24. EXIT_STATUS=$?
  25. echo "exit: ${EXIT_STATUS}"
  26. if (( "${EXIT_STATUS}" )); then
  27. for (( i=0; i<10; i++ ))
  28. do
  29. github-release delete --owner "${OWNER}" --repo "${REPOSITORY}" --tag "${MS_TAG}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  30. sleep $(( 15 * (i + 1)))
  31. echo "RE-Uploading '${FILE}' at $( date "+%T" )"
  32. gh release upload "${MS_TAG}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  33. EXIT_STATUS=$?
  34. echo "exit: ${EXIT_STATUS}"
  35. if ! (( "${EXIT_STATUS}" )); then
  36. break
  37. fi
  38. done
  39. echo "exit: ${EXIT_STATUS}"
  40. if (( "${EXIT_STATUS}" )); then
  41. echo "'${FILE}' hasn't been uploaded!"
  42. github-release delete --owner "${OWNER}" --repo "${REPOSITORY}" --tag "${MS_TAG}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  43. exit 1
  44. fi
  45. fi
  46. echo "::endgroup::"
  47. fi
  48. done
  49. cd ..