release.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. OWNER="${GITHUB_REPOSITORY_OWNER:-"VSCodium"}"
  8. REPO_NAME="${GITHUB_REPOSITORY:(${#OWNER}+1)}"
  9. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  10. REPOSITORY="${REPO_NAME:-"vscodium"}-insiders"
  11. else
  12. REPOSITORY="${REPO_NAME:-"vscodium"}"
  13. fi
  14. npm install -g github-release-cli
  15. if [[ $( gh release view --repo "${OWNER}/${REPOSITORY}" "${RELEASE_VERSION}" 2>&1 ) =~ "release not found" ]]; then
  16. echo "Creating release '${RELEASE_VERSION}'"
  17. gh release create --repo "${OWNER}/${REPOSITORY}" "${RELEASE_VERSION}"
  18. fi
  19. cd artifacts
  20. set +e
  21. for FILE in *
  22. do
  23. if [[ -f "${FILE}" ]] && [[ "${FILE}" != *.sha1 ]] && [[ "${FILE}" != *.sha256 ]]; then
  24. echo "::group::Uploading '${FILE}' at $( date "+%T" )"
  25. gh release upload --repo "${OWNER}/${REPOSITORY}" "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  26. EXIT_STATUS=$?
  27. echo "exit: ${EXIT_STATUS}"
  28. if (( "${EXIT_STATUS}" )); then
  29. for (( i=0; i<10; i++ ))
  30. do
  31. github-release delete --owner "${OWNER}" --repo "${REPOSITORY}" --tag "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  32. sleep $(( 15 * (i + 1)))
  33. echo "RE-Uploading '${FILE}' at $( date "+%T" )"
  34. gh release upload --repo "${OWNER}/${REPOSITORY}" "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  35. EXIT_STATUS=$?
  36. echo "exit: ${EXIT_STATUS}"
  37. if ! (( "${EXIT_STATUS}" )); then
  38. break
  39. fi
  40. done
  41. echo "exit: ${EXIT_STATUS}"
  42. if (( "${EXIT_STATUS}" )); then
  43. echo "'${FILE}' hasn't been uploaded!"
  44. github-release delete --owner "${OWNER}" --repo "${REPOSITORY}" --tag "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
  45. exit 1
  46. fi
  47. fi
  48. echo "::endgroup::"
  49. fi
  50. done
  51. cd ..