-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_release.sh
More file actions
184 lines (159 loc) · 6.74 KB
/
Copy pathbuild_release.sh
File metadata and controls
184 lines (159 loc) · 6.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
# AgenticSRE release builder.
#
# Produces a self-contained release directory and tarball for container
# deployment. The package contains:
# - agenticsre-image.tar.gz: Docker image built from the current workspace
# - agenticsre-source.tar.gz: source snapshot used for the image
# - docker-compose.yaml, deploy_docker.sh, configs, .env.example
# - SHA256SUMS and MANIFEST.txt for auditability
set -euo pipefail
IMAGE_NAME="${IMAGE_NAME:-agenticsre}"
IMAGE_TAG="${IMAGE_TAG:-latest}"
IMAGE_REF="${IMAGE_NAME}:${IMAGE_TAG}"
DOCKER_PLATFORM="${DOCKER_PLATFORM:-linux/amd64}"
IMAGE_TAR="agenticsre-image.tar.gz"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "${SCRIPT_DIR}"
RELEASE_DATE="$(date +%Y%m%d)"
RELEASE_NAME="${RELEASE_NAME:-agenticsre-release-${RELEASE_DATE}}"
STAGING_DIR="${SCRIPT_DIR}/release/${RELEASE_NAME}"
RELEASE_TAR="${SCRIPT_DIR}/${RELEASE_NAME}.tar.gz"
SOURCE_TAR="agenticsre-source.tar.gz"
GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)"
GIT_COMMIT="$(git rev-parse --short HEAD 2>/dev/null || echo unknown)"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
info() { echo -e "${GREEN}[INFO]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*"; exit 1; }
command -v docker >/dev/null 2>&1 || error "Docker not found."
command -v tar >/dev/null 2>&1 || error "tar not found."
if docker compose version >/dev/null 2>&1; then
COMPOSE_CMD="docker compose"
elif command -v docker-compose >/dev/null 2>&1; then
COMPOSE_CMD="docker-compose"
else
error "docker compose not found."
fi
info "Building ${IMAGE_REF} for ${DOCKER_PLATFORM} from current workspace..."
docker build --platform "${DOCKER_PLATFORM}" -t "${IMAGE_REF}" .
info "Creating release staging directory..."
rm -rf "${STAGING_DIR}"
mkdir -p "${STAGING_DIR}"
info "Saving Docker image..."
docker save "${IMAGE_REF}" | gzip > "${STAGING_DIR}/${IMAGE_TAR}"
info "Creating source snapshot..."
tar --exclude='.venv' \
--exclude='__pycache__' \
--exclude='*.pyc' \
--exclude='.git' \
--exclude='.claude' \
--exclude='.pycache_tmp' \
--exclude='.DS_Store' \
--exclude='*/.DS_Store' \
--exclude='data' \
--exclude='logs' \
--exclude='.env' \
--exclude='docker-compose.yaml' \
--exclude='*.tar' \
--exclude='*.tar.gz' \
--exclude='*.tgz' \
--exclude='release' \
--exclude='hermes-agent' \
--exclude='运维多智能体协作技术研究项目SOW.docx' \
--exclude='*SOW*' \
--exclude='*sow*' \
--exclude='eval/results/*' \
--exclude="${RELEASE_NAME}.tar.gz" \
-czf "${STAGING_DIR}/${SOURCE_TAR}" .
info "Copying deployment files..."
cp Dockerfile .dockerignore docker-compose.release.yaml deploy_docker.sh build_release.sh build_release_from_remote_image.sh package_release_from_image.sh README.md USER_MANUAL.md AGENTS.md requirements.txt .env.example "${STAGING_DIR}/"
cp docker-compose.release.yaml "${STAGING_DIR}/docker-compose.yaml"
cp main.py mcp_server.py "${STAGING_DIR}/"
cp -R agents "${STAGING_DIR}/agents"
cp -R configs "${STAGING_DIR}/configs"
cp -R eval "${STAGING_DIR}/eval"
cp -R memory "${STAGING_DIR}/memory"
cp -R observability "${STAGING_DIR}/observability"
cp -R orchestrator "${STAGING_DIR}/orchestrator"
cp -R paradigms "${STAGING_DIR}/paradigms"
cp -R tools "${STAGING_DIR}/tools"
cp -R web_app "${STAGING_DIR}/web_app"
cp -R tests "${STAGING_DIR}/tests"
cp -R doc "${STAGING_DIR}/doc"
cp -R report "${STAGING_DIR}/report"
cp -R 测试 "${STAGING_DIR}/测试"
cp -R vllm_fault_injector "${STAGING_DIR}/vllm_fault_injector"
find "${STAGING_DIR}" -type d -name __pycache__ -prune -exec rm -rf {} +
rm -rf "${STAGING_DIR}/eval/results"
mkdir -p "${STAGING_DIR}/eval/results"
touch "${STAGING_DIR}/eval/results/.gitkeep"
find "${STAGING_DIR}" -name .DS_Store -delete
find "${STAGING_DIR}" -name '._*' -delete
chmod +x "${STAGING_DIR}/deploy_docker.sh" "${STAGING_DIR}/build_release.sh" "${STAGING_DIR}/build_release_from_remote_image.sh" "${STAGING_DIR}/package_release_from_image.sh"
cat > "${STAGING_DIR}/RELEASE_NOTES.md" <<EOF
# AgenticSRE Release ${RELEASE_DATE}
This package was built from the current workspace and is intended for container deployment.
## Contents
- \`${IMAGE_TAR}\`: prebuilt Docker image \`${IMAGE_REF}\`
- \`${SOURCE_TAR}\`: source snapshot used to build the image
- Source snapshot: \`${GIT_BRANCH}@${GIT_COMMIT}\`
- Docker platform: \`${DOCKER_PLATFORM}\`
- \`docker-compose.yaml\`: offline runtime Compose definition (no build section)
- \`deploy_docker.sh\`: one-command offline deployment helper
- Runtime source directories are included at package top level for bind mounts
- \`configs/\`: runtime configuration templates
- \`doc/\`, \`report/\`, \`测试/\`, \`tests/\`: local project documentation and test materials
- \`.env.example\`: environment variable template
- \`SHA256SUMS\`: checksum file for package verification
- \`MANIFEST.txt\`: file list inside this release package
## Deploy
\`\`\`bash
tar xzf ${RELEASE_NAME}.tar.gz
cd ${RELEASE_NAME}
./deploy_docker.sh
\`\`\`
The release deploy script creates \`.env\` from \`.env.example\` when needed,
loads \`${IMAGE_TAR}\`, verifies the bundled runtime, and starts Compose with
\`--no-build\`. It should not download apt/pip dependencies during deployment.
Use \`./deploy_docker.sh --build\` only when an online rebuild is intentional.
Dashboard: http://localhost:8080
Health: http://localhost:8080/api/health
EOF
info "Writing manifest and checksums..."
(
cd "${STAGING_DIR}"
find . -type f | sort > MANIFEST.txt
: > SHA256SUMS
if command -v shasum >/dev/null 2>&1; then
find . -type f ! -name SHA256SUMS | sort | while IFS= read -r file; do
shasum -a 256 "$file" >> SHA256SUMS
done
else
find . -type f ! -name SHA256SUMS | sort | while IFS= read -r file; do
sha256sum "$file" >> SHA256SUMS
done
fi
)
info "Creating release tarball..."
rm -f "${RELEASE_TAR}"
tar -czf "${RELEASE_TAR}" -C "${SCRIPT_DIR}/release" "${RELEASE_NAME}"
RELEASE_SIZE="$(du -h "${RELEASE_TAR}" | awk '{print $1}')"
IMAGE_SIZE="$(du -h "${STAGING_DIR}/${IMAGE_TAR}" | awk '{print $1}')"
SOURCE_SIZE="$(du -h "${STAGING_DIR}/${SOURCE_TAR}" | awk '{print $1}')"
echo ""
echo "═══════════════════════════════════════════"
info "Release package built."
echo " File: ${RELEASE_TAR}"
echo " Size: ${RELEASE_SIZE}"
echo " Image: ${IMAGE_SIZE}"
echo " Source: ${SOURCE_SIZE}"
echo ""
echo " Deploy:"
echo " tar xzf ${RELEASE_NAME}.tar.gz"
echo " cd ${RELEASE_NAME}"
echo " ./deploy_docker.sh"
echo "═══════════════════════════════════════════"