批量构建 Magisk 模块 #22
This file contains hidden or 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: 批量构建 Magisk 模块 | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| generate-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - name: 🧾 检出 batch_rom_list.json | |
| uses: actions/checkout@v5.0.0 | |
| with: | |
| sparse-checkout: | | |
| batch_rom_list.json | |
| sparse-checkout-cone-mode: false | |
| - name: 🚀 生成并发矩阵 | |
| id: set-matrix | |
| run: | | |
| jq -c ' | |
| to_entries | |
| | map( | |
| .key as $device | |
| | .value | |
| | map({ | |
| device: $device, | |
| rom: .rom, | |
| }) | |
| ) | |
| | flatten | |
| | {include: .} | |
| ' batch_rom_list.json >matrix.json | |
| echo "matrix=$(cat matrix.json | jq -c .)" >> $GITHUB_OUTPUT | |
| build: | |
| needs: generate-matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
| steps: | |
| - name: 🧾 克隆仓库 | |
| uses: actions/checkout@v5.0.0 | |
| - name: 🛠 安装依赖 | |
| run: | | |
| sudo apt update | |
| sudo apt-get install -y zip unzip | |
| - name: 🚀 执行批量构建 | |
| run: | | |
| url=$(jq -r --arg device "${{ matrix.device }}" --arg rom "${{ matrix.rom }}" ' | |
| .[$device][] | select(.rom == $rom) | .url' batch_rom_list.json) | |
| bash ./build.sh --rom "${{ matrix.rom }}" \ | |
| --url "$url" | |
| - name: 📦 上传构建产物 | |
| uses: actions/upload-artifact@v5.0.0 | |
| with: | |
| name: "${{ matrix.device }}-${{ matrix.rom }}" | |
| path: tmp/release/ | |
| merge-artifacts: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: ⬇️ 下载所有构建产物 | |
| uses: actions/download-artifact@v6.0.0 | |
| with: | |
| path: combined-artifacts | |
| - name: ⏰ 获取当前时间 | |
| id: datetime | |
| run: | | |
| sudo timedatectl set-timezone Asia/Shanghai | |
| echo "datetime=$(date +'%Y-%m-%d-%H-%M')" >> "$GITHUB_OUTPUT" | |
| - name: 📦 处理总构建产物 | |
| run: | | |
| cd combined-artifacts | |
| find . -mindepth 1 -maxdepth 1 -type d | while IFS= read -r dir; do | |
| dirname="${dir#./}" | |
| model="${dirname%%-*}" | |
| version="${dirname#*-}" | |
| if [[ "$model" == "$dirname" || "$version" == "$dirname" ]]; then | |
| continue | |
| fi | |
| mkdir -p "$model" | |
| cd "$dirname" | |
| zip -r "../$model/${version}.zip" . >/dev/null | |
| cd .. | |
| rm -rf "$dirname" | |
| done | |
| - name: 📦 上传总构建产物 | |
| uses: actions/upload-artifact@v5.0.0 | |
| with: | |
| name: batch-build-artifacts-${{ github.run_id }}-${{ steps.datetime.outputs.datetime }} | |
| path: combined-artifacts/ |