mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 18:01:26 +08:00
63 lines
1.6 KiB
Bash
Executable File
63 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
source_repo=$1
|
|
limit=${2:-6}
|
|
|
|
ghrepo() {
|
|
gh $@ --repo $source_repo
|
|
}
|
|
|
|
working_dir=$(pwd)
|
|
echo "working_dir: $working_dir"
|
|
|
|
echo "fetching $limit release info from $source_repo"
|
|
ghrepo release list --limit=$limit | awk '{ print $1 }' | tee releases
|
|
|
|
latest_tag=$(head -n 1 ./releases)
|
|
|
|
while read tag; do
|
|
(
|
|
mkdir -pv "$tag"
|
|
cd "$tag"
|
|
echo "Downloading $tag"
|
|
ghrepo release download "$tag" --pattern "MAA-$tag-win-x64.zip" --pattern "MaaBundle-$tag.zip" --clobber
|
|
mkdir -pv 'content'
|
|
echo "Unzip" *.zip
|
|
unzip -qq -O gbk -o "*.zip" -d 'content'
|
|
rm -fv *.zip
|
|
)
|
|
|
|
cd $working_dir
|
|
|
|
if [[ "$tag" == "$latest_tag" ]]; then
|
|
cd "$latest_tag"/content/
|
|
find * -type f -exec md5sum '{}' \; > ../md5sum.txt
|
|
cd $working_dir
|
|
else
|
|
echo "Comparing files $tag...$latest_tag"
|
|
rsync -ancv --delete --info=FLIST0 "$latest_tag"/content/ "$tag"/content/ \
|
|
| grep -v '/$' \
|
|
| head -n -3 \
|
|
| tee "$tag"/files.txt
|
|
|
|
echo "Installing files"
|
|
mkdir -pv "$tag"/pkg
|
|
|
|
install -DCv "$latest_tag"/md5sum.txt "$tag"/pkg
|
|
|
|
while read file; do
|
|
if [[ $file == "deleting "* ]]; then
|
|
echo ${file#"deleting "} >> "$tag"/pkg/removelist.txt
|
|
else
|
|
install -DCv "$latest_tag"/content/"$file" "$tag"/pkg/"$file"
|
|
fi
|
|
done < "$tag"/files.txt
|
|
|
|
echo "Creating zip archive"
|
|
cd "$tag"/pkg
|
|
zip -q -9 -r "$working_dir"/"MAAComponent-OTA-${tag}_${latest_tag}-win-x64.zip" .
|
|
cd $working_dir
|
|
fi
|
|
done < ./releases
|
|
|