feat(release):完成双 release 运维闭环
bat-rust / Build and test Rust (push) Canceled after 0s
bat-rust / Build and test Go API (push) Canceled after 0s

This commit is contained in:
2026-09-12 11:08:04 +08:00
parent 8a77502272
commit 8d57a63697
27 changed files with 3635 additions and 222 deletions
+33
View File
@@ -85,6 +85,7 @@ func (s *Server) handleAdminIndex(w http.ResponseWriter, r *http.Request) {
"/admin/control/translation-glossary-delete",
"/admin/control/localized-publish",
"/admin/control/localized-rollback",
"/admin/control/release-cleanup",
},
}
if r.Method == http.MethodHead {
@@ -144,6 +145,10 @@ func (s *Server) handleAdminControl(w http.ResponseWriter, r *http.Request) {
s.handleAdminLocalizedRollback(w, r)
return
}
if action == "release-cleanup" {
s.handleAdminReleaseCleanup(w, r)
return
}
request, ok := decodeAdminControlRequest(w, r)
if !ok {
return
@@ -619,6 +624,34 @@ func (s *Server) handleAdminLocalizedStatus(w http.ResponseWriter, r *http.Reque
writeNoStoreJSON(w, http.StatusOK, result)
}
func (s *Server) handleAdminReleaseCleanup(w http.ResponseWriter, r *http.Request) {
backend, ok := s.backend.(ReleaseBackend)
if !ok || backend == nil {
writeErrorJSON(w, http.StatusServiceUnavailable, "release_backend_unavailable", "Rust bat release backend is unavailable")
return
}
var params backendrpc.ReleaseCleanupParams
if !decodeAdminTranslationJSON(w, r, &params) {
return
}
if params.Execute && strings.TrimSpace(params.PlanID) == "" {
writeErrorJSON(w, http.StatusBadRequest, "invalid_release_cleanup_params", "execute cleanup requires plan_id from a dry run")
return
}
result, err := backend.ReleaseCleanup(r.Context(), params)
if err != nil {
s.writeControlBackendError(w, "release-cleanup", err)
return
}
writeNoStoreJSON(w, http.StatusAccepted, AdminControlResponse{
Service: "bat-api",
Action: "release-cleanup",
RPCMethod: "release.cleanup",
Status: "accepted",
Result: result,
})
}
func (s *Server) handleAdminDiagnostics(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet && r.Method != http.MethodHead {
writeErrorJSON(w, http.StatusMethodNotAllowed, "method_not_allowed", "method not allowed")