重构为 musl 纯静态打包,配置迁 /etc,对齐三项目
Build and Release / release (push) Has been skipped
Build and Release / build-and-test (amd64) (push) Failing after 3m8s
Build and Release / build-and-test (arm64) (push) Failing after 7m31s

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 14:55:12 +08:00
co-authored by Claude Opus 4.8
parent b222b802bf
commit 3b024fdc10
14 changed files with 307 additions and 312 deletions
+40 -17
View File
@@ -9,7 +9,7 @@ on:
env:
DOCKER_BUILDKIT: "1"
PRODUCT_NAME: "p2pool"
PACKAGE_VERSION: "v4.15.1"
PACKAGE_VERSION: "4.15.1"
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
jobs:
@@ -18,7 +18,6 @@ jobs:
strategy:
matrix:
arch: [amd64, arm64]
distro: [ubuntu, alpine]
steps:
- uses: actions/checkout@v4
@@ -35,11 +34,10 @@ jobs:
- name: Build binaries
run: |
P2POOL_VERSION=${PACKAGE_VERSION}
PLATFORM="linux/${{ matrix.arch }}"
P2POOL_VERSION="v${PACKAGE_VERSION}" # 上游 p2pool git tag 带 v 前缀,需补回
echo "🏗️ Building ${PLATFORM} on native ${{ matrix.arch }} runner"
echo "📦 Distribution: ${{ matrix.distro }}"
echo "🏗️ Building ${PLATFORM} on native ${{ matrix.arch }} runner (musl 纯静态)"
# 设置 BuildKit 优化参数
export BUILDKIT_PROGRESS=plain
@@ -48,7 +46,7 @@ jobs:
--platform ${PLATFORM} \
--build-arg P2POOL_VERSION=${P2POOL_VERSION} \
--output type=local,dest=./output \
-f docker/Dockerfile.${{ matrix.distro }} .
-f docker/Dockerfile .
- name: Package and test
run: |
@@ -59,24 +57,25 @@ jobs:
exit 1
fi
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-${{ matrix.distro }}-${PACKAGE_VERSION}.tar.gz"
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-linux-static-${PACKAGE_VERSION}.tar.gz"
tar -czf "${TARGZ}" -C "$DIR" .
echo "📦 Created package: ${TARGZ}"
ls -lh "${TARGZ}"
# 快速验证
# 快速验证--help 冒烟 + ldd 纯静态校验(musl 静态可在 glibc runner 直接跑)
mkdir -p test && tar -xzf "${TARGZ}" -C test
test/p2pool --help 2>/dev/null || echo "⚠️ Help displayed"
test/p2pool --help >/dev/null 2>&1 && echo "✅ --help OK" || echo "⚠️ --help 退出非0"
ldd test/p2pool 2>&1 | grep -qE 'statically linked|not a dynamic executable' \
&& echo "✅ fully-static(无动态依赖,跨发行版)" || { echo "⚠️ 非纯静态:"; ldd test/p2pool; }
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"
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-linux-static-${PACKAGE_VERSION}.tar.gz"
echo "📦 Building Debian package for ${{ matrix.arch }}..."
chmod +x debian/build-deb.sh
@@ -86,7 +85,7 @@ jobs:
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
with:
name: binaries-${{ matrix.arch }}-${{ matrix.distro }}
name: binaries-${{ matrix.arch }}
path: |
*.tar.gz
*.deb
@@ -114,12 +113,13 @@ jobs:
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: ${TAG}"
echo " Version: ${VERSION}"
# 上传所有 tar.gz 包到 Generic Package Registry
for file in *.tar.gz; do
@@ -128,7 +128,7 @@ jobs:
curl -fsSL -X PUT \
-H "Authorization: token ${TOKEN}" \
--upload-file "$file" \
"https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${TAG}/$file" || {
"https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${VERSION}/$file" || {
echo "❌ 上传失败: $file"
exit 1
}
@@ -151,12 +151,35 @@ jobs:
}
done
# 生成 Release JSON payload
# 生成 Release 描述
echo ""
echo "📝 生成 Release..."
export REGISTRY OWNER TAG
RELEASE_DATA=$(python3 -c 'import json,glob,os;r=os.environ["REGISTRY"];o=os.environ["OWNER"];p=os.environ["PRODUCT_NAME"];t=os.environ["TAG"];b=["## Release "+t,"","### 📥 下载方式","","#### 方式 1: 直接下载(推荐)","","点击下面 **Assets** 部分的文件名直接下载。","","#### 方式 2: Generic Package Registry",""]+[f"- [`{f}`](https://{r}/api/packages/{o}/generic/{p}/{t}/{f})" for f in sorted(glob.glob("*.tar.gz"))]+["","#### 方式 3: Debian Repository","","```bash","# Download GPG key",f"sudo curl https://{r}/api/packages/{o}/debian/repository.key -o /etc/apt/keyrings/gitea-{o}.asc","","# Add repository",f"echo \"deb [signed-by=/etc/apt/keyrings/gitea-{o}.asc] https://{r}/api/packages/{o}/debian stable main\" | sudo tee -a /etc/apt/sources.list.d/{o}.list","","# Update and install","sudo apt-get update",f"sudo apt-get install {p}","```"];print(json.dumps({"tag_name":t,"name":f"Release {t}","body":"\n".join(b),"draft":False,"prerelease":False}))')
# 拼接 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 ${PRODUCT_NAME}
\`\`\`
### 📦 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 ""