mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
chore: add OTA workflow
This commit is contained in:
38
.github/workflows/release-ota.yml
vendored
Normal file
38
.github/workflows/release-ota.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
name: release-ota
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
limit:
|
||||
description: 'Number of releases to fetch, 2 at least'
|
||||
required: false
|
||||
default: 21
|
||||
type: number
|
||||
|
||||
jobs:
|
||||
make-ota:
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: "Build OTA"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
mkdir -pv build-ota && cd build-ota
|
||||
../tools/OTAPacker/build.sh 'MaaAssistantArknights/MaaAssistantArknights' ${{ inputs.limit }}
|
||||
- name: "Set tag"
|
||||
id: set_tag
|
||||
run: |
|
||||
echo "release_tag=$(head -n 1 build-ota/releases)" >> $GITHUB_ENV
|
||||
- name: "Upload to MaaRelease"
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_name: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
|
||||
repo_token: ${{ secrets.MAARELEASE_RELEASE }}
|
||||
file_glob: true
|
||||
file: build-ota/*.zip
|
||||
tag: ${{ env.release_tag }}
|
||||
overwrite: true
|
||||
|
||||
56
tools/OTAPacker/build.sh
Executable file
56
tools/OTAPacker/build.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/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
|
||||
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
|
||||
|
||||
while read file; do
|
||||
if [[ $file == "deleting "* ]]; then
|
||||
echo ${file#"deleting "} >> "$tag"/pkg/deleted.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"/"${tag}_${latest_tag}.zip" .
|
||||
cd $working_dir
|
||||
fi
|
||||
done < ./releases
|
||||
|
||||
Reference in New Issue
Block a user