Skip to content

[Add]更新一堆落幕曲中的Mod #12

[Add]更新一堆落幕曲中的Mod

[Add]更新一堆落幕曲中的Mod #12

Workflow file for this run

name: Cross-Platform Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [published]
jobs:
build:
name: Build ${{ matrix.os }}-${{ matrix.arch }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# Linux builds
- os: linux
arch: x86_64
runner: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
executable_suffix: ""
cmake_arch: ""
- os: linux
arch: aarch64
runner: ubuntu-latest
c_compiler: aarch64-linux-gnu-gcc
cpp_compiler: aarch64-linux-gnu-g++
executable_suffix: ""
cmake_arch: "-DCMAKE_SYSTEM_PROCESSOR=aarch64"
- os: linux
arch: i386
runner: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
executable_suffix: ""
cmake_arch: "-DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32"
# Windows builds
- os: windows
arch: x86_64
runner: windows-latest
c_compiler: cl
cpp_compiler: cl
executable_suffix: ".exe"
cmake_arch: "-A x64"
- os: windows
arch: aarch64
runner: windows-latest
c_compiler: cl
cpp_compiler: cl
executable_suffix: ".exe"
cmake_arch: "-A ARM64"
- os: windows
arch: i386
runner: windows-latest
c_compiler: cl
cpp_compiler: cl
executable_suffix: ".exe"
cmake_arch: "-A Win32"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies (Linux)
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake ninja-build
# ARM64 交叉编译工具链
if [ "${{ matrix.arch }}" == "aarch64" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
fi
# i386 支持
if [ "${{ matrix.arch }}" == "i386" ]; then
sudo apt-get install -y gcc-multilib g++-multilib
fi
- name: Install dependencies (Windows)
if: matrix.os == 'windows'
run: |
choco install ninja
- name: Configure CMake (Linux)
if: matrix.os == 'linux'
run: |
cmake -B ${{ github.workspace }}/build -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_BUILD_TYPE=Release -G Ninja ${{ matrix.cmake_arch }}
- name: Configure CMake (Windows)
if: matrix.os == 'windows'
run: |
cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_arch }}
- name: Build
run: |
cmake --build ${{ github.workspace }}/build --config Release
- name: Test
if: matrix.arch == 'x86_64' # 只在x86_64架构上运行测试
working-directory: ${{ github.workspace }}/build
run: |
ctest --build-config Release --output-on-failure
- name: Debug - List build directory
run: |
echo "=== Build directory structure ==="
find build -type f -name "*" | head -20
echo "=== Looking for executable files ==="
find build -name "*Minecraft-mod-classifier*" -type f
echo "=== Looking for data files ==="
find . -name "mods_data.json" -o -name "mods-data.json"
shell: bash
- name: Package artifacts
run: |
mkdir -p artifacts
# 查找并复制可执行文件 (注意大小写)
if [ "${{ matrix.os }}" == "windows" ]; then
# Windows 构建输出路径
find build -name "*Minecraft-mod-classifier*${{ matrix.executable_suffix }}" -type f -exec cp {} artifacts/ \;
find build/Release -name "*Minecraft-mod-classifier*${{ matrix.executable_suffix }}" -type f -exec cp {} artifacts/ \; 2>/dev/null || true
else
# Linux 构建输出路径
find build -name "*Minecraft-mod-classifier*${{ matrix.executable_suffix }}" -type f -exec cp {} artifacts/ \;
fi
# 复制数据文件 (注意文件名是 mods_data.json)
if [ -f "assets/mods_data.json" ]; then
cp assets/mods_data.json artifacts/
fi
# 重命名可执行文件以包含架构信息,但保留JSON文件原名
cd artifacts
for file in *${{ matrix.executable_suffix }}; do
if [ -f "$file" ] && [[ "$file" != *.json ]]; then
mv "$file" "${file%${{ matrix.executable_suffix }}}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.executable_suffix }}"
fi
done
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: minecraft-mod-classifier-${{ matrix.os }}-${{ matrix.arch }}
path: artifacts/
retention-days: 30
release:
if: github.event_name == 'release'
needs: build
runs-on: ubuntu-latest
permissions:
contents: write # 添加写权限
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: Create release archives
run: |
cd release-artifacts
for dir in */; do
if [ -d "$dir" ]; then
cd "$dir"
if [[ "$dir" == *"windows"* ]]; then
# Windows 平台使用 zip
zip -r "../${dir%/}.zip" .
else
# Linux 平台使用 tar.gz
tar -czf "../${dir%/}.tar.gz" .
fi
cd ..
fi
done
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
files: |
release-artifacts/*.tar.gz
release-artifacts/*.zip
token: ${{ secrets.GITHUB_TOKEN }}