CI / validate (push) Successful in 5s
CI / build (amd64) (push) Successful in 3m38s
CI / build (arm64) (push) Successful in 8m39s
Release / build (amd64) (push) Successful in 3m35s
Release / build (arm64) (push) Successful in 8m58s
Release / release (push) Successful in 42s
- 新增 .gitea/workflows/ci.yml,包含版本校验、构建和冒烟测试 - 新增 .gitea/workflows/release.yml,处理 tag 发布,上传包到仓库并创建 Release - 更新 README.md 和 CLAUDE.md,描述新的 CI/CD 流程和版本号约定 - 修改 init.sh,增加对关键锚点的检查,确保源码结构一致性 - 更新 Dockerfile,使用 OpenSSL 3.0.21 和 unbound 1.25.1,确保与 Monero 版本一致 - 更新 build-deb.sh 示例,反映最新版本号 - 新增 VERSION 文件,统一版本管理
170 lines
6.0 KiB
YAML
170 lines
6.0 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags: ["*"]
|
|
|
|
env:
|
|
DOCKER_BUILDKIT: "1"
|
|
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
|
|
BUILDKIT_PROGRESS: plain
|
|
PRODUCT_NAME: mond
|
|
|
|
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]+\.[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 "MONERO_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}/mond"
|
|
tar -czf "${TARGZ}" -C "${DIR}" .
|
|
TEST_DIR=$(mktemp -d)
|
|
trap 'rm -rf "${TEST_DIR}"' EXIT
|
|
tar -xzf "${TARGZ}" -C "${TEST_DIR}"
|
|
"${TEST_DIR}/mond" --version
|
|
"${TEST_DIR}/mond" --help >/dev/null
|
|
LDD_OUT=$(ldd "${TEST_DIR}/mond" 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/mond/mond' <<<"${CONTENTS}"
|
|
grep -Fq 'opt/mond/params.conf' <<<"${CONTENTS}"
|
|
grep -Fq 'lib/systemd/system/mond.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 <<EOF
|
|
## Release ${VERSION}
|
|
|
|
上游版本:[Monero v${VERSION}](https://github.com/monero-project/monero/releases/tag/v${VERSION})
|
|
|
|
### Debian/Ubuntu 安装
|
|
|
|
\`\`\`bash
|
|
sudo curl https://${REGISTRY}/api/packages/${{ gitea.repository_owner }}/debian/repository.key -o /etc/apt/keyrings/gitea-${{ gitea.repository_owner }}.asc
|
|
echo "deb [signed-by=/etc/apt/keyrings/gitea-${{ gitea.repository_owner }}.asc] https://${REGISTRY}/api/packages/${{ gitea.repository_owner }}/debian stable main" | sudo tee /etc/apt/sources.list.d/${{ gitea.repository_owner }}.list
|
|
sudo apt-get update && sudo apt-get install mond
|
|
\`\`\`
|
|
|
|
发布附件包含 amd64、arm64 的 tar.gz、Debian 包和 SHA256SUMS。
|
|
EOF
|
|
|
|
- name: 创建或更新 Release 并上传附件
|
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
|
with:
|
|
token: ${{ secrets.BUILD_TOKEN }}
|
|
name: Release ${{ gitea.ref_name }}
|
|
body_path: release-notes.md
|
|
files: |
|
|
packages/*.tar.gz
|
|
packages/*.deb
|
|
packages/SHA256SUMS
|