ci: correctly check assets [skip ci]

This commit is contained in:
Baptiste Augrain 2024-04-13 02:30:32 +02:00
parent a1f3d6ff6c
commit 07b7cb95cf

View File

@ -9,10 +9,15 @@ if [[ -z "${GITHUB_TOKEN}" ]]; then
fi
APP_NAME_LC="$( echo "${APP_NAME}" | awk '{print tolower($0)}' )"
GITHUB_RESPONSE=$( curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${ASSETS_REPOSITORY}/releases/latest" )
LATEST_VERSION=$( echo "${GITHUB_RESPONSE}" | jq -c -r '.tag_name' )
if [[ "${LATEST_VERSION}" =~ ^([0-9]+\.[0-9]+\.[0-9]+) ]]; then
if [[ "${SHOULD_DEPLOY}" == "no" ]]; then
ASSETS="null"
else
GITHUB_RESPONSE=$( curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${ASSETS_REPOSITORY}/releases/latest" )
LATEST_VERSION=$( echo "${GITHUB_RESPONSE}" | jq -c -r '.tag_name' )
RECHECK_ASSETS="${SHOULD_BUILD}"
if [[ "${LATEST_VERSION}" =~ ^([0-9]+\.[0-9]+\.[0-9]+) ]]; then
if [[ "${MS_TAG}" != "${BASH_REMATCH[1]}" ]]; then
echo "New VSCode version, new build"
export SHOULD_BUILD="yes"
@ -36,10 +41,16 @@ if [[ "${LATEST_VERSION}" =~ ^([0-9]+\.[0-9]+\.[0-9]+) ]]; then
echo "Switch to release version: ${RELEASE_VERSION}"
ASSETS=$( echo "${GITHUB_RESPONSE}" | jq -c '.assets | map(.name)?' )
elif [[ "${RECHECK_ASSETS}" == "yes" ]]; then
ASSETS=$( echo "${GITHUB_RESPONSE}" | jq -c '.assets | map(.name)?' )
else
ASSETS="null"
fi
else
echo "can't check assets"
exit 1
fi
fi
contains() {
@ -47,6 +58,7 @@ contains() {
echo "${ASSETS}" | grep "${1}\""
}
# shellcheck disable=SC2153
if [[ "${CHECK_ASSETS}" == "no" ]]; then
echo "Don't check assets, yet"
elif [[ "${ASSETS}" != "null" ]]; then