check_version.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. set -e
  3. if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
  4. echo "It's a PR"
  5. export SHOULD_DEPLOY="no"
  6. elif [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
  7. echo "It's a Push"
  8. export SHOULD_DEPLOY="no"
  9. else
  10. echo "It's a cron"
  11. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  12. REPOSITORY="${GITHUB_REPOSITORY:-"VSCodium/vscodium"}-insiders"
  13. SNAP_NAME="codium-insiders"
  14. else
  15. REPOSITORY="${GITHUB_REPOSITORY:-"VSCodium/vscodium"}"
  16. SNAP_NAME="codium"
  17. fi
  18. sudo snap install --channel stable --classic snapcraft
  19. echo "Architecture: ${ARCHITECTURE}"
  20. SNAP_VERSION=$(snapcraft list-revisions ${SNAP_NAME} | grep -F "stable*" | grep "${ARCHITECTURE}" | tr -s ' ' | cut -d ' ' -f 4)
  21. echo "Snap version: ${SNAP_VERSION}"
  22. wget --quiet "https://api.github.com/repos/${REPOSITORY}/releases" -O gh_latest.json
  23. GH_VERSION=$(jq -r 'sort_by(.tag_name)|last.tag_name' gh_latest.json)
  24. echo "GH version: ${GH_VERSION}"
  25. rm -f gh_latest.json
  26. if [[ "${SNAP_VERSION}" == "${GH_VERSION}" ]]; then
  27. export SHOULD_DEPLOY="no"
  28. else
  29. export SHOULD_DEPLOY="yes"
  30. snap version
  31. snap info "${SNAP_NAME}" | true
  32. fi
  33. fi
  34. if [[ "${GITHUB_ENV}" ]]; then
  35. echo "SHOULD_DEPLOY=${SHOULD_DEPLOY}" >> "${GITHUB_ENV}"
  36. fi