2023-07-20 14:25:13 -04:00
|
|
|
#!/usr/bin/env bash
|
2021-10-01 12:47:10 -04:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2024-06-11 13:30:12 -04:00
|
|
|
if [[ -z "${GH_TOKEN}" ]] && [[ -z "${GITHUB_TOKEN}" ]] && [[ -z "${GH_ENTERPRISE_TOKEN}" ]] && [[ -z "${GITHUB_ENTERPRISE_TOKEN}" ]]; then
|
2021-11-10 04:13:12 -05:00
|
|
|
echo "Will not release because no GITHUB_TOKEN defined"
|
2021-10-01 12:47:10 -04:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2022-10-06 16:15:41 -04:00
|
|
|
REPOSITORY_OWNER="${ASSETS_REPOSITORY/\/*/}"
|
|
|
|
REPOSITORY_NAME="${ASSETS_REPOSITORY/*\//}"
|
2022-08-29 09:13:25 -04:00
|
|
|
|
2021-11-10 04:13:12 -05:00
|
|
|
npm install -g github-release-cli
|
2021-10-01 12:47:10 -04:00
|
|
|
|
2022-10-06 16:15:41 -04:00
|
|
|
if [[ $( gh release view --repo "${ASSETS_REPOSITORY}" "${RELEASE_VERSION}" 2>&1 ) =~ "release not found" ]]; then
|
2022-08-16 07:51:45 -04:00
|
|
|
echo "Creating release '${RELEASE_VERSION}'"
|
2022-10-06 16:15:41 -04:00
|
|
|
|
|
|
|
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
|
|
|
|
NOTES="update vscode to [${MS_COMMIT}](https://github.com/microsoft/vscode/tree/${MS_COMMIT})"
|
|
|
|
CREATE_OPTIONS=""
|
|
|
|
else
|
2023-07-20 14:25:13 -04:00
|
|
|
NOTES="update vscode to [${MS_TAG}](https://code.visualstudio.com/updates/v$( echo "${MS_TAG//./_}" | cut -d'_' -f 1,2 ))"
|
2022-10-06 16:15:41 -04:00
|
|
|
CREATE_OPTIONS="--generate-notes"
|
|
|
|
fi
|
|
|
|
|
2022-11-19 18:42:22 -05:00
|
|
|
gh release create "${RELEASE_VERSION}" --repo "${ASSETS_REPOSITORY}" --title "${RELEASE_VERSION}" --notes "${NOTES}" ${CREATE_OPTIONS}
|
2021-10-01 12:47:10 -04:00
|
|
|
fi
|
|
|
|
|
2022-10-06 16:15:41 -04:00
|
|
|
cd assets
|
2021-10-01 12:47:10 -04:00
|
|
|
|
2021-11-06 07:26:36 -04:00
|
|
|
set +e
|
|
|
|
|
2023-07-23 12:35:27 -04:00
|
|
|
for FILE in *; do
|
2021-10-01 12:47:10 -04:00
|
|
|
if [[ -f "${FILE}" ]] && [[ "${FILE}" != *.sha1 ]] && [[ "${FILE}" != *.sha256 ]]; then
|
2021-11-11 20:14:13 -05:00
|
|
|
echo "::group::Uploading '${FILE}' at $( date "+%T" )"
|
2022-10-06 16:15:41 -04:00
|
|
|
gh release upload --repo "${ASSETS_REPOSITORY}" "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
|
2021-11-06 07:03:44 -04:00
|
|
|
|
2021-11-10 05:52:44 -05:00
|
|
|
EXIT_STATUS=$?
|
2022-06-05 15:30:23 -04:00
|
|
|
echo "exit: ${EXIT_STATUS}"
|
2021-11-10 05:52:44 -05:00
|
|
|
|
2022-06-05 15:30:23 -04:00
|
|
|
if (( "${EXIT_STATUS}" )); then
|
2023-07-23 12:35:27 -04:00
|
|
|
for (( i=0; i<10; i++ )); do
|
2022-10-06 16:15:41 -04:00
|
|
|
github-release delete --owner "${REPOSITORY_OWNER}" --repo "${REPOSITORY_NAME}" --tag "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
|
2021-11-10 04:13:12 -05:00
|
|
|
|
2021-11-06 07:58:53 -04:00
|
|
|
sleep $(( 15 * (i + 1)))
|
|
|
|
|
2021-11-10 04:13:12 -05:00
|
|
|
echo "RE-Uploading '${FILE}' at $( date "+%T" )"
|
2022-10-06 16:15:41 -04:00
|
|
|
gh release upload --repo "${ASSETS_REPOSITORY}" "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
|
2021-11-10 04:40:20 -05:00
|
|
|
|
|
|
|
EXIT_STATUS=$?
|
2022-06-05 15:30:23 -04:00
|
|
|
echo "exit: ${EXIT_STATUS}"
|
2021-11-06 07:03:44 -04:00
|
|
|
|
2022-06-05 15:30:23 -04:00
|
|
|
if ! (( "${EXIT_STATUS}" )); then
|
2021-11-06 07:03:44 -04:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2022-06-05 15:30:23 -04:00
|
|
|
echo "exit: ${EXIT_STATUS}"
|
2021-11-06 07:58:53 -04:00
|
|
|
|
2022-06-05 15:30:23 -04:00
|
|
|
if (( "${EXIT_STATUS}" )); then
|
2021-11-06 07:58:53 -04:00
|
|
|
echo "'${FILE}' hasn't been uploaded!"
|
2021-11-10 04:13:12 -05:00
|
|
|
|
2022-10-06 16:15:41 -04:00
|
|
|
github-release delete --owner "${REPOSITORY_OWNER}" --repo "${REPOSITORY_NAME}" --tag "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
|
2021-11-10 04:13:12 -05:00
|
|
|
|
2021-11-06 07:58:53 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-11-06 07:03:44 -04:00
|
|
|
fi
|
2021-11-11 20:14:13 -05:00
|
|
|
|
|
|
|
echo "::endgroup::"
|
2021-10-01 12:47:10 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
cd ..
|