Details (original message): Release 0.1.0: build pipeline from pinned dev combination, native deploy materials (systemd, install/rollback, sha256 verify), manifest snapshot.
60 lines
2.2 KiB
Bash
Executable File
60 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# Agent-System-Releases:从 Dev 仓固定提交构建发布(非容器;单二进制 + 原生部署物料)。
|
||
# 用法:scripts/build-release.sh <version> [dev-repo-URL-or-path]
|
||
# 产物:build/<version>/{agent-system, plugins/, manifest.json, agent-system-<version>.tar.gz}
|
||
set -euo pipefail
|
||
|
||
VERSION="${1:?用法: build-release.sh <version> [dev-repo]}"
|
||
DEV_REPO="${2:-ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/Agent-System-Dev.git}"
|
||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||
OUT="$ROOT/build/$VERSION"
|
||
WORK="$(mktemp -d)"
|
||
trap 'rm -rf "$WORK"' EXIT
|
||
|
||
echo "==> 克隆 Dev 仓(固定提交组合)"
|
||
git clone -q --recurse-submodules "$DEV_REPO" "$WORK/dev"
|
||
# 嵌套子模块(backend/deps)
|
||
cd "$WORK/dev" && git submodule update --init --recursive -q
|
||
DEV_SHA="$(git rev-parse HEAD)"
|
||
echo " dev @ $DEV_SHA"
|
||
|
||
echo "==> 构建(契约同步 → 前端 → embed → 静态链接单二进制)"
|
||
make build -s
|
||
test -x bin/agent-system
|
||
|
||
echo "==> 组装发布目录"
|
||
rm -rf "$OUT" && mkdir -p "$OUT"
|
||
cp bin/agent-system "$OUT/agent-system"
|
||
cp -r plugins "$OUT/plugins"
|
||
cp deploy/agent-system.service "$OUT/" 2>/dev/null || cp "$ROOT/deploy/agent-system.service" "$OUT/"
|
||
cp "$ROOT/deploy/install.sh" "$OUT/"
|
||
|
||
echo "==> 生成 manifest(gitlink 组合 + 制品摘要;从固定提交导出,不自引用)"
|
||
{
|
||
echo '{'
|
||
echo " \"version\": \"$VERSION\","
|
||
echo " \"devCommit\": \"$DEV_SHA\","
|
||
echo " \"builtAt\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\","
|
||
echo " \"components\": {"
|
||
first=1
|
||
while read -r sha path; do
|
||
test -n "$path" || continue
|
||
[ $first -eq 1 ] && first=0 || echo ','
|
||
printf ' "%s": "%s"' "$path" "$sha"
|
||
done < <(git submodule status | awk '{print $1, $2}')
|
||
echo ''
|
||
echo ' },'
|
||
echo " \"artifacts\": {"
|
||
echo " \"agent-system\": \"$(sha256sum "$OUT/agent-system" | cut -d' ' -f1)\""
|
||
echo ' },'
|
||
echo ' "deployment": "native-single-binary",'
|
||
echo ' "container": false'
|
||
echo '}'
|
||
} > "$OUT/manifest.json"
|
||
|
||
echo "==> 打包"
|
||
tar -czf "$OUT/agent-system-$VERSION.tar.gz" -C "$OUT" agent-system plugins manifest.json agent-system.service install.sh
|
||
|
||
echo "✓ 发布就绪:$OUT"
|
||
cat "$OUT/manifest.json"
|