feat: add Github Enterprise support (#1926)
This commit is contained in:
parent
8c9acad540
commit
0c31a54dea
5 changed files with 22 additions and 9 deletions
|
@ -3,17 +3,22 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [[ -z "${GITHUB_TOKEN}" ]]; then
|
if [[ -z "${GH_TOKEN}" ]] && [[ -z "${GITHUB_TOKEN}" ]] && [[ -z "${GH_ENTERPRISE_TOKEN}" ]] && [[ -z "${GITHUB_ENTERPRISE_TOKEN}" ]]; then
|
||||||
echo "Will not build because no GITHUB_TOKEN defined"
|
echo "Will not build because no GITHUB_TOKEN defined"
|
||||||
exit 0
|
exit 0
|
||||||
|
else
|
||||||
|
GITHUB_TOKEN="${GH_TOKEN:-${GITHUB_TOKEN:-${GH_ENTERPRISE_TOKEN:-${GITHUB_ENTERPRISE_TOKEN}}}}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Support for GitHub Enterprise
|
||||||
|
GH_HOST="${GH_HOST:-github.com}"
|
||||||
|
|
||||||
APP_NAME_LC="$( echo "${APP_NAME}" | awk '{print tolower($0)}' )"
|
APP_NAME_LC="$( echo "${APP_NAME}" | awk '{print tolower($0)}' )"
|
||||||
|
|
||||||
if [[ "${SHOULD_DEPLOY}" == "no" ]]; then
|
if [[ "${SHOULD_DEPLOY}" == "no" ]]; then
|
||||||
ASSETS="null"
|
ASSETS="null"
|
||||||
else
|
else
|
||||||
GITHUB_RESPONSE=$( curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${ASSETS_REPOSITORY}/releases/latest" )
|
GITHUB_RESPONSE=$( curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.${GH_HOST}/repos/${ASSETS_REPOSITORY}/releases/latest" )
|
||||||
LATEST_VERSION=$( echo "${GITHUB_RESPONSE}" | jq -c -r '.tag_name' )
|
LATEST_VERSION=$( echo "${GITHUB_RESPONSE}" | jq -c -r '.tag_name' )
|
||||||
RECHECK_ASSETS="${SHOULD_BUILD}"
|
RECHECK_ASSETS="${SHOULD_BUILD}"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [[ -z "${GITHUB_TOKEN}" ]]; then
|
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"
|
echo "Will not release because no GITHUB_TOKEN defined"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -7,10 +7,13 @@ export SHOULD_BUILD="no"
|
||||||
export SHOULD_DEPLOY_TO_RELEASE="no"
|
export SHOULD_DEPLOY_TO_RELEASE="no"
|
||||||
export SHOULD_DEPLOY_TO_STORE="no"
|
export SHOULD_DEPLOY_TO_STORE="no"
|
||||||
|
|
||||||
|
# Support for GitHub Enterprise
|
||||||
|
GH_HOST="${GH_HOST:-github.com}"
|
||||||
|
|
||||||
if [[ "${GENERATE_ASSETS}" == "true" ]]; then
|
if [[ "${GENERATE_ASSETS}" == "true" ]]; then
|
||||||
export SHOULD_BUILD="yes"
|
export SHOULD_BUILD="yes"
|
||||||
else
|
else
|
||||||
wget --quiet "https://api.github.com/repos/${ASSETS_REPOSITORY}/releases" -O gh_latest.json
|
wget --quiet "https://api.${GH_HOST}/repos/${ASSETS_REPOSITORY}/releases" -O gh_latest.json
|
||||||
SNAP_URL=$( jq -r 'map(select(.tag_name == "'"${RELEASE_VERSION}"'"))|first.assets[].browser_download_url|select(endswith("'"_${ARCHITECTURE}.snap"'"))' gh_latest.json )
|
SNAP_URL=$( jq -r 'map(select(.tag_name == "'"${RELEASE_VERSION}"'"))|first.assets[].browser_download_url|select(endswith("'"_${ARCHITECTURE}.snap"'"))' gh_latest.json )
|
||||||
|
|
||||||
if [[ -z "${SNAP_URL}" ]]; then
|
if [[ -z "${SNAP_URL}" ]]; then
|
||||||
|
|
|
@ -7,7 +7,7 @@ if [[ "${SHOULD_BUILD}" != "yes" ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${GITHUB_TOKEN}" ]]; then
|
if [[ -z "${GH_TOKEN}" ]] && [[ -z "${GITHUB_TOKEN}" ]] && [[ -z "${GH_ENTERPRISE_TOKEN}" ]] && [[ -z "${GITHUB_ENTERPRISE_TOKEN}" ]]; then
|
||||||
echo "Will not update ${VSCODE_QUALITY}.json because no GITHUB_TOKEN defined"
|
echo "Will not update ${VSCODE_QUALITY}.json because no GITHUB_TOKEN defined"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -8,11 +8,16 @@ if [[ "${SHOULD_BUILD}" != "yes" && "${FORCE_UPDATE}" != "true" ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${GITHUB_TOKEN}" ]]; then
|
if [[ -z "${GH_TOKEN}" ]] && [[ -z "${GITHUB_TOKEN}" ]] && [[ -z "${GH_ENTERPRISE_TOKEN}" ]] && [[ -z "${GITHUB_ENTERPRISE_TOKEN}" ]]; then
|
||||||
echo "Will not update version JSON because no GITHUB_TOKEN defined"
|
echo "Will not update version JSON because no GITHUB_TOKEN defined"
|
||||||
exit 0
|
exit 0
|
||||||
|
else
|
||||||
|
GITHUB_TOKEN="${GH_TOKEN:-${GITHUB_TOKEN:-${GH_ENTERPRISE_TOKEN:-${GITHUB_ENTERPRISE_TOKEN}}}}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Support for GitHub Enterprise
|
||||||
|
GH_HOST="${GH_HOST:-github.com}"
|
||||||
|
|
||||||
if [[ "${FORCE_UPDATE}" == "true" ]]; then
|
if [[ "${FORCE_UPDATE}" == "true" ]]; then
|
||||||
. version.sh
|
. version.sh
|
||||||
fi
|
fi
|
||||||
|
@ -47,7 +52,7 @@ fi
|
||||||
# `sha256hash` in <filename>.sha256
|
# `sha256hash` in <filename>.sha256
|
||||||
|
|
||||||
REPOSITORY_NAME="${VERSIONS_REPOSITORY/*\//}"
|
REPOSITORY_NAME="${VERSIONS_REPOSITORY/*\//}"
|
||||||
URL_BASE="https://github.com/${ASSETS_REPOSITORY}/releases/download/${RELEASE_VERSION}"
|
URL_BASE="https://${GH_HOST}/${ASSETS_REPOSITORY}/releases/download/${RELEASE_VERSION}"
|
||||||
|
|
||||||
generateJson() {
|
generateJson() {
|
||||||
local url name version productVersion sha1hash sha256hash timestamp
|
local url name version productVersion sha1hash sha256hash timestamp
|
||||||
|
@ -115,12 +120,12 @@ updateLatestVersion() {
|
||||||
|
|
||||||
# init versions repo for later commiting + pushing the json file to it
|
# init versions repo for later commiting + pushing the json file to it
|
||||||
# thank you https://www.vinaygopinath.me/blog/tech/commit-to-master-branch-on-github-using-travis-ci/
|
# thank you https://www.vinaygopinath.me/blog/tech/commit-to-master-branch-on-github-using-travis-ci/
|
||||||
git clone "https://github.com/${VERSIONS_REPOSITORY}.git"
|
git clone "https://${GH_HOST}/${VERSIONS_REPOSITORY}.git"
|
||||||
cd "${REPOSITORY_NAME}" || { echo "'${REPOSITORY_NAME}' dir not found"; exit 1; }
|
cd "${REPOSITORY_NAME}" || { echo "'${REPOSITORY_NAME}' dir not found"; exit 1; }
|
||||||
git config user.email "$( echo "${GITHUB_USERNAME}" | awk '{print tolower($0)}' )-ci@not-real.com"
|
git config user.email "$( echo "${GITHUB_USERNAME}" | awk '{print tolower($0)}' )-ci@not-real.com"
|
||||||
git config user.name "${GITHUB_USERNAME} CI"
|
git config user.name "${GITHUB_USERNAME} CI"
|
||||||
git remote rm origin
|
git remote rm origin
|
||||||
git remote add origin "https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${VERSIONS_REPOSITORY}.git" &> /dev/null
|
git remote add origin "https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@${GH_HOST}/${VERSIONS_REPOSITORY}.git" &> /dev/null
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
if [[ "${OS_NAME}" == "osx" ]]; then
|
if [[ "${OS_NAME}" == "osx" ]]; then
|
||||||
|
|
Loading…
Reference in a new issue