初始化 proxy 打包项目,对齐 xxxig 矿工项目
Build and Release / build-and-test (amd64, alpine) (push) Successful in 20s
Build and Release / build-and-test (arm64, alpine) (push) Successful in 42s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 27s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 9s
Build and Release / release (push) Has been skipped
Build and Release / build-and-test (amd64, alpine) (push) Successful in 20s
Build and Release / build-and-test (arm64, alpine) (push) Successful in 42s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 27s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 9s
Build and Release / release (push) Has been skipped
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,232 @@
|
|||||||
|
# .gitea/workflows/ci.yaml
|
||||||
|
name: Build and Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main, develop]
|
||||||
|
tags: ['*']
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOCKER_BUILDKIT: "1"
|
||||||
|
PRODUCT_NAME: "xxxig-proxy"
|
||||||
|
PACKAGE_VERSION: "6.26.0"
|
||||||
|
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-test:
|
||||||
|
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: |
|
||||||
|
# 创建 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 \
|
||||||
|
|| true
|
||||||
|
docker buildx inspect --bootstrap
|
||||||
|
|
||||||
|
- name: Build binaries
|
||||||
|
run: |
|
||||||
|
XXXIG_PROXY_VERSION=v${PACKAGE_VERSION} # 上游源码 git tag 带 v 前缀,需补回
|
||||||
|
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 ${PLATFORM} \
|
||||||
|
--build-arg XXXIG_PROXY_VERSION=${XXXIG_PROXY_VERSION} \
|
||||||
|
--output type=local,dest=./output \
|
||||||
|
-f docker/Dockerfile.${{ matrix.distro }} .
|
||||||
|
|
||||||
|
- name: Package and test
|
||||||
|
run: |
|
||||||
|
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/xxxig-proxy --version 2>/dev/null || echo "⚠️ 跳过版本检查"
|
||||||
|
rm -rf test
|
||||||
|
|
||||||
|
- name: Build Debian package
|
||||||
|
if: matrix.distro == 'ubuntu'
|
||||||
|
run: |
|
||||||
|
# 安装 dpkg-deb(如果需要)
|
||||||
|
sudo apt-get update && sudo apt-get install -y dpkg-dev
|
||||||
|
|
||||||
|
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-${{ matrix.distro }}-${PACKAGE_VERSION}.tar.gz"
|
||||||
|
|
||||||
|
echo "📦 Building Debian package for ${{ matrix.arch }}..."
|
||||||
|
chmod +x debian/build-deb.sh
|
||||||
|
./debian/build-deb.sh ${{ matrix.arch }} ${PACKAGE_VERSION} "${TARGZ}"
|
||||||
|
|
||||||
|
ls -lh *.deb
|
||||||
|
|
||||||
|
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: binaries-${{ matrix.arch }}-${{ matrix.distro }}
|
||||||
|
path: |
|
||||||
|
*.tar.gz
|
||||||
|
*.deb
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest-amd64
|
||||||
|
needs: build-and-test
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
steps:
|
||||||
|
- uses: https://github.com/ChristopherHX/gitea-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 }}
|
||||||
|
run: |
|
||||||
|
cd packages
|
||||||
|
|
||||||
|
# 提取仓库信息(移除 https:// 前缀和仓库路径)
|
||||||
|
REGISTRY=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
|
||||||
|
OWNER="${{ gitea.repository_owner }}"
|
||||||
|
REPO_NAME=$(echo "${{ gitea.repository }}" | cut -d'/' -f2)
|
||||||
|
VERSION="${TAG#v}" # 包版本:去掉 git tag 的 v 前缀(registry 路径/下载名/Release 标题用)
|
||||||
|
|
||||||
|
echo "📦 上传包到 Generic Package Registry..."
|
||||||
|
echo " Registry: ${REGISTRY}"
|
||||||
|
echo " Owner: ${OWNER}"
|
||||||
|
echo " Package: ${PRODUCT_NAME}"
|
||||||
|
echo " Version: ${VERSION}"
|
||||||
|
|
||||||
|
# 上传所有 tar.gz 包到 Generic Package Registry
|
||||||
|
for file in *.tar.gz; do
|
||||||
|
[ ! -f "$file" ] && continue
|
||||||
|
echo " ⬆️ $file"
|
||||||
|
curl -fsSL -X PUT \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
--upload-file "$file" \
|
||||||
|
"https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${VERSION}/$file" || {
|
||||||
|
echo "❌ 上传失败: $file"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
# 上传 Debian 包到 Debian Package Registry (通用稳定版)
|
||||||
|
echo ""
|
||||||
|
echo "📦 上传 Debian 包到 Debian Package Registry..."
|
||||||
|
for file in *.deb; do
|
||||||
|
[ ! -f "$file" ] && continue
|
||||||
|
|
||||||
|
# 上传到 stable (通用稳定版)
|
||||||
|
echo " ⬆️ $file → stable"
|
||||||
|
curl -fsSL -X PUT \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
--upload-file "$file" \
|
||||||
|
"https://${REGISTRY}/api/packages/${OWNER}/debian/pool/stable/main/upload" || {
|
||||||
|
echo "❌ Debian 包上传失败: $file (stable)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
# 生成 Release 描述
|
||||||
|
echo ""
|
||||||
|
echo "📝 生成 Release..."
|
||||||
|
|
||||||
|
# 拼接 tar.gz 下载链接
|
||||||
|
ASSETS=$(for f in *.tar.gz; do
|
||||||
|
[ -f "$f" ] || continue
|
||||||
|
echo "- [\`$f\`](https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${VERSION}/$f)"
|
||||||
|
done)
|
||||||
|
|
||||||
|
BODY=$(cat <<EOF
|
||||||
|
## Release ${VERSION}
|
||||||
|
|
||||||
|
### 📥 Debian/Ubuntu 安装
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
sudo curl https://${REGISTRY}/api/packages/${OWNER}/debian/repository.key -o /etc/apt/keyrings/gitea-${OWNER}.asc
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/gitea-${OWNER}.asc] https://${REGISTRY}/api/packages/${OWNER}/debian stable main" | sudo tee /etc/apt/sources.list.d/${OWNER}.list
|
||||||
|
sudo apt-get update && sudo apt-get install xxxig-proxy
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### 📦 tar.gz 下载
|
||||||
|
|
||||||
|
${ASSETS}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
RELEASE_DATA=$(jq -n --arg tag "$TAG" --arg ver "$VERSION" --arg body "$BODY" \
|
||||||
|
'{tag_name: $tag, name: "Release \($ver)", body: $body, draft: false, prerelease: false}')
|
||||||
|
|
||||||
|
# 创建 Release
|
||||||
|
echo ""
|
||||||
|
echo "🎉 创建 Release..."
|
||||||
|
RESPONSE=$(curl -fsSL -w "\n%{http_code}" -X POST \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
"https://${REGISTRY}/api/v1/repos/${{ gitea.repository }}/releases" \
|
||||||
|
-d "${RELEASE_DATA}")
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||||
|
RESPONSE_BODY=$(echo "$RESPONSE" | head -n-1)
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" = "201" ]; then
|
||||||
|
echo "✅ Release 创建成功"
|
||||||
|
RELEASE_ID=$(echo "$RESPONSE_BODY" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||||
|
echo " Release ID: ${RELEASE_ID}"
|
||||||
|
elif [ "$HTTP_CODE" = "409" ]; then
|
||||||
|
echo "⚠️ Release 已存在,获取现有 Release ID..."
|
||||||
|
RELEASE_ID=$(curl -fsSL \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
"https://${REGISTRY}/api/v1/repos/${{ gitea.repository }}/releases/tags/${TAG}" | \
|
||||||
|
grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||||
|
echo " Release ID: ${RELEASE_ID}"
|
||||||
|
else
|
||||||
|
echo "❌ 创建 Release 失败 (HTTP ${HTTP_CODE})"
|
||||||
|
echo "$RESPONSE_BODY"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 上传文件作为 Release 附件
|
||||||
|
echo ""
|
||||||
|
echo "📎 上传文件作为 Release 附件..."
|
||||||
|
for file in *.tar.gz *.deb; do
|
||||||
|
[ ! -f "$file" ] && continue
|
||||||
|
echo " ⬆️ $file"
|
||||||
|
|
||||||
|
# 使用 multipart/form-data 上传附件
|
||||||
|
curl -fsSL -X POST \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-F "attachment=@${file}" \
|
||||||
|
"https://${REGISTRY}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets?name=${file}" || {
|
||||||
|
echo " ⚠️ 附件上传失败: $file(可能已存在)"
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "✅ Release 创建完成!"
|
||||||
|
echo "🔗 访问: https://${REGISTRY}/${{ gitea.repository }}/releases/tag/${TAG}"
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
.claude
|
||||||
|
.codex
|
||||||
|
|
||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# 构建产物
|
||||||
|
*.deb
|
||||||
|
*.tar.gz
|
||||||
|
output/
|
||||||
|
packages/
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
|
||||||
|
## 仓库性质
|
||||||
|
|
||||||
|
本仓库**只包含构建与打包基础设施**,不含代理源码。代理源码在编译时从外部仓库克隆(见两个 Dockerfile):
|
||||||
|
|
||||||
|
- 源码仓库:`github.com/wangdefaa/xxxig-proxy.git`(注意结尾是 **wangdefaa**,双 a)
|
||||||
|
- 发布仓库:Gitea `gitea.bcde.io` 下的 `wangdefa/xxxig-proxy`(结尾是 **wangdefa**,单 a)
|
||||||
|
|
||||||
|
这两个名字极易混淆,改动 URL 时务必区分。xxxig-proxy 是 XMRig-Proxy(Monero/RandomX 矿机代理)的定制/换名构建,**已移除捐献功能**。
|
||||||
|
|
||||||
|
## 整体架构:单二进制
|
||||||
|
|
||||||
|
编译产出单个可执行文件 `xxxig-proxy`:矿机代理服务,监听矿机接入并把算力聚合转发到上游矿池,降低矿池侧连接数。配置来自源码 `src/config.json`。
|
||||||
|
|
||||||
|
> **与矿工项目 `xxxig` 的关键差异**:矿工是 `xxxig / xxxigDaemon / xxxigServer` 三件套 + CC(Central Control)+ Web 控制台;proxy 是**单二进制、无 C&C、无 GPU、动态链接**。本仓库的 build-deb.sh / postinst / service 都只处理这一个二进制。
|
||||||
|
|
||||||
|
## 构建与发布流程(CI)
|
||||||
|
|
||||||
|
[.gitea/workflows/ci.yaml](.gitea/workflows/ci.yaml) 是 Gitea Actions 流水线:
|
||||||
|
|
||||||
|
1. **build-and-test**(矩阵 `arch=[amd64,arm64] × distro=[ubuntu,alpine]`,跑在对应架构的原生 runner 上):用 `docker buildx` 按 `docker/Dockerfile.{distro}` 原生编译 → 打成 tar.gz → 仅 ubuntu distro 再调 `debian/build-deb.sh` 打 .deb → 上传 artifact。
|
||||||
|
2. **release**(仅 tag 触发):下载 artifact,上传 tar.gz 到 Generic Package Registry、上传 .deb 到 Debian Registry(stable/main),并用 `jq` 生成描述创建 Gitea Release。
|
||||||
|
|
||||||
|
关键点:
|
||||||
|
- 版本号**硬编码**在 ci.yaml 的 `PACKAGE_VERSION: "6.26.0"`(纯数字,符合 Debian 版本规范),发版改这里。**关键分界**:上游源码 git tag 带 `v`(CI 用 `XXXIG_PROXY_VERSION=v${PACKAGE_VERSION}` 检出 `v6.26.0`),而 tar.gz/deb/registry 路径等包版本一律用数字;release job 用 `VERSION="${TAG#v}"` 归一,build-deb.sh 用 `DEB_VERSION="${VERSION#v}"` 归一。
|
||||||
|
- Dockerfile build-arg 名为 `XXXIG_PROXY_VERSION`(注意 `_PROXY_`,与矿工的 `XXXIG_VERSION` 区分),ci.yaml 与两个 Dockerfile 三处必须一致。
|
||||||
|
- 构建用 `cmake .. -DCMAKE_BUILD_TYPE=Release`(**动态链接**,依赖 libuv/OpenSSL),与矿工的静态构建不同;Dockerfile.ubuntu 基于 `ubuntu:20.04`(glibc 2.31,与 control.template 的 `libc6 (>= 2.31)` 对齐)。
|
||||||
|
- 架构名映射:`x86_64→amd64`、`aarch64→arm64`。
|
||||||
|
- tar.gz 下载 URL 形如 `https://gitea.bcde.io/api/packages/wangdefa/generic/xxxig-proxy/{version}/xxxig-proxy-{arch}-{os}-{version}.tar.gz`。
|
||||||
|
|
||||||
|
## 本地常用命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 本地编译某架构/发行版的二进制(输出到 ./output/linux_<arch>/)
|
||||||
|
docker buildx build --platform linux/amd64 \
|
||||||
|
--build-arg XXXIG_PROXY_VERSION=v6.26.0 \
|
||||||
|
--output type=local,dest=./output \
|
||||||
|
-f docker/Dockerfile.ubuntu .
|
||||||
|
|
||||||
|
# 用已有 tar.gz 打 .deb 包
|
||||||
|
./debian/build-deb.sh amd64 6.26.0 xxxig-proxy-amd64-ubuntu-6.26.0.tar.gz
|
||||||
|
|
||||||
|
# 改 shell 脚本后做静态检查(需自行安装 shellcheck)
|
||||||
|
shellcheck debian/*.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
无单元测试;CI 中唯一的冒烟测试是解包后跑 `xxxig-proxy --version`。
|
||||||
|
|
||||||
|
## Debian 包布局与服务
|
||||||
|
|
||||||
|
- 二进制装到 `/opt/xxxig-proxy/`,systemd 服务文件 `debian/xxxig-proxy.service`,维护脚本 `debian/{postinst,prerm,postrm}`。
|
||||||
|
- postinst 创建 `xxxig-proxy` 系统用户、把默认配置复制到 `/etc/xxxig-proxy/config.json`、`/opt` 归 `root:root`(目录/二进制 755、数据文件 644)。**服务不自动启用/启动**(默认上游 `localhost` 无效),升级时仅 `try-restart` 已在运行的服务。
|
||||||
|
- 本仓库**不含 `script/` 安装脚本**(与矿工项目不同),.deb 安装后需用户手动 `systemctl enable --now xxxig-proxy`。
|
||||||
|
- **已知待办**:proxy 为动态链接(依赖 libuv/OpenSSL),但 control.template 的 `Depends` 目前仅 `libc6`。待 CI 首次构建出产物后用 `ldd` 实测,再补全 `libuv1`、`libssl`(按构建发行版包名,ubuntu 20.04 为 `libssl1.1`,22.04 为 `libssl3`,写错会导致 apt 拒装)。
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
# XXXig Proxy
|
||||||
|
|
||||||
|
XXXig Proxy 是 [XMRig-Proxy](https://github.com/xmrig/xmrig-proxy) 的定制构建——**无捐献改造版**的 Monero (RandomX) 矿机代理。
|
||||||
|
|
||||||
|
代理的作用:把大量矿机聚合成到上游矿池的少数几条连接,降低矿池侧连接数与网络开销,并统一管理矿机接入。
|
||||||
|
|
||||||
|
**本仓库只包含构建与打包基础设施**,不含代理源码:二进制在 CI 中从上游源码仓库 `github.com/wangdefaa/xxxig-proxy` 编译,再打包分发到 [gitea.bcde.io](https://gitea.bcde.io) 的 Generic / Debian 包仓库。
|
||||||
|
|
||||||
|
## 产物
|
||||||
|
|
||||||
|
每次构建产出单个可执行文件(网络服务,动态链接 libuv/OpenSSL,运行时依赖 glibc):
|
||||||
|
|
||||||
|
| 二进制 | 作用 |
|
||||||
|
|---|---|
|
||||||
|
| `xxxig-proxy` | 矿机代理服务:监听矿机接入,聚合转发到上游矿池 |
|
||||||
|
|
||||||
|
支持架构 `amd64` / `arm64`,发行版 Ubuntu/Debian、Alpine。
|
||||||
|
|
||||||
|
> 与矿工项目 `xxxig`(`xxxig` / `xxxigDaemon` / `xxxigServer` 三件套 + Web 控制台)不同,proxy 是**单二进制、无 C&C、无 GPU**。
|
||||||
|
|
||||||
|
## 安装
|
||||||
|
|
||||||
|
### APT(Debian / Ubuntu)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo curl https://gitea.bcde.io/api/packages/wangdefa/debian/repository.key -o /etc/apt/keyrings/gitea-wangdefa.asc
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/gitea-wangdefa.asc] https://gitea.bcde.io/api/packages/wangdefa/debian stable main" | sudo tee /etc/apt/sources.list.d/wangdefa.list
|
||||||
|
sudo apt-get update && sudo apt-get install xxxig-proxy
|
||||||
|
```
|
||||||
|
|
||||||
|
安装布局:
|
||||||
|
|
||||||
|
| | 路径 |
|
||||||
|
|---|---|
|
||||||
|
| 二进制 | `/opt/xxxig-proxy/xxxig-proxy` |
|
||||||
|
| 默认配置 | `/opt/xxxig-proxy/config.json`(postinst 复制到 `/etc/xxxig-proxy/config.json`) |
|
||||||
|
| 日志 | `/var/log/xxxig-proxy/` |
|
||||||
|
| 服务 | `xxxig-proxy.service` |
|
||||||
|
|
||||||
|
> 安装后服务**不会自动启动**(默认上游为 `localhost`,无实际意义)。先编辑 `/etc/xxxig-proxy/config.json` 配好上游矿池,再启用:
|
||||||
|
>
|
||||||
|
> ```bash
|
||||||
|
> sudo systemctl enable --now xxxig-proxy
|
||||||
|
> ```
|
||||||
|
|
||||||
|
### tar.gz(通用:Alpine / Ubuntu / Debian)
|
||||||
|
|
||||||
|
从 Generic Package Registry 下载对应架构/发行版的 tar.gz 解压即用:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fSL -o xxxig-proxy.tar.gz \
|
||||||
|
https://gitea.bcde.io/api/packages/wangdefa/generic/xxxig-proxy/6.26.0/xxxig-proxy-amd64-ubuntu-6.26.0.tar.gz
|
||||||
|
tar -xzf xxxig-proxy.tar.gz
|
||||||
|
./xxxig-proxy -c config.json
|
||||||
|
```
|
||||||
|
|
||||||
|
## 构建与发布
|
||||||
|
|
||||||
|
CI 定义于 [.gitea/workflows/ci.yaml](.gitea/workflows/ci.yaml):
|
||||||
|
|
||||||
|
- **push 到 `main`/`develop`**:矩阵 `arch=[amd64,arm64] × distro=[ubuntu,alpine]`,在原生 runner 上用 Docker 编译为 tar.gz,ubuntu 再打 `.deb`。
|
||||||
|
- **打 tag**:产物上传到 Generic / Debian 包仓库并创建 Release。
|
||||||
|
|
||||||
|
本地构建:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 编译某架构/发行版二进制(输出到 ./output/linux_<arch>/)
|
||||||
|
docker buildx build --platform linux/amd64 \
|
||||||
|
--build-arg XXXIG_PROXY_VERSION=v6.26.0 \
|
||||||
|
--output type=local,dest=./output \
|
||||||
|
-f docker/Dockerfile.ubuntu .
|
||||||
|
|
||||||
|
# 用产物 tar.gz 打 .deb
|
||||||
|
./debian/build-deb.sh amd64 6.26.0 xxxig-proxy-amd64-ubuntu-6.26.0.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
## 版本号约定
|
||||||
|
|
||||||
|
- **上游源码 git tag** 带 `v`(如 `v6.26.0`),CI 用 `XXXIG_PROXY_VERSION=v${PACKAGE_VERSION}` 检出。
|
||||||
|
- **包版本**(tar.gz / deb / registry 路径)一律用数字(如 `6.26.0`),符合 Debian 版本规范。
|
||||||
|
|
||||||
|
发版只需改 ci.yaml 的 `PACKAGE_VERSION`。
|
||||||
|
|
||||||
|
## 目录结构
|
||||||
|
|
||||||
|
```
|
||||||
|
.gitea/workflows/ CI 流水线
|
||||||
|
docker/ 各发行版 Dockerfile(从上游源码编译)
|
||||||
|
debian/ .deb 打包:control 模板、维护脚本、systemd 服务
|
||||||
|
```
|
||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# 参数检查
|
||||||
|
if [ $# -ne 3 ]; then
|
||||||
|
echo "Usage: $0 <ARCH> <VERSION> <TARGZ_FILE>"
|
||||||
|
echo "Example: $0 amd64 6.26.0 xxxig-proxy-amd64-ubuntu-6.26.0.tar.gz"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ARCH=$1
|
||||||
|
VERSION=$2
|
||||||
|
TARGZ_FILE=$3
|
||||||
|
PKG_NAME="xxxig-proxy"
|
||||||
|
DEB_VERSION="${VERSION#v}" # Debian 版本号必须以数字开头,去掉可能的 v 前缀
|
||||||
|
|
||||||
|
[ -f "$TARGZ_FILE" ] || { echo "❌ 找不到产物包: $TARGZ_FILE"; exit 1; }
|
||||||
|
|
||||||
|
# 转换架构名称(Docker 使用的架构名到 Debian 架构名)
|
||||||
|
case "$ARCH" in
|
||||||
|
amd64)
|
||||||
|
DEB_ARCH="amd64"
|
||||||
|
;;
|
||||||
|
arm64)
|
||||||
|
DEB_ARCH="arm64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported architecture: $ARCH"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
DEB_FILE="${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}.deb"
|
||||||
|
|
||||||
|
echo "📦 Building Debian package: ${DEB_FILE}"
|
||||||
|
echo " Architecture: ${DEB_ARCH}"
|
||||||
|
echo " Version: ${DEB_VERSION}"
|
||||||
|
echo " Source: ${TARGZ_FILE}"
|
||||||
|
|
||||||
|
# 创建临时目录
|
||||||
|
BUILD_DIR=$(mktemp -d)
|
||||||
|
trap "rm -rf $BUILD_DIR" EXIT
|
||||||
|
|
||||||
|
# 创建包目录结构
|
||||||
|
PKG_DIR="${BUILD_DIR}/${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}"
|
||||||
|
mkdir -p "${PKG_DIR}/DEBIAN"
|
||||||
|
mkdir -p "${PKG_DIR}/opt/xxxig-proxy"
|
||||||
|
mkdir -p "${PKG_DIR}/lib/systemd/system"
|
||||||
|
|
||||||
|
# 解压二进制文件
|
||||||
|
echo "📂 Extracting binary..."
|
||||||
|
tar -xzf "${TARGZ_FILE}" -C "${PKG_DIR}/opt/xxxig-proxy"
|
||||||
|
|
||||||
|
# 生成 control 文件
|
||||||
|
echo "📝 Generating control file..."
|
||||||
|
sed -e "s/{{VERSION}}/${DEB_VERSION}/" \
|
||||||
|
-e "s/{{ARCH}}/${DEB_ARCH}/" \
|
||||||
|
debian/control.template > "${PKG_DIR}/DEBIAN/control"
|
||||||
|
|
||||||
|
# 复制维护脚本
|
||||||
|
echo "📋 Copying maintainer scripts..."
|
||||||
|
cp debian/postinst "${PKG_DIR}/DEBIAN/postinst"
|
||||||
|
cp debian/prerm "${PKG_DIR}/DEBIAN/prerm"
|
||||||
|
cp debian/postrm "${PKG_DIR}/DEBIAN/postrm"
|
||||||
|
chmod 755 "${PKG_DIR}/DEBIAN/postinst"
|
||||||
|
chmod 755 "${PKG_DIR}/DEBIAN/prerm"
|
||||||
|
chmod 755 "${PKG_DIR}/DEBIAN/postrm"
|
||||||
|
|
||||||
|
# 复制 systemd service 文件
|
||||||
|
echo "🔧 Installing systemd service..."
|
||||||
|
cp debian/xxxig-proxy.service "${PKG_DIR}/lib/systemd/system/"
|
||||||
|
|
||||||
|
# 设置权限
|
||||||
|
chmod 755 "${PKG_DIR}/opt/xxxig-proxy/xxxig-proxy"
|
||||||
|
chmod 644 "${PKG_DIR}/opt/xxxig-proxy/config.json"
|
||||||
|
chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-proxy.service"
|
||||||
|
|
||||||
|
# 构建 deb 包
|
||||||
|
echo "🔨 Building package..."
|
||||||
|
dpkg-deb --build --root-owner-group "${PKG_DIR}" "${DEB_FILE}"
|
||||||
|
|
||||||
|
# 检查包
|
||||||
|
echo "✅ Package built successfully!"
|
||||||
|
echo "📦 Package: $(pwd)/${DEB_FILE}"
|
||||||
|
echo "📊 Package info:"
|
||||||
|
dpkg-deb --info "${DEB_FILE}"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "🎉 Done!"
|
||||||
Vendored
+16
@@ -0,0 +1,16 @@
|
|||||||
|
Package: xxxig-proxy
|
||||||
|
Version: {{VERSION}}
|
||||||
|
Section: net
|
||||||
|
Priority: optional
|
||||||
|
Architecture: {{ARCH}}
|
||||||
|
Depends: libc6 (>= 2.31)
|
||||||
|
Maintainer: XXXig Team <noreply@example.com>
|
||||||
|
Homepage: https://github.com/wangdefaa/xxxig-proxy
|
||||||
|
Description: Cryptocurrency mining proxy
|
||||||
|
XXXig Proxy is a customized build of xmrig-proxy,
|
||||||
|
a cryptocurrency mining proxy server.
|
||||||
|
.
|
||||||
|
This package includes:
|
||||||
|
- The xxxig-proxy binary
|
||||||
|
- Systemd service configuration
|
||||||
|
- Default configuration file
|
||||||
Vendored
+61
@@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Create user and group if they don't exist
|
||||||
|
if ! getent group xxxig-proxy >/dev/null; then
|
||||||
|
addgroup --system xxxig-proxy
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! getent passwd xxxig-proxy >/dev/null; then
|
||||||
|
adduser --system --ingroup xxxig-proxy --no-create-home \
|
||||||
|
--home /opt/xxxig-proxy --shell /usr/sbin/nologin \
|
||||||
|
--gecos "XXXig Proxy Service" xxxig-proxy
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create log directory
|
||||||
|
mkdir -p /var/log/xxxig-proxy
|
||||||
|
chown xxxig-proxy:xxxig-proxy /var/log/xxxig-proxy
|
||||||
|
chmod 750 /var/log/xxxig-proxy
|
||||||
|
|
||||||
|
# Create config directory
|
||||||
|
mkdir -p /etc/xxxig-proxy
|
||||||
|
|
||||||
|
# Copy default config if it doesn't exist
|
||||||
|
if [ ! -f /etc/xxxig-proxy/config.json ]; then
|
||||||
|
cp /opt/xxxig-proxy/config.json /etc/xxxig-proxy/config.json
|
||||||
|
chown xxxig-proxy:xxxig-proxy /etc/xxxig-proxy/config.json
|
||||||
|
chmod 640 /etc/xxxig-proxy/config.json
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set permissions:目录与二进制 755,配置等数据文件 644
|
||||||
|
chown -R root:root /opt/xxxig-proxy
|
||||||
|
find /opt/xxxig-proxy -type d -exec chmod 755 {} +
|
||||||
|
find /opt/xxxig-proxy -type f -exec chmod 644 {} +
|
||||||
|
chmod 755 /opt/xxxig-proxy/xxxig-proxy
|
||||||
|
|
||||||
|
# Reload systemd
|
||||||
|
if [ -d /run/systemd/system ]; then
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
# 升级时重启正在运行的服务以加载新二进制;try-restart 不会启动未运行的服务,
|
||||||
|
# 故首次安装仍保持"不自动启动"语义(默认上游为 localhost,需用户改配置后再启用)
|
||||||
|
systemctl try-restart xxxig-proxy.service 2>/dev/null || true
|
||||||
|
|
||||||
|
# Note: Service is NOT auto-enabled or auto-started
|
||||||
|
# systemctl enable xxxig-proxy.service
|
||||||
|
# systemctl start xxxig-proxy.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "✅ XXXig Proxy installed successfully!"
|
||||||
|
echo ""
|
||||||
|
echo "📁 Important paths:"
|
||||||
|
echo " Config files: /etc/xxxig-proxy/config.json"
|
||||||
|
echo " Log directory: /var/log/xxxig-proxy"
|
||||||
|
echo " Binaries: /opt/xxxig-proxy/xxxig-proxy"
|
||||||
|
echo " Systemd services: xxxig-proxy.service"
|
||||||
|
echo ""
|
||||||
|
echo "💡 Tip: Your config files will NOT be overwritten during package upgrades."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
exit 0
|
||||||
Vendored
+30
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
purge)
|
||||||
|
# Remove log directory
|
||||||
|
rm -rf /var/log/xxxig-proxy
|
||||||
|
|
||||||
|
# Remove config directory
|
||||||
|
rm -rf /etc/xxxig-proxy
|
||||||
|
|
||||||
|
# Remove user and group
|
||||||
|
if getent passwd xxxig-proxy >/dev/null; then
|
||||||
|
deluser --system xxxig-proxy 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if getent group xxxig-proxy >/dev/null; then
|
||||||
|
delgroup --system xxxig-proxy 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||||
|
# Reload systemd
|
||||||
|
if [ -d /run/systemd/system ]; then
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
Vendored
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Stop service before removal
|
||||||
|
if [ -d /run/systemd/system ]; then
|
||||||
|
if systemctl is-active xxxig-proxy.service >/dev/null 2>&1; then
|
||||||
|
systemctl stop xxxig-proxy.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
if systemctl is-enabled xxxig-proxy.service >/dev/null 2>&1; then
|
||||||
|
systemctl disable xxxig-proxy.service
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
Vendored
+39
@@ -0,0 +1,39 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XXXig Proxy Service
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
|
||||||
|
# 工作目录
|
||||||
|
WorkingDirectory=/opt/xxxig-proxy
|
||||||
|
|
||||||
|
# 执行命令
|
||||||
|
ExecStart=/opt/xxxig-proxy/xxxig-proxy --config=/etc/xxxig-proxy/config.json --log-file=/var/log/xxxig-proxy/proxy.log --access-log-file=/var/log/xxxig-proxy/access.log
|
||||||
|
|
||||||
|
# 重启策略
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
# 用户和组
|
||||||
|
User=xxxig-proxy
|
||||||
|
Group=xxxig-proxy
|
||||||
|
|
||||||
|
# 安全设置
|
||||||
|
NoNewPrivileges=true
|
||||||
|
PrivateTmp=true
|
||||||
|
ProtectSystem=strict
|
||||||
|
ProtectHome=true
|
||||||
|
ReadWritePaths=/var/log/xxxig-proxy
|
||||||
|
|
||||||
|
# 日志设置
|
||||||
|
StandardOutput=journal
|
||||||
|
StandardError=journal
|
||||||
|
SyslogIdentifier=xxxig-proxy
|
||||||
|
|
||||||
|
# 资源限制
|
||||||
|
LimitNOFILE=65535
|
||||||
|
LimitNPROC=4096
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
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 XXXIG_PROXY_VERSION
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG BUILDPLATFORM
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
|
||||||
|
RUN git clone --recursive https://github.com/wangdefaa/xxxig-proxy.git && \
|
||||||
|
cd xxxig-proxy && \
|
||||||
|
git checkout ${XXXIG_PROXY_VERSION}
|
||||||
|
|
||||||
|
WORKDIR /xxxig-proxy
|
||||||
|
|
||||||
|
# 根据目标架构优化编译
|
||||||
|
RUN mkdir build && cd build && \
|
||||||
|
if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
||||||
|
MAKE_JOBS="-j2"; \
|
||||||
|
else \
|
||||||
|
MAKE_JOBS="-j$(nproc)"; \
|
||||||
|
fi && \
|
||||||
|
echo "Building with parallel jobs: $MAKE_JOBS (cross-compile: $([ "$BUILDPLATFORM" != "$TARGETPLATFORM" ] && echo yes || echo no))" && \
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=Release && \
|
||||||
|
make $MAKE_JOBS
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
COPY --from=build /xxxig-proxy/build/xxxig-proxy /linux_${TARGETARCH}/xxxig-proxy
|
||||||
|
COPY --from=build /xxxig-proxy/src/config.json /linux_${TARGETARCH}/config.json
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# 使用 Ubuntu 20.04 作为基础镜像(glibc 2.31,兼容更老系统)
|
||||||
|
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 \
|
||||||
|
openssl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
FROM base AS build
|
||||||
|
|
||||||
|
ARG XXXIG_PROXY_VERSION
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG BUILDPLATFORM
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
|
||||||
|
RUN git clone --recursive https://github.com/wangdefaa/xxxig-proxy.git && \
|
||||||
|
cd xxxig-proxy && \
|
||||||
|
git checkout ${XXXIG_PROXY_VERSION}
|
||||||
|
|
||||||
|
WORKDIR /xxxig-proxy
|
||||||
|
|
||||||
|
# 根据目标架构优化编译
|
||||||
|
RUN mkdir build && cd build && \
|
||||||
|
if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
||||||
|
MAKE_JOBS="-j2"; \
|
||||||
|
else \
|
||||||
|
MAKE_JOBS="-j$(nproc)"; \
|
||||||
|
fi && \
|
||||||
|
echo "Building with parallel jobs: $MAKE_JOBS (cross-compile: $([ "$BUILDPLATFORM" != "$TARGETPLATFORM" ] && echo yes || echo no))" && \
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=Release && \
|
||||||
|
make $MAKE_JOBS
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
COPY --from=build /xxxig-proxy/build/xxxig-proxy /linux_${TARGETARCH}/xxxig-proxy
|
||||||
|
COPY --from=build /xxxig-proxy/src/config.json /linux_${TARGETARCH}/config.json
|
||||||
Reference in New Issue
Block a user