My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/pkgs/common-updater/scripts/list-git-tags

53 lines
1.2 KiB

#!/usr/bin/env bash
# lists all available tags from a git repository
echo "# pname=$UPDATE_NIX_ATTR_PATH" > /tmp/test.txt
url="" # git repository url
pname="" # package name
file="" # file for writing debugging information
while (( $# > 0 )); do
flag="$1"
shift 1
case "$flag" in
--url=*)
url="${flag#*=}"
;;
--pname=*)
pname="${flag#*=}"
;;
--file=*)
file="${flag#*=}"
;;
*)
echo "$0: unknown option ‘${flag}"
exit 1
;;
esac
done
# By default we set url to src.url or src.meta.homepage
if [[ -z "$url" ]]; then
url="$(nix-instantiate $systemArg --eval -E \
"with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.meta.homepage or $UPDATE_NIX_ATTR_PATH.src.url" \
| tr -d '"')"
fi
if [[ -z "$pname" ]]; then
pname="$UPDATE_NIX_ATTR_PATH"
fi
# print a debugging message
if [[ -n "$file" ]]; then
echo "# Listing tags for '$pname' at $url" >> $file
fi
# list all tags from the remote repository
tags=$(git ls-remote --tags --refs "$url")
# keep only the version part of the tag
tags=$(echo "$tags" | cut --delimiter=/ --field=3)
echo "$tags"