release.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. for FILE in *
  15. do
  16. if [[ -f "${FILE}" ]] && [[ "${FILE}" != *.sha1 ]] && [[ "${FILE}" != *.sha256 ]]; then
  17. echo "::group::Uploading '${FILE}' at $( date "+%T" )"
  18. gh release upload "${MS_TAG}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  19. EXIT_STATUS=$?
  20. echo "exit: $EXIT_STATUS"
  21. if (( $EXIT_STATUS )); then
  22. for (( i=0; i<10; i++ ))
  23. do
  24. github-release delete --owner VSCodium --repo vscodium --tag "${MS_TAG}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  25. sleep $(( 15 * (i + 1)))
  26. echo "RE-Uploading '${FILE}' at $( date "+%T" )"
  27. gh release upload "${MS_TAG}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  28. EXIT_STATUS=$?
  29. echo "exit: $EXIT_STATUS"
  30. if ! (( $EXIT_STATUS )); then
  31. break
  32. fi
  33. done
  34. echo "exit: $EXIT_STATUS"
  35. if (( $EXIT_STATUS )); then
  36. echo "'${FILE}' hasn't been uploaded!"
  37. github-release delete --owner VSCodium --repo vscodium --tag "${MS_TAG}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  38. exit 1
  39. fi
  40. fi
  41. echo "::endgroup::"
  42. fi
  43. done
  44. cd ..