Skip to content

Instantly share code, notes, and snippets.

@roelds
Last active September 9, 2023 18:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roelds/b2cd9cc2ba6c7887ddaf6bde2ef7ef50 to your computer and use it in GitHub Desktop.
Save roelds/b2cd9cc2ba6c7887ddaf6bde2ef7ef50 to your computer and use it in GitHub Desktop.
Shell - Get latest release tag name from GitLab or GitHub
# for GitHub:
# use this for name:
VERNAME=$(wget -q -O- https://api.github.com/repos/roelds/litaf/releases/latest | jq -r '.name')
# or this for tag name, if jq installed:
VERTAG=$(wget -q -O- https://api.github.com/repos/roelds/litaf/releases/latest | jq -r '.tag_name')
# or if jq not installed:
curl --silent "https://api.github.com/repos/roelds/litaf/releases/latest" | grep -Po "(?<=\"tag_name\": \").*(?=\")"
# latest release tag name, for GitLab:
curl -s https://gitlab.com/gitlab-org/cli/-/releases/permalink/latest | grep -m1 -Eo "releases/[^/]+\"" | awk 'BEGIN { FS="/" } {print $2}' | rev | cut -c2- | rev
# git clone single release tag:
git clone --single-branch -b v1.1 https://github.com/roelds/litaf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment