name: Release on: push: tags: ["*"] env: DOCKER_BUILDKIT: "1" BUILDX_NO_DEFAULT_ATTESTATIONS: "1" BUILDKIT_PROGRESS: plain PRODUCT_NAME: p2pool jobs: build: 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: 校验 tag 与源码版本 env: TAG: ${{ gitea.ref_name }} run: | VERSION=$(tr -d '\r\n' < VERSION) TAG_VERSION="${TAG#v}" [[ "${TAG_VERSION}" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?$ ]] [ "${TAG_VERSION}" = "${VERSION}" ] || { echo "tag ${TAG_VERSION} 与 VERSION ${VERSION} 不一致" exit 1 } echo "VERSION=${VERSION}" >> "$GITHUB_ENV" - 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: | 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 }}" TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-linux-static-${VERSION}.tar.gz" test -x "${DIR}/p2pool" tar -czf "${TARGZ}" -C "${DIR}" . TEST_DIR=$(mktemp -d) trap 'rm -rf "${TEST_DIR}"' EXIT tar -xzf "${TARGZ}" -C "${TEST_DIR}" "${TEST_DIR}/p2pool" --version "${TEST_DIR}/p2pool" --help >/dev/null "${TEST_DIR}/p2pool" --test LDD_OUT=$(ldd "${TEST_DIR}/p2pool" 2>&1 || true) grep -qE 'statically linked|not a dynamic executable' <<<"${LDD_OUT}" - name: 构建 Debian 包 run: | if ! command -v dpkg-deb >/dev/null; then sudo apt-get update sudo apt-get install -y dpkg-dev fi TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-linux-static-${VERSION}.tar.gz" ./debian/build-deb.sh "${{ matrix.arch }}" "${VERSION}" "${TARGZ}" DEB="${PRODUCT_NAME}_${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}" - uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4 with: name: packages-${{ matrix.arch }} path: | *.tar.gz *.deb if-no-files-found: error retention-days: 1 - name: 清理 Buildx if: always() run: docker buildx rm "${BUILDER}" || true release: needs: build runs-on: ubuntu-latest-amd64 steps: - uses: actions/checkout@v4 - uses: https://github.com/ChristopherHX/gitea-download-artifact@v4 with: pattern: packages-* path: ./packages merge-multiple: true - name: 校验发布文件并生成校验和 env: TAG: ${{ gitea.ref_name }} run: | VERSION=$(tr -d '\r\n' < VERSION) TAG_VERSION="${TAG#v}" [ "${TAG_VERSION}" = "${VERSION}" ] for arch in amd64 arm64; do test -f "packages/${PRODUCT_NAME}-${arch}-linux-static-${VERSION}.tar.gz" test -f "packages/${PRODUCT_NAME}_${VERSION}_${arch}.deb" done (cd packages && sha256sum *.tar.gz *.deb > SHA256SUMS) REGISTRY=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||') echo "VERSION=${VERSION}" >> "$GITHUB_ENV" echo "REGISTRY=${REGISTRY}" >> "$GITHUB_ENV" - name: 上传 Generic 和 Debian 软件包 env: TOKEN: ${{ secrets.BUILD_TOKEN }} run: | OWNER="${{ gitea.repository_owner }}" for file in packages/*.tar.gz; do name=$(basename "${file}") curl -fsSL -X PUT \ -H "Authorization: token ${TOKEN}" \ --upload-file "${file}" \ "https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${VERSION}/${name}" done for file in packages/*.deb; do curl -fsSL -X PUT \ -H "Authorization: token ${TOKEN}" \ --upload-file "${file}" \ "https://${REGISTRY}/api/packages/${OWNER}/debian/pool/stable/main/upload" done - name: 生成 Release 描述 run: | cat > release-notes.md <