refactor: passing linter for root bash scripts (#1569)

This commit is contained in:
Zac
2023-07-20 13:25:13 -05:00
committed by GitHub
parent d6b7880a05
commit b4318d78a0
16 changed files with 96 additions and 73 deletions

View File

@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC2129
set -e
@@ -12,28 +13,28 @@ if [[ -z "${RELEASE_VERSION}" ]]; then
if [[ "${VSCODE_LATEST}" == "yes" ]] || [[ ! -f "insider.json" ]]; then
UPDATE_INFO=$( curl --silent --fail https://update.code.visualstudio.com/api/update/darwin/insider/0000000000000000000000000000000000000000 )
else
export MS_COMMIT=$(jq -r '.commit' insider.json)
export MS_TAG=$(jq -r '.tag' insider.json)
MS_COMMIT=$( jq -r '.commit' insider.json )
MS_TAG=$( jq -r '.tag' insider.json )
fi
else
UPDATE_INFO=$( curl --silent --fail https://update.code.visualstudio.com/api/update/darwin/stable/0000000000000000000000000000000000000000 )
fi
if [[ -z "${MS_COMMIT}" ]]; then
export MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
export MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
export MS_TAG="${MS_TAG/\-insider/}"
MS_TAG="${MS_TAG/\-insider/}"
fi
fi
date=$( date +%Y%j )
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
export RELEASE_VERSION="${MS_TAG}.${date: -5}-insider"
RELEASE_VERSION="${MS_TAG}.${date: -5}-insider"
else
export RELEASE_VERSION="${MS_TAG}.${date: -5}"
RELEASE_VERSION="${MS_TAG}.${date: -5}"
fi
else
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
@@ -45,8 +46,8 @@ else
exit 1
fi
if [[ "${MS_TAG}" == "$(jq -r '.tag' insider.json)" ]]; then
export MS_COMMIT=$(jq -r '.commit' insider.json)
if [[ "${MS_TAG}" == "$( jq -r '.tag' insider.json )" ]]; then
MS_COMMIT=$( jq -r '.commit' insider.json )
else
echo "Error: No MS_COMMIT for ${RELEASE_VERSION}"
exit 1
@@ -77,8 +78,8 @@ if [[ -z "${MS_TAG}" ]]; then
else
UPDATE_INFO=$( curl --silent --fail https://update.code.visualstudio.com/api/update/darwin/stable/0000000000000000000000000000000000000000 )
fi
export MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
export MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
MS_COMMIT=$( echo "${UPDATE_INFO}" | jq -r '.version' )
MS_TAG=$( echo "${UPDATE_INFO}" | jq -r '.name' )
elif [[ -z "${MS_COMMIT}" ]]; then
REFERENCE=$( git ls-remote --tags | grep -x ".*refs\/tags\/${MS_TAG}" | head -1 )
@@ -86,8 +87,8 @@ elif [[ -z "${MS_COMMIT}" ]]; then
echo "Error: The following tag can't be found: ${MS_TAG}"
exit 1
elif [[ "${REFERENCE}" =~ ^([[:alnum:]]+)[[:space:]]+refs\/tags\/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
export MS_COMMIT="${BASH_REMATCH[1]}"
export MS_TAG="${BASH_REMATCH[2]}"
MS_COMMIT="${BASH_REMATCH[1]}"
MS_TAG="${BASH_REMATCH[2]}"
else
echo "Error: The following reference can't be parsed: ${REFERENCE}"
exit 1
@@ -108,3 +109,7 @@ if [[ "${GITHUB_ENV}" ]]; then
echo "MS_COMMIT=${MS_COMMIT}" >> "${GITHUB_ENV}"
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_ENV}"
fi
export MS_TAG
export MS_COMMIT
export RELEASE_VERSION