-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
release.sh
executable file
·82 lines (57 loc) · 2.66 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
# shellcheck disable=SC1091
set -ex
if [[ -z "${GH_TOKEN}" ]] && [[ -z "${GITHUB_TOKEN}" ]] && [[ -z "${GH_ENTERPRISE_TOKEN}" ]] && [[ -z "${GITHUB_ENTERPRISE_TOKEN}" ]]; then
echo "Will not release because no GITHUB_TOKEN defined"
exit
fi
REPOSITORY_OWNER="${ASSETS_REPOSITORY/\/*/}"
REPOSITORY_NAME="${ASSETS_REPOSITORY/*\//}"
npm install -g github-release-cli
if [[ $( gh release view --repo "${ASSETS_REPOSITORY}" "${RELEASE_VERSION}" 2>&1 ) =~ "release not found" ]]; then
echo "Creating release '${RELEASE_VERSION}'"
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
NOTES="update vscode to [${MS_COMMIT}](https://github.com/microsoft/vscode/tree/${MS_COMMIT})"
gh release create "${RELEASE_VERSION}" --repo "${ASSETS_REPOSITORY}" --title "${RELEASE_VERSION}" --notes "${NOTES}"
else
gh release create "${RELEASE_VERSION}" --repo "${ASSETS_REPOSITORY}" --title "${RELEASE_VERSION}" --generate-notes
. ./utils.sh
RELEASE_NOTES=$( gh release view "${RELEASE_VERSION}" --json "body" --jq ".body" )
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}|g" release_notes.txt
replace "s|RELEASE_NOTES|${RELEASE_NOTES//$'\n'/\\n}|" release_notes.txt
gh release edit "${RELEASE_VERSION}" --notes-file release_notes.txt
fi
fi
cd assets
set +e
for FILE in *; do
if [[ -f "${FILE}" ]] && [[ "${FILE}" != *.sha1 ]] && [[ "${FILE}" != *.sha256 ]]; then
echo "::group::Uploading '${FILE}' at $( date "+%T" )"
gh release upload --repo "${ASSETS_REPOSITORY}" "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
EXIT_STATUS=$?
echo "exit: ${EXIT_STATUS}"
if (( "${EXIT_STATUS}" )); then
for (( i=0; i<10; i++ )); do
github-release delete --owner "${REPOSITORY_OWNER}" --repo "${REPOSITORY_NAME}" --tag "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
sleep $(( 15 * (i + 1)))
echo "RE-Uploading '${FILE}' at $( date "+%T" )"
gh release upload --repo "${ASSETS_REPOSITORY}" "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
EXIT_STATUS=$?
echo "exit: ${EXIT_STATUS}"
if ! (( "${EXIT_STATUS}" )); then
break
fi
done
echo "exit: ${EXIT_STATUS}"
if (( "${EXIT_STATUS}" )); then
echo "'${FILE}' hasn't been uploaded!"
github-release delete --owner "${REPOSITORY_OWNER}" --repo "${REPOSITORY_NAME}" --tag "${RELEASE_VERSION}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256"
exit 1
fi
fi
echo "::endgroup::"
fi
done
cd ..