This commit is contained in:
Kelorastus
2026-09-30 11:24:46 +02:00
parent d780c12b71
commit df2f30af17
+55 -19
View File
@@ -155,44 +155,65 @@ pub fn run_release(
sudo: &str,
) -> Result<PathBuf, String> {
let scripts = mcp_repo.join("scripts");
let mut ps = String::new();
ps.push_str("$ErrorActionPreference = 'Stop'
");
ps.push_str("$pw = $env:ODIAN_NODE_SUDO
");
ps.push_str("$env:ODIAN_NODE_SUDO = $null
"); // out of the environment the scripts inherit
ps.push_str(&format!(
let log = work_dir.join("release.log");
let mut body = String::new();
body.push_str(&format!(
"Write-Host '=== ODIAN pack {pack_version} ===' -ForegroundColor Cyan
& '{}' -Version '{pack_version}' -NodeSudoPw $pw
if ($LASTEXITCODE -notin 0,2) {{ Write-Host 'the pack step failed' -ForegroundColor Red; pause; exit 1 }}
if ($LASTEXITCODE -eq 2) {{ Write-Host 'pack: nothing to release' -ForegroundColor Yellow }}
elseif ($LASTEXITCODE -ne 0) {{ throw 'the pack step failed' }}
",
scripts.join("release_pack.ps1").display()
));
if let Some(v) = launcher_version {
ps.push_str(&format!(
body.push_str(&format!(
"Write-Host '=== Launcher {v} ===' -ForegroundColor Cyan
& '{}' -Version '{v}' -SiteUrl 'https://engine.odian.fr/dhp' -McpUrl 'https://engine.odian.fr' -AiUrl 'https://engine.odian.fr' -SiteName 'ODIAN test DHP' -Publish
if ($LASTEXITCODE -ne 0) {{ Write-Host 'the launcher step failed' -ForegroundColor Red; pause; exit 1 }}
if ($LASTEXITCODE -ne 0) {{ throw 'the launcher step failed' }}
",
scripts.join("package_launcher.ps1").display()
));
}
if with_api {
ps.push_str(&format!(
// It ships with the release skill rather than the repo, so look there when the repo
// has no copy. A missing script used to fail the same way a broken one does.
let api = api_script(&scripts).ok_or(
"deploy-api.ps1 is neither in the repo's scripts nor in the release skill: the API cannot be rolled.",
)?;
body.push_str(&format!(
"Write-Host '=== Engine API ===' -ForegroundColor Cyan
& '{}' -NodeSudoPw $pw
if ($LASTEXITCODE -notin 0,3) {{ Write-Host 'the API step failed' -ForegroundColor Red; pause; exit 1 }}
if ($LASTEXITCODE -notin 0,3) {{ throw 'the API step failed' }}
",
// The api script lives with the release skill, beside the others when it is there.
scripts.join("deploy-api.ps1").display()
api.display()
));
}
ps.push_str("Write-Host ''
Write-Host 'Release finished.' -ForegroundColor Green
pause
");
// Everything inside try/finally, and everything recorded. A step that throws used to
// take the window with it - the release simply vanished, with nothing to read.
let ps = format!(
"$ErrorActionPreference = 'Stop'
$pw = $env:ODIAN_NODE_SUDO
$env:ODIAN_NODE_SUDO = $null
Start-Transcript -Path '{}' -Force | Out-Null
try {{
{}
Write-Host ''
Write-Host 'Release finished.' -ForegroundColor Green
}} catch {{
Write-Host ''
Write-Host \"FAILED: $_\" -ForegroundColor Red
}} finally {{
Stop-Transcript | Out-Null
Write-Host ''
Write-Host 'Log: {}'
pause
}}
",
log.display(),
body,
log.display()
);
std::fs::create_dir_all(work_dir).map_err(|e| format!("cannot use {}: {e}", work_dir.display()))?;
let file = work_dir.join("release.ps1");
@@ -210,6 +231,21 @@ pause
Ok(file)
}
/// Where the Engine API deploy script is: beside the other release scripts, or in the
/// release skill that carries it.
fn api_script(scripts: &Path) -> Option<PathBuf> {
let here = scripts.join("deploy-api.ps1");
if here.is_file() {
return Some(here);
}
let skill = dirs_home()?.join(".claude/skills/odian-api-release/scripts/deploy-api.ps1");
skill.is_file().then_some(skill)
}
fn dirs_home() -> Option<PathBuf> {
std::env::var_os("USERPROFILE").or_else(|| std::env::var_os("HOME")).map(PathBuf::from)
}
/// `0.71.0` -> `0.72.0`. A pack release is a minor; the patch place is not used.
pub fn next_pack(live: &str) -> Option<String> {
let p: Vec<u64> = live.split('.').map_while(|x| x.parse().ok()).collect();