-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Packages version checker (#82) [skip ci]
* feat: packages version checker * fix: check aquamarine package
- Loading branch information
1 parent
c3776b5
commit b20dcbd
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |