2021-10-01 19:47:10 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2021-11-10 12:13:12 +03:00
|
|
|
if [[ -z "${GITHUB_TOKEN}" ]]; then
|
|
|
|
echo "Will not release because no GITHUB_TOKEN defined"
|
2021-10-01 19:47:10 +03:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2022-08-29 16:13:25 +03:00
|
|
|
OWNER="${GITHUB_REPOSITORY_OWNER:-"VSCodium"}"
|
|
|
|
REPO_NAME="${GITHUB_REPOSITORY:(${#OWNER}+1)}"
|
|
|
|
|
|
|
|
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
|
|
|
|
REPOSITORY="${REPO_NAME:-"vscodium"}-insiders"
|
2022-09-02 08:58:40 +03:00
|
|
|
NOTES="update vscode to [${MS_COMMIT}](https://github.com/microsoft/vscode/tree/${MS_COMMIT})"
|
2022-08-29 16:13:25 +03:00
|
|
|
else
|
|
|
|
REPOSITORY="${REPO_NAME:-"vscodium"}"
|
2022-09-02 08:58:40 +03:00
|
|
|
NOTES="update vscode to [${MS_TAG}](https://code.visualstudio.com/updates/v$( echo ${MS_TAG//./_} | cut -d'_' -f 1,2 ))"
|
2022-08-29 16:13:25 +03:00
|
|
|
fi
|
|
|
|
|
2021-11-10 12:13:12 +03:00
|
|
|
npm install -g github-release-cli
|
2021-10-01 19:47:10 +03:00
|
|
|
|
2022-08-30 14:55:17 +03:00
|
|
|
if [[ $( gh release view --repo "${OWNER}/${REPOSITORY}" "${RELEASE_VERSION}" 2>&1 ) =~ "release not found" ]]; then
|
2022-08-16 14:51:45 +03:00
|
|
|
echo "Creating release '${RELEASE_VERSION}'"
|
2022-09-02 09:21:24 +03:00
|
|
|
gh release create "${RELEASE_VERSION}" --repo "${OWNER}/${REPOSITORY}" --notes "${NOTES}" --generate-notes
|
2021-10-01 19:47:10 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd artifacts
|
|
|
|
|
2021-11-06 14:26:36 +03:00
|
|
|
set +e
|
|
|
|
|
2021-10-01 19:47:10 +03:00
|
|
|
for FILE in *
|
|
|
|
do
|
|
|
|
if [[ -f "${FILE}" ]] && [[ "${FILE}" != *.sha1 ]] && [[ "${FILE}" != *.sha256 ]]; then
|
2021-11-12 04:14:13 +03:00
|
|
|
echo "::group::Uploading '${FILE}' at $( date "+%T" )"
|
2022-08-30 14:55:17 +03:00
|
|
|
gh release upload --repo "${OWNER}/${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
|
2021-11-06 14:58:53 +03:00
|
|
|
for (( i=0; i<10; i++ ))
|
2021-11-06 14:03:44 +03:00
|
|
|
do
|
2022-08-16 14:51:45 +03:00
|
|
|
github-release delete --owner "${OWNER}" --repo "${REPOSITORY}" --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-08-30 14:55:17 +03:00
|
|
|
gh release upload --repo "${OWNER}/${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-08-16 14:51:45 +03:00
|
|
|
github-release delete --owner "${OWNER}" --repo "${REPOSITORY}" --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 ..
|