diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 287b4a3..1da2d51 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -14,65 +14,65 @@ env: jobs: build-and-test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest-amd64' || 'ubuntu-latest-arm64' }} strategy: matrix: + arch: [amd64, arm64] distro: [ubuntu, alpine] steps: - uses: actions/checkout@v4 - name: Setup Docker Buildx run: | - # 尝试设置 QEMU,但忽略错误(宿主机可能已配置) - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes 2>/dev/null || true - - # 验证 binfmt 是否可用 - if [ -d /proc/sys/fs/binfmt_misc ]; then - echo "✅ binfmt_misc 可用" - ls /proc/sys/fs/binfmt_misc/ | grep -E "qemu-(aarch64|arm)" || echo "⚠️ 部分架构可能未注册" - fi - - # 创建 buildx builder,增加资源限制和优化参数 - docker buildx create --use --name multiarch-builder \ + # 创建 buildx builder(原生构建不需要 QEMU) + docker buildx create --use --name native-builder \ --driver docker-container \ --driver-opt network=host \ --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=50000000 \ --driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10000000 \ - --buildkitd-flags '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host' \ || true docker buildx inspect --bootstrap - name: Build binaries run: | XMRIGCC_VERSION=${PACKAGE_VERSION%-*} + PLATFORM="linux/${{ matrix.arch }}" + + echo "🏗️ Building ${PLATFORM} on native ${{ matrix.arch }} runner" + echo "📦 Distribution: ${{ matrix.distro }}" # 设置 BuildKit 优化参数 export BUILDKIT_PROGRESS=plain docker buildx build --pull \ - --platform linux/amd64,linux/arm64 \ + --platform ${PLATFORM} \ --build-arg XMRIGCC_VERSION=${XMRIGCC_VERSION} \ --output type=local,dest=./output \ -f docker/Dockerfile.${{ matrix.distro }} . - name: Package and test run: | - for arch in amd64 arm64; do - DIR="./output/linux_${arch}" - [ ! -d "$DIR" ] && continue - - TARGZ="${PRODUCT_NAME}-${arch}-${{ matrix.distro }}-${PACKAGE_VERSION}.tar.gz" - tar -czf "${TARGZ}" -C "$DIR" . - - # 快速验证 - mkdir -p test && tar -xzf "${TARGZ}" -C test - test/xxxigDaemon --version 2>/dev/null || echo "⚠️ 跳过版本检查" - rm -rf test - done + DIR="./output/linux_${{ matrix.arch }}" + + if [ ! -d "$DIR" ]; then + echo "❌ 构建输出目录不存在: $DIR" + exit 1 + fi + + TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-${{ matrix.distro }}-${PACKAGE_VERSION}.tar.gz" + tar -czf "${TARGZ}" -C "$DIR" . + + echo "📦 Created package: ${TARGZ}" + ls -lh "${TARGZ}" + + # 快速验证 + mkdir -p test && tar -xzf "${TARGZ}" -C test + test/xxxigDaemon --version 2>/dev/null || echo "⚠️ 跳过版本检查" + rm -rf test - uses: actions/upload-artifact@v4 with: - name: binaries-${{ matrix.distro }} + name: binaries-${{ matrix.arch }}-${{ matrix.distro }} path: "*.tar.gz" retention-days: 1