-
Notifications
You must be signed in to change notification settings - Fork 17
/
version-checker.sh
executable file
·79 lines (61 loc) · 1.66 KB
/
version-checker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
template_dir="srcpkgs"
log() {
local RED='\033[0;31m'
local GREEN='\033[0;32m'
local YELLOW='\033[0;33m'
local BLUE='\033[0;34m'
local NC='\033[0m'
case "$1" in
success)
echo -e "${GREEN}$2${NC}"
;;
info)
echo -e "${BLUE}$2${NC}"
;;
warning)
echo -e "${YELLOW}$2${NC}"
;;
error)
echo -e "${RED}$2${NC}"
;;
*)
echo "$2"
;;
esac
}
fetch_version() {
repo=$1
# latest_tag=$(curl -s "https://api.github.com/repos/hyprwm/$repo/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
latest_tag=$(curl -s "https://github.com/hyprwm/$repo/releases" | grep -Po 'href="[^"]*/releases/tag/\K[^"]+' | head -n 1)
echo $latest_tag
}
main() {
command -v curl >/dev/null || {
log error "Curl not found, please install. Exiting..." >&2
exit 1
}
for package_dir in "$template_dir"/aquamarine/ "$template_dir"/hypr*/ "$template_dir"/xdg-desktop-portal-hyprland/; do
pkgname=$(basename "$package_dir")
if [[ "$pkgname" == "hyprland-devel" ]]; then
continue
fi
template_file="${package_dir}template"
if [[ ! -f "$template_file" ]]; then
echo "Template file not found for $pkgname"
continue
fi
current_version="v$(grep -Po '^version=\K[0-9.]+(?=$)' "$template_file")"
latest_version=$(fetch_version "$pkgname")
echo "$pkgname ===> $current_version"
if [[ -z "$latest_version" ]]; then
log error "$pkgname ===> Failed to fetch the latest version from GitHub\n"
continue
elif [[ "$current_version" == "$latest_version" ]]; then
log success "${GREEN}$pkgname is up-to-date (Version: $current_version)\n"
else
log info "$pkgname: $current_version, but latest version is $latest_version\n"
fi
done
}
main