Last active
November 15, 2022 19:22
-
-
Save sumanmaity112/600ce8bffe1e504857ca37ba4acc4f24 to your computer and use it in GitHub Desktop.
Get latest tag (sort by semver/refname) on git repository filtered by optional prefix
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 | |
set -euo pipefail | |
# git version 2.38.1 | |
_get_latest_tag(){ | |
local prefix="${1:-}" | |
git tag -i -l "${prefix}*" --sort -v:refname | head -n1 | |
} | |
_get_latest_tag "$@" | |
# ./get-latest-tag-on-git.sh "v" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment