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