get_files #93
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
name: get_files | |
on: | |
workflow_dispatch: | |
inputs: | |
URL: | |
description: "待操作的系统包下载地址" | |
required: true | |
info: | |
description: "提取文件信息" | |
required: true | |
type: string | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- name: 准备环境 | |
run: | | |
echo "date=$(echo "${{ github.event.inputs.URL }}" | cut -d"/" -f4)" >> $GITHUB_ENV | |
device1=$(echo "${{ github.event.inputs.URL }}" | cut -d"_" -f2) | |
echo "device=$(echo ${device1,,})" >> $GITHUB_ENV | |
sudo apt install aria2 p7zip-full | |
mkdir -p "$GITHUB_WORKSPACE"/get_files | |
sudo chmod -R 777 "$GITHUB_WORKSPACE"/tools | |
- name: 下载系统包 | |
run: | | |
aria2c -x16 -j$(nproc) -U "Mozilla/5.0" -d "$GITHUB_WORKSPACE" "${{ github.event.inputs.URL }}" | |
- name: 检测payload/br | |
run: | | |
ZIP_NAME=$(echo "${{ github.event.inputs.URL }}" | sed 's/.*\(miui_.*\.zip\).*/\1/') | |
7z x "$GITHUB_WORKSPACE"/$ZIP_NAME -r -o"$GITHUB_WORKSPACE"/$device && rm -rf "$GITHUB_WORKSPACE"/$ZIP_NAME | |
if [[ -e "$GITHUB_WORKSPACE"/$device/payload.bin ]]; then | |
echo "unpack=payload" >> $GITHUB_ENV | |
else | |
echo "unpack=br" >> $GITHUB_ENV | |
fi | |
- if: ${{ env.unpack == 'payload' }} | |
name: 解压payload | |
run: | | |
# unpack_partiton="product" | |
unpack_partiton="system odm system_ext product vendor mi_ext system_dlkm vendor_dlkm" | |
for i in $unpack_partiton; do | |
"$GITHUB_WORKSPACE"/tools/payload-dumper-go -o "$GITHUB_WORKSPACE"/$device/ -p $i "$GITHUB_WORKSPACE"/$device/payload.bin > /dev/null | |
if [[ $("$GITHUB_WORKSPACE"/tools/gettype -i "$GITHUB_WORKSPACE"/$device/$i.img) == "ext" ]]; then | |
sudo "$GITHUB_WORKSPACE"/tools/imgextractorLinux "$GITHUB_WORKSPACE"/$device/$i.img "$GITHUB_WORKSPACE"/$device > /dev/null | |
elif [[ $("$GITHUB_WORKSPACE"/tools/gettype -i "$GITHUB_WORKSPACE"/$device/$i.img) == "erofs" ]]; then | |
cd "$GITHUB_WORKSPACE"/$device && "$GITHUB_WORKSPACE"/tools/extract.erofs -i "$GITHUB_WORKSPACE"/$device/$i.img -x > /dev/null && cd "$GITHUB_WORKSPACE" | |
fi | |
rm -rf "$GITHUB_WORKSPACE"/$device/$i.img | |
done | |
sudo rm -rf "$GITHUB_WORKSPACE"/$device/TI_config "$GITHUB_WORKSPACE"/$device/payload.bin | |
- if: ${{ env.unpack == 'br' }} | |
name: 解压br | |
run: | | |
unpack_partiton="product" | |
# unpack_partiton="system odm system_ext product vendor mi_ext system_dlkm vendor_dlkm" | |
for i in $unpack_partiton; do | |
"$GITHUB_WORKSPACE"/tools/brotli -d "$GITHUB_WORKSPACE"/$device/$i.new.dat.br > /dev/null | |
rm -rf "$GITHUB_WORKSPACE"/$device/$i.new.dat.br | |
"$GITHUB_WORKSPACE"/tools/sdat2img "$GITHUB_WORKSPACE"/$device/$i.transfer.list "$GITHUB_WORKSPACE"/$device/$i.new.dat "$GITHUB_WORKSPACE"/$device/$i.img > /dev/null | |
rm -rf "$GITHUB_WORKSPACE"/$device/$i.patch.dat "$GITHUB_WORKSPACE"/$device/$i.transfer.list "$GITHUB_WORKSPACE"/$device/$i.new.dat | |
if [[ $("$GITHUB_WORKSPACE"/tools/gettype -i "$GITHUB_WORKSPACE"/$device/$i.img) == "ext" ]]; then | |
sudo python3 "$GITHUB_WORKSPACE"/tools/imgextractorLinux/imgextractorLinux.py "$GITHUB_WORKSPACE"/$device/$i.img "$GITHUB_WORKSPACE"/$device > /dev/null | |
elif [[ $("$GITHUB_WORKSPACE"/tools/gettype -i "$GITHUB_WORKSPACE"/$device/$i.img) == "erofs" ]]; then | |
cd "$GITHUB_WORKSPACE"/$device && "$GITHUB_WORKSPACE"/tools/extract.erofs -i "$GITHUB_WORKSPACE"/$device/$i.img -x > /dev/null && cd "$GITHUB_WORKSPACE" | |
fi | |
rm -rf "$GITHUB_WORKSPACE"/$device/$i.img | |
done | |
sudo rm -rf "$GITHUB_WORKSPACE"/$device/config | |
- name: 提取指定文件 | |
run: | | |
mkdir -p "$GITHUB_WORKSPACE"/get_files | |
get_prop_files(){ | |
# mi_ext_build_prop=$(sudo find "$GITHUB_WORKSPACE"/"$device"/mi_ext -name "build.prop") | |
# sudo cp -f "$GITHUB_WORKSPACE"/"$device"/system/system/build.prop "$GITHUB_WORKSPACE"/get_files/system | |
# sudo cp -f "$GITHUB_WORKSPACE"/"$device"/vendor/build.prop "$GITHUB_WORKSPACE"/get_files/vendor | |
# sudo cp -f "$GITHUB_WORKSPACE"/"$device"/system_ext/etc/build.prop "$GITHUB_WORKSPACE"/get_files/system_ext | |
# sudo cp -f "$GITHUB_WORKSPACE"/"$device"/odm/etc/build.prop "$GITHUB_WORKSPACE"/get_files/odm | |
sudo cp -f "$GITHUB_WORKSPACE"/"$device"/product/etc/build.prop "$GITHUB_WORKSPACE"/get_files/product | |
sudo 7z a "$GITHUB_WORKSPACE"/get_files/devicefeatures.zip "$GITHUB_WORKSPACE"/"$device"/product/etc/device_features/* | |
sudo 7z a "$GITHUB_WORKSPACE"/get_files/overlay.zip "$GITHUB_WORKSPACE"/"$device"/product/overlay/* | |
sudo 7z a "$GITHUB_WORKSPACE"/get_files/MiuiCamera.zip "$GITHUB_WORKSPACE"/"$device"/product/priv-app/MiuiCamera/* | |
# sudo cp -f "$mi_ext_build_prop" "$GITHUB_WORKSPACE"/get_files/mi_ext | |
} | |
get_files_config(){ | |
if [ -d "$GITHUB_WORKSPACE"/$device/config ]; then | |
sudo 7z a "$GITHUB_WORKSPACE"/get_files/context.zip "$GITHUB_WORKSPACE"/$device/config/* | |
else | |
sudo 7z a "$GITHUB_WORKSPACE"/get_files/context.zip "$GITHUB_WORKSPACE"/$device/TI_config/* | |
fi | |
} | |
# mkdir -p "$GITHUB_WORKSPACE"/get_files/system | |
# mkdir -p "$GITHUB_WORKSPACE"/get_files/vendor | |
# mkdir -p "$GITHUB_WORKSPACE"/get_files/system_ext | |
# mkdir -p "$GITHUB_WORKSPACE"/get_files/product | |
# mkdir -p "$GITHUB_WORKSPACE"/get_files/odm | |
# mkdir -p "$GITHUB_WORKSPACE"/get_files/mi_ext | |
get_prop_files | |
get_files_config | |
- name: 打包 | |
run: | | |
timestamp=$(date +%s) | |
echo "timestamp=$timestamp" >> $GITHUB_ENV | |
mkdir -p "$GITHUB_WORKSPACE"/zip | |
sudo chmod -R 777 "$GITHUB_WORKSPACE"/get_files | |
7z a "$GITHUB_WORKSPACE"/zip/"$device"_get_files.zip "$GITHUB_WORKSPACE"/get_files/* | |
mv "$GITHUB_WORKSPACE"/zip/"$device"_get_files.zip "$GITHUB_WORKSPACE"/zip/"$device"_"$date"_"$timestamp".zip | |
cd "$GITHUB_WORKSPACE" | |
touch file.log | |
echo "${{ github.event.inputs.info }}" > file.log | |
- name: 上传到Github Release | |
uses: ncipollo/release-action@main | |
with: | |
artifacts: ${{ github.workspace }}/zip/* | |
name: ${{ env.device }} | |
tag: ${{ env.device }} | |
bodyFile: "${{ github.workspace }}/file.log" | |
allowUpdates: true | |
artifactErrorsFailBuild: true | |
token: ${{ secrets.GITHUB_TOKEN }} |