Last active
June 8, 2020 17:21
-
-
Save eliashaeussler/644177b99f9d1340bb994dffa595c291 to your computer and use it in GitHub Desktop.
GitLab Omnibus version check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## Requirements: | |
## * jq: https://stedolan.github.io/jq/ | |
## * GitLab auth token: https://gitlab.example.com/profile/personal_access_tokens | |
GITLAB_DOMAIN="https://gitlab.example.com" | |
AUTH_TOKEN="<insert GitLab auth token here>" | |
CURRENT_VERSION="$(curl -s -H "Authorization: Bearer ${AUTH_TOKEN}" "${GITLAB_DOMAIN}/api/v4/version" | jq -r '.version')" | |
STABLE_VERSION="$(curl -s https://gitlab.com/api/v4/projects/13083/repository/tags | jq -r '[ .[] | .name | match("^v?(\\d+\\.\\d+\\.\\d+)$") | .captures[0].string ] | sort_by(split(".") | map(tonumber))[-1]')" | |
if [ "${CURRENT_VERSION}" != "${STABLE_VERSION}" ]; then | |
>&2 echo "A new GitLab version is available: ${STABLE_VERSION}" | |
>&2 echo "Current version: ${CURRENT_VERSION}" | |
exit 1; | |
fi | |
echo "No GitLab update available." | |
echo "Current version: ${CURRENT_VERSION}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment