Skip to content

Commit

Permalink
🚧 CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kitUIN committed Dec 4, 2024
1 parent a049cc1 commit a1ac7d6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test_fabric.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:
jobs:

generate-matrix:
runs-on: windows-latest
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
Expand All @@ -23,7 +23,7 @@ jobs:
id: set-matrix
shell: pwsh
run: |
.\matrix.ps1 -path "fabric"
.\matrix.sh -path "fabric"
test:
runs-on: windows-latest
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Init Files
shell: pwsh
run: |
./init.ps1
./init.sh
- name: Build
run: |
cd ${{ matrix.config.mc-loader }}/${{ matrix.config.mc-loader }}-${{ matrix.config.mc-version }}
Expand Down
9 changes: 9 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

file=$(find tool -name "ModMultiVersionTool*.jar" | head -n 1)

if [ -n "$file" ]; then
java -jar "$file"
else
echo "can't find ModMultiVersionTool.jar"
fi
32 changes: 32 additions & 0 deletions matrix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# 获取传入的路径参数
paths=("$@")

# 初始化一个空数组,用于存储所有文件夹对象
all_folder_objects=()

# 遍历每个路径
for path in "${paths[@]}"; do
# 查找目录,排除 "origin" 文件夹
folders=$(find "$path" -mindepth 1 -maxdepth 1 -type d ! -name "origin")

# 遍历每个文件夹,生成相应的 JSON 对象
for folder in $folders; do
mc_version=$(basename "$folder" | sed "s/^$path-//")
mc_loader="$path"

folder_object=$(jq -n \
--arg mc_version "$mc_version" \
--arg mc_loader "$mc_loader" \
'{ "mc-version": $mc_version, "mc-loader": $mc_loader }')

all_folder_objects+=("$folder_object")
done
done

# 使用 jq 创建 JSON 结构
json=$(jq -n --argjson config "$(echo "[${all_folder_objects[*]}]" | jq -s .)" '{ config: $config }')

# 输出结果
echo "::set-output name=matrix::$json"

0 comments on commit a1ac7d6

Please sign in to comment.