Update utils.sh

This commit is contained in:
Fioren
2023-11-07 00:23:52 +07:00
committed by GitHub
parent 06e50590ca
commit 040a520f02

View File

@@ -4,34 +4,6 @@ mkdir ./release
#################################################
# Check new patch:
get_date() {
local assets asset name updated_at
assets=$(curl -s https://api.github.com/repos/"$1"/releases/latest | jq '.assets')
for asset in $(echo "$assets" | jq -r '.[] | @base64'); do
asset=$(echo "$asset" | base64 --decode)
name=$(echo "$asset" | jq -r '.name')
updated_at=$(echo "$asset" | jq -r '.updated_at')
[[ $name =~ "$2" ]] && echo "$updated_at"
done
}
checker(){
local date1 date2 date1_sec date1_sec repo=$1 ur_repo=$GITHUB_REPOSITORY check=$2
date1=$(get_date "$repo" "patches.json")
date2=$(get_date "$ur_repo" "$check")
date1_sec=$(date -d "$date1" +%s)
date2_sec=$(date -d "$date2" +%s)
if [ -z "$date2" ] || [ "$date1_sec" -gt "$date2_sec" ]; then
export new_patch=1
echo "New patch, building..."
elif [ "$date1_sec" -lt "$date2_sec" ]; then
export new_patch=0
echo "Old patch, not build."
fi
}
#################################################
# Download Github assets requirement:
dl_gh() {
for repo in $1 ; do
@@ -202,4 +174,4 @@ split_arch() {
fi
}
#################################################
#################################################