更新 CI/CD 流水线,拆分为独立的构建和发布流程,添加版本控制,更新至 4.18
CI / validate (push) Successful in 6s
CI / build (amd64) (push) Successful in 4m11s
CI / build (arm64) (push) Successful in 22m29s
Release / build (amd64) (push) Successful in 4m23s
Release / build (arm64) (push) Successful in 22m17s
Release / release (push) Successful in 37s
CI / validate (push) Successful in 6s
CI / build (amd64) (push) Successful in 4m11s
CI / build (arm64) (push) Successful in 22m29s
Release / build (amd64) (push) Successful in 4m23s
Release / build (arm64) (push) Successful in 22m17s
Release / release (push) Successful in 37s
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
name: CI
|
||||
|
||||
# 分支推送只做校验和原生构建;tag 发布由 release.yml 独立处理。
|
||||
on:
|
||||
push:
|
||||
branches: ["**"]
|
||||
|
||||
env:
|
||||
DOCKER_BUILDKIT: "1"
|
||||
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
|
||||
BUILDKIT_PROGRESS: plain
|
||||
|
||||
jobs:
|
||||
validate:
|
||||
runs-on: ubuntu-latest-amd64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: 校验版本、配置和脚本语法
|
||||
run: |
|
||||
VERSION=$(tr -d '\r\n' < VERSION)
|
||||
[[ "${VERSION}" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]
|
||||
test -s conf/params.conf.example
|
||||
bash -n debian/build-deb.sh
|
||||
sh -n debian/postinst debian/prerm debian/postrm
|
||||
|
||||
build:
|
||||
needs: validate
|
||||
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest-amd64' || 'ubuntu-latest-arm64' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [amd64, arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: 准备原生 Buildx
|
||||
run: |
|
||||
BUILDER=$(docker buildx create --use \
|
||||
--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)
|
||||
echo "BUILDER=${BUILDER}" >> "$GITHUB_ENV"
|
||||
docker buildx inspect --bootstrap
|
||||
|
||||
- name: 构建 ${{ matrix.arch }} 二进制
|
||||
run: |
|
||||
VERSION=$(tr -d '\r\n' < VERSION)
|
||||
docker buildx build --pull \
|
||||
--platform "linux/${{ matrix.arch }}" \
|
||||
--build-arg "P2POOL_VERSION=v${VERSION}" \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile .
|
||||
|
||||
- name: 冒烟测试
|
||||
run: |
|
||||
DIR="./output/linux_${{ matrix.arch }}"
|
||||
test -x "${DIR}/p2pool"
|
||||
"${DIR}/p2pool" --version
|
||||
"${DIR}/p2pool" --help >/dev/null
|
||||
"${DIR}/p2pool" --test
|
||||
LDD_OUT=$(ldd "${DIR}/p2pool" 2>&1 || true)
|
||||
grep -qE 'statically linked|not a dynamic executable' <<<"${LDD_OUT}"
|
||||
|
||||
- name: 验证 Debian 打包
|
||||
run: |
|
||||
VERSION=$(tr -d '\r\n' < VERSION)
|
||||
TARGZ="p2pool-${{ matrix.arch }}-linux-static-${VERSION}.tar.gz"
|
||||
tar -czf "${TARGZ}" -C "./output/linux_${{ matrix.arch }}" .
|
||||
if ! command -v dpkg-deb >/dev/null; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y dpkg-dev
|
||||
fi
|
||||
./debian/build-deb.sh "${{ matrix.arch }}" "${VERSION}" "${TARGZ}"
|
||||
DEB="p2pool_${VERSION}_${{ matrix.arch }}.deb"
|
||||
CONTENTS=$(dpkg-deb --contents "${DEB}")
|
||||
grep -Fq 'opt/p2pool/p2pool' <<<"${CONTENTS}"
|
||||
grep -Fq 'opt/p2pool/params.conf' <<<"${CONTENTS}"
|
||||
grep -Fq 'lib/systemd/system/p2pool.service' <<<"${CONTENTS}"
|
||||
|
||||
- name: 清理 Buildx
|
||||
if: always()
|
||||
run: docker buildx rm "${BUILDER}" || true
|
||||
Reference in New Issue
Block a user