vscodium/stores/snapcraft/check_version.sh

50 lines
1.2 KiB
Bash
Raw Normal View History

2021-12-17 17:21:31 -05:00
#!/bin/bash
set -e
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
echo "It's a PR"
export SHOULD_DEPLOY="no"
elif [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
echo "It's a Push"
export SHOULD_DEPLOY="no"
else
echo "It's a cron"
2022-08-29 09:13:25 -04:00
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
REPOSITORY="${GITHUB_REPOSITORY:-"VSCodium/vscodium"}-insiders"
SNAP_NAME="codium-insiders"
else
REPOSITORY="${GITHUB_REPOSITORY:-"VSCodium/vscodium"}"
SNAP_NAME="codium"
fi
sudo snap install --channel stable --classic snapcraft
echo "Architecture: ${ARCHITECTURE}"
SNAP_VERSION=$(snapcraft list-revisions ${SNAP_NAME} 2>&1 | grep -F "stable*" | grep "${ARCHITECTURE}" | tr -s ' ' | cut -d ' ' -f 4)
2021-12-17 17:21:31 -05:00
echo "Snap version: ${SNAP_VERSION}"
2022-08-29 09:13:25 -04:00
wget --quiet "https://api.github.com/repos/${REPOSITORY}/releases" -O gh_latest.json
2021-12-17 17:21:31 -05:00
GH_VERSION=$(jq -r 'sort_by(.tag_name)|last.tag_name' gh_latest.json)
echo "GH version: ${GH_VERSION}"
rm -f gh_latest.json
2021-12-17 17:21:31 -05:00
if [[ "${SNAP_VERSION}" == "${GH_VERSION}" ]]; then
export SHOULD_DEPLOY="no"
else
export SHOULD_DEPLOY="yes"
2022-03-04 09:08:21 -05:00
snap version
2022-08-29 09:13:25 -04:00
snap info "${SNAP_NAME}"
2021-12-17 17:21:31 -05:00
fi
fi
if [[ "${GITHUB_ENV}" ]]; then
echo "SHOULD_DEPLOY=${SHOULD_DEPLOY}" >> "${GITHUB_ENV}"
2021-12-17 17:21:31 -05:00
fi