首次提交
Some checks failed
Build and Release / build-and-test (alpine) (push) Failing after 53s
Build and Release / build-and-test (ubuntu) (push) Failing after 8m7s
Build and Release / docker-images (push) Has been skipped
Build and Release / release (push) Has been skipped

This commit is contained in:
2025-12-02 11:57:14 +08:00
commit 612ec7b521
6 changed files with 451 additions and 0 deletions

166
.gitea/workflows/ci.yaml Normal file
View File

@@ -0,0 +1,166 @@
# .gitea/workflows/demo.yaml
name: Build and Release
on:
push:
branches: [main, develop]
tags: ['*']
env:
DOCKER_BUILDKIT: "1"
PRODUCT_NAME: "xxxigcc"
PACKAGE_VERSION: "3.4.6-xg1"
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
distro: [ubuntu, alpine]
steps:
- uses: actions/checkout@v4
- name: Setup Docker Buildx
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --use --driver docker-container
- name: Build binaries
run: |
XMRIGCC_VERSION=${PACKAGE_VERSION%-*}
docker buildx build --pull \
--platform linux/amd64,linux/arm64 \
--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 test && tar -xzf "${TARGZ}" -C test
test/xxxigDaemon --version 2>/dev/null || echo "⚠️ 跳过版本检查"
rm -rf test
done
- uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.distro }}
path: "*.tar.gz"
retention-days: 1
docker-images:
runs-on: ubuntu-latest
needs: build-and-test
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: binaries-*
path: ./app
merge-multiple: true
- name: Setup Docker and Login
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --use --driver docker-container
echo "${{ secrets.BUILD_TOKEN }}" | docker login ${{ gitea.server_url }} -u ${{ gitea.actor }} --password-stdin
- name: Determine Docker tag
id: tag
run: |
case "${{ github.ref }}" in
refs/heads/main) TAG="latest" ;;
refs/heads/develop) TAG="develop" ;;
refs/tags/*) TAG="${GITHUB_REF#refs/tags/}" ;;
*) TAG="${{ github.ref_name }}" ;;
esac
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "📦 Docker tag: ${TAG}"
- name: Build and push Docker images
run: |
REGISTRY="${{ gitea.server_url }}/${{ gitea.repository }}"
TAG="${{ steps.tag.outputs.tag }}"
BUILD_ARGS="--pull --push --platform linux/amd64,linux/arm64 \
--build-arg TARGZ_FILE_AMD64=${PRODUCT_NAME}-amd64-alpine-${PACKAGE_VERSION}.tar.gz \
--build-arg TARGZ_FILE_ARM64=${PRODUCT_NAME}-arm64-alpine-${PACKAGE_VERSION}.tar.gz \
--provenance=false --sbom=false"
echo "🐳 Building server image..."
docker buildx build $BUILD_ARGS -t "${REGISTRY}/server:${TAG}" -f docker/Dockerfile.Server .
echo "🐳 Building daemon image..."
docker buildx build $BUILD_ARGS -t "${REGISTRY}/daemon:${TAG}" -f docker/Dockerfile.Daemon .
release:
runs-on: ubuntu-latest
needs: build-and-test
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: binaries-*
path: ./packages
merge-multiple: true
- name: Upload packages and create release
env:
TOKEN: ${{ secrets.BUILD_TOKEN }}
TAG: ${{ github.ref_name }}
REGISTRY: ${{ gitea.server_url }}
OWNER: ${{ gitea.repository_owner }}
REPO: ${{ gitea.repository }}
run: |
cd packages
# 上传所有包
echo "📦 上传包到 Generic Package Registry..."
for file in *.tar.gz; do
[ ! -f "$file" ] && continue
echo " ⬆️ $file"
curl -fsSL -X POST \
-H "Authorization: token ${TOKEN}" \
-F "file=@$file" \
"${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${TAG}/$file" || {
echo "❌ 上传失败: $file"
exit 1
}
done
# 生成 Release 描述
echo "📝 生成 Release 描述..."
BODY="## Release ${TAG}\n\n### 📥 下载链接\n"
for file in *.tar.gz; do
[ -f "$file" ] && BODY="${BODY}- [${file}](${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${TAG}/${file})\n"
done
# 创建 Release
echo "🎉 创建 Release..."
curl -fsSL -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
"${REGISTRY}/api/v1/repos/${REPO}/releases" \
-d @- << EOF || echo "⚠️ Release 可能已存在"
{
"tag_name": "${TAG}",
"name": "Release ${TAG}",
"body": "${BODY}",
"draft": false,
"prerelease": false
}
EOF
echo "✅ Release 创建完成!"

33
docker/Dockerfile.Daemon Normal file
View File

@@ -0,0 +1,33 @@
FROM alpine:3.21
ARG TARGETARCH
ARG TARGZ_FILE_AMD64
ARG TARGZ_FILE_ARM64
RUN apk update && apk add --no-cache wget
COPY ./app /app
RUN if [ "$TARGETARCH" = "amd64" ]; then \
ARCH_FILE="$TARGZ_FILE_AMD64"; \
elif [ "$TARGETARCH" = "arm64" ]; then \
ARCH_FILE="$TARGZ_FILE_ARM64"; \
else \
echo "不支持的架构: $TARGETARCH" && exit 1; \
fi && \
echo "TARGETARCH: $TARGETARCH" && \
echo "使用文件: $ARCH_FILE" && \
ls -la /app/ && \
tar -xzf "/app/${ARCH_FILE}" -C /app --strip-components=1 && \
ls -la /app/ && \
rm -rf /app/*.tar.gz /app/config.json /app/config_cc.json /app/index.html /app/xxxigServer && \
addgroup -S xxxig && \
adduser -S -G xxxig xxxig && \
mkdir -p /app/data && \
chown -R xxxig:xxxig /app && \
chmod +x /app/xxxigDaemon /app/xxxigMiner
USER xxxig
WORKDIR /app
ENTRYPOINT ["/app/xxxigDaemon"]

78
docker/Dockerfile.Server Normal file
View File

@@ -0,0 +1,78 @@
FROM alpine:3.21
ARG TARGETARCH
ARG TARGZ_FILE_AMD64
ARG TARGZ_FILE_ARM64
RUN apk update && apk add --no-cache wget gettext
COPY ./app /app
RUN if [ "$TARGETARCH" = "amd64" ]; then \
ARCH_FILE="$TARGZ_FILE_AMD64"; \
elif [ "$TARGETARCH" = "arm64" ]; then \
ARCH_FILE="$TARGZ_FILE_ARM64"; \
else \
echo "不支持的架构: $TARGETARCH" && exit 1; \
fi && \
echo "TARGETARCH: $TARGETARCH" && \
echo "使用文件: $ARCH_FILE" && \
ls -la /app/ && \
tar -xzf "/app/${ARCH_FILE}" -C /app --strip-components=1 && \
ls -la /app/ && \
rm -rf /app/*.tar.gz /app/config.json /app/config_cc.json /app/xxxigDaemon /app/xxxigMiner && \
addgroup -S xxxig && \
adduser -S -G xxxig xxxig && \
mkdir -p /app/data && \
chown -R xxxig:xxxig /app && \
chmod +x /app/xxxigServer
ENV LOG_FILE=/app/data/xxxigServer.log \
BIND_IP=0.0.0.0 \
PORT=80 \
USER= \
PASS= \
ACCESS_TOKEN= \
TLS=false \
CERT_FILE= \
KEY_FILE= \
TG_BOT_TOKEN= \
TG_CHAT_ID=
COPY <<EOF /app/config.template.json
{
"bind-ip": "\${BIND_IP}",
"log-file": "\${LOG_FILE}",
"port": \${PORT},
"user": "\${USER}",
"pass": "\${PASS}",
"access-token": "\${ACCESS_TOKEN}",
"use-tls": \${TLS},
"cert-file": "\${CERT_FILE}",
"key-file": "\${KEY_FILE}",
"telegram-bot-token": "\${TG_BOT_TOKEN}",
"telegram-chat-id": "\${TG_CHAT_ID}"
}
EOF
RUN chmod 644 /app/config.template.json
COPY <<EOF /app/entrypoint.sh
#!/bin/sh
if [ ! -f /app/data/config.json ]; then
envsubst < /app/config.template.json > /app/data/config.json
fi
exec "\$@"
EOF
RUN chmod +x /app/entrypoint.sh
EXPOSE 80 443
VOLUME /app/data \
/app/certs
USER xxxig
WORKDIR /app
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["/app/xxxigServer", "-c", "/app/data/config.json"]

74
docker/Dockerfile.alpine Normal file
View File

@@ -0,0 +1,74 @@
FROM alpine:latest AS base
# 根据目标架构设置构建参数
ARG TARGETARCH
RUN apk update && apk add --no-cache \
git \
make \
cmake \
libstdc++ \
gcc \
g++ \
automake \
libtool \
autoconf \
linux-headers \
libuv-dev \
openssl-dev \
hwloc-dev
FROM base AS build
ARG TARGZ_FILE
ARG XMRIGCC_VERSION
ARG TARGETARCH
RUN git clone --recursive https://github.com/Bendr0id/xmrigCC.git && \
mv xmrigCC xxxigcc && \
cd xxxigcc && \
git checkout ${XMRIGCC_VERSION}
WORKDIR /xxxigcc
COPY ./init.sh ./init.sh
# 根据目标架构优化编译
RUN chmod +x ./init.sh && ./init.sh && \
mkdir build && cd scripts && chmod +x ./*.sh && ./build_deps.sh && cd ../build && \
if [ "$TARGETARCH" = "arm64" ]; then \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DXMRIG_DEPS=scripts/deps \
-DBUILD_STATIC=ON \
-DWITH_ZLIB=ON \
-DWITH_OPENCL=OFF \
-DWITH_CUDA=OFF \
-DARM_TARGET=8; \
elif [ "$TARGETARCH" = "arm" ]; then \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DXMRIG_DEPS=scripts/deps \
-DBUILD_STATIC=ON \
-DWITH_ZLIB=ON \
-DWITH_OPENCL=OFF \
-DWITH_CUDA=OFF \
-DARM_TARGET=7; \
else \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DXMRIG_DEPS=scripts/deps \
-DBUILD_STATIC=ON \
-DWITH_ZLIB=ON \
-DWITH_OPENCL=OFF \
-DWITH_CUDA=OFF; \
fi && \
make -j$(nproc)
FROM scratch
ARG TARGETARCH
COPY --from=build /xxxigcc/build/xxxigDaemon /linux_${TARGETARCH}/xxxigDaemon
COPY --from=build /xxxigcc/build/xxxigMiner /linux_${TARGETARCH}/xxxigMiner
COPY --from=build /xxxigcc/build/xxxigServer /linux_${TARGETARCH}/xxxigServer
COPY --from=build /xxxigcc/src/config_cc.json /linux_${TARGETARCH}/config_cc.json
COPY --from=build /xxxigcc/src/config.json /linux_${TARGETARCH}/config.json
COPY --from=build /xxxigcc/index.html /linux_${TARGETARCH}/index.html

76
docker/Dockerfile.ubuntu Normal file
View File

@@ -0,0 +1,76 @@
FROM ubuntu:20.04 AS base
ARG TARGETARCH
ARG BUILDPLATFORM
ENV DEBIAN_FRONTEND=noninteractive
# 根据目标架构安装相应的交叉编译工具链
RUN apt-get update && apt-get install -y \
git \
wget \
build-essential \
cmake \
libuv1-dev \
libssl-dev \
libhwloc-dev \
&& if [ "$TARGETARCH" = "arm64" ] && [ "$BUILDPLATFORM" != "linux/arm64" ]; then \
apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu; \
elif [ "$TARGETARCH" = "arm" ] && [ "$BUILDPLATFORM" != "linux/arm/v7" ]; then \
apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf; \
fi \
&& rm -rf /var/lib/apt/lists/*
FROM base AS build
ARG TARGZ_FILE
ARG TARGET_ARCH
ARG XMRIGCC_VERSION
ARG TARGETARCH
ARG BUILDPLATFORM
RUN git clone --recursive https://github.com/Bendr0id/xmrigCC.git && \
mv xmrigCC xxxigcc && \
cd xxxigcc && \
git checkout ${XMRIGCC_VERSION}
WORKDIR /xxxigcc
COPY ./init.sh ./init.sh
# 根据目标架构设置编译环境和参数
RUN chmod +x ./init.sh && ./init.sh && \
mkdir build && cd scripts && chmod +x ./*.sh && ./build_deps.sh && cd ../build && \
if [ "$TARGETARCH" = "arm64" ] && [ "$BUILDPLATFORM" != "linux/arm64" ]; then \
export CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++; \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
-DARM_TARGET=8 \
-DXMRIG_DEPS=scripts/deps \
-DWITH_ZLIB=ON; \
elif [ "$TARGETARCH" = "arm" ] && [ "$BUILDPLATFORM" != "linux/arm/v7" ]; then \
export CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++; \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
-DARM_TARGET=7 \
-DXMRIG_DEPS=scripts/deps \
-DWITH_ZLIB=ON; \
else \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DXMRIG_DEPS=scripts/deps \
-DWITH_ZLIB=ON; \
fi && \
make -j$(nproc)
FROM scratch
ARG TARGETARCH
COPY --from=build /xxxigcc/build/xxxigDaemon /linux_${TARGETARCH}/xxxigDaemon
COPY --from=build /xxxigcc/build/xxxigMiner /linux_${TARGETARCH}/xxxigMiner
COPY --from=build /xxxigcc/build/xxxigServer /linux_${TARGETARCH}/xxxigServer
COPY --from=build /xxxigcc/src/config_cc.json /linux_${TARGETARCH}/config_cc.json
COPY --from=build /xxxigcc/src/config.json /linux_${TARGETARCH}/config.json
COPY --from=build /xxxigcc/index.html /linux_${TARGETARCH}/index.html

24
init.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/sh
# Modify the CMakeLists.txt and source files to change the project name from "xmrigcc" to "xxxigcc"
sed -i 's/project(xmrigcc)/project(xxxigcc)/' CMakeLists.txt
sed -i 's/XMRigCC: Found ccache package/XXXigCC: Found ccache package/' CMakeLists.txt
sed -i 's/MINER_EXECUTABLE_NAME "xmrigMiner"/MINER_EXECUTABLE_NAME "xxxigMiner"/' CMakeLists.txt
sed -i 's/DAEMON_EXECUTABLE_NAME "xmrigDaemon"/DAEMON_EXECUTABLE_NAME "xxxigDaemon"/' CMakeLists.txt
sed -i 's/xmrigServer ${SOURCES_CC_SERVER}/xxxigServer ${SOURCES_CC_SERVER}/' CMakeLists.txt
sed -i 's/xmrigServer ${XMRIG_ASM_LIBRARY}/xxxigServer ${XMRIG_ASM_LIBRARY}/' CMakeLists.txt
sed -i 's/xmrigServer POST_BUILD/xxxigServer POST_BUILD/' CMakeLists.txt
# Modify donate functionality
sed -i 's/kDefaultDonateLevel = 3/kDefaultDonateLevel = 0/' src/donate.h
sed -i 's/kMinimumDonateLevel = 1/kMinimumDonateLevel = 0/' src/donate.h
sed -i 's/donate.graef.in/127.0.0.1/' src/net/strategies/DonateStrategy.cpp
sed -i 's/87.106.163.52/127.0.0.1/' src/net/strategies/DonateStrategy.cpp
sed -i 's/"donate-level": 3/"donate-level": 0/' src/config.json
sed -i 's/"donate-over-proxy": 1/"donate-over-proxy": 0/' src/config.json
# Modify version information
sed -i 's/Copyright (C) 2017- XMRigCC//' src/version.h
sed -i 's/https:\/\/github.com\/BenDr0id\/xmrigCC\///' src/version.h
sed -i 's/xmrigcc/xxxigcc/' src/version.h
sed -i 's/XMRigCC/XXXigCC/' src/version.h