Skip to content

Commit 2aa27b0

Browse files
authored
CI - Move the DLL updating code into a function (#4868)
# Description of Changes Just moving code into functions so it can be reused, no functional changes. # API and ABI breaking changes None. CI only. # Expected complexity level and risk 1 # Testing None --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent e2a74b5 commit 2aa27b0

1 file changed

Lines changed: 79 additions & 73 deletions

File tree

tools/ci/src/main.rs

Lines changed: 79 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,84 @@ fn tracked_rs_files_under(path: &str) -> Result<Vec<PathBuf>> {
300300
.collect())
301301
}
302302

303+
fn run_dlls() -> Result<()> {
304+
ensure_repo_root()?;
305+
306+
cmd!(
307+
"dotnet",
308+
"pack",
309+
"crates/bindings-csharp/BSATN.Runtime",
310+
"-c",
311+
"Release"
312+
)
313+
.run()?;
314+
cmd!("dotnet", "pack", "crates/bindings-csharp/Runtime", "-c", "Release").run()?;
315+
316+
let repo_root = env::current_dir()?;
317+
let bsatn_source = repo_root.join("crates/bindings-csharp/BSATN.Runtime/bin/Release");
318+
let runtime_source = repo_root.join("crates/bindings-csharp/Runtime/bin/Release");
319+
320+
let nuget_config_dir = tempfile::tempdir()?;
321+
let nuget_config_path = nuget_config_dir.path().join("nuget.config");
322+
let nuget_config_contents = format!(
323+
r#"<?xml version="1.0" encoding="utf-8"?>
324+
<configuration>
325+
<packageSources>
326+
<clear />
327+
<add key="Local SpacetimeDB.BSATN.Runtime" value="{}" />
328+
<add key="Local SpacetimeDB.Runtime" value="{}" />
329+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
330+
</packageSources>
331+
<packageSourceMapping>
332+
<packageSource key="Local SpacetimeDB.BSATN.Runtime">
333+
<package pattern="SpacetimeDB.BSATN.Runtime" />
334+
</packageSource>
335+
<packageSource key="Local SpacetimeDB.Runtime">
336+
<package pattern="SpacetimeDB.Runtime" />
337+
</packageSource>
338+
<packageSource key="nuget.org">
339+
<package pattern="*" />
340+
</packageSource>
341+
</packageSourceMapping>
342+
</configuration>
343+
"#,
344+
bsatn_source.display(),
345+
runtime_source.display(),
346+
);
347+
fs::write(&nuget_config_path, nuget_config_contents)?;
348+
349+
let nuget_config_path_str = nuget_config_path.to_string_lossy().to_string();
350+
351+
clear_restored_package_dirs("spacetimedb.bsatn.runtime")?;
352+
clear_restored_package_dirs("spacetimedb.runtime")?;
353+
354+
cmd!(
355+
"dotnet",
356+
"restore",
357+
"SpacetimeDB.ClientSDK.csproj",
358+
"--configfile",
359+
&nuget_config_path_str,
360+
)
361+
.dir("sdks/csharp")
362+
.run()?;
363+
364+
overlay_unity_meta_skeleton("spacetimedb.bsatn.runtime")?;
365+
overlay_unity_meta_skeleton("spacetimedb.runtime")?;
366+
367+
cmd!(
368+
"dotnet",
369+
"pack",
370+
"SpacetimeDB.ClientSDK.csproj",
371+
"-c",
372+
"Release",
373+
"--no-restore"
374+
)
375+
.dir("sdks/csharp")
376+
.run()?;
377+
378+
Ok(())
379+
}
380+
303381
fn main() -> Result<()> {
304382
env_logger::init();
305383

@@ -463,79 +541,7 @@ fn main() -> Result<()> {
463541
}
464542

465543
Some(CiCmd::Dlls) => {
466-
ensure_repo_root()?;
467-
468-
cmd!(
469-
"dotnet",
470-
"pack",
471-
"crates/bindings-csharp/BSATN.Runtime",
472-
"-c",
473-
"Release"
474-
)
475-
.run()?;
476-
cmd!("dotnet", "pack", "crates/bindings-csharp/Runtime", "-c", "Release").run()?;
477-
478-
let repo_root = env::current_dir()?;
479-
let bsatn_source = repo_root.join("crates/bindings-csharp/BSATN.Runtime/bin/Release");
480-
let runtime_source = repo_root.join("crates/bindings-csharp/Runtime/bin/Release");
481-
482-
let nuget_config_dir = tempfile::tempdir()?;
483-
let nuget_config_path = nuget_config_dir.path().join("nuget.config");
484-
let nuget_config_contents = format!(
485-
r#"<?xml version="1.0" encoding="utf-8"?>
486-
<configuration>
487-
<packageSources>
488-
<clear />
489-
<add key="Local SpacetimeDB.BSATN.Runtime" value="{}" />
490-
<add key="Local SpacetimeDB.Runtime" value="{}" />
491-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
492-
</packageSources>
493-
<packageSourceMapping>
494-
<packageSource key="Local SpacetimeDB.BSATN.Runtime">
495-
<package pattern="SpacetimeDB.BSATN.Runtime" />
496-
</packageSource>
497-
<packageSource key="Local SpacetimeDB.Runtime">
498-
<package pattern="SpacetimeDB.Runtime" />
499-
</packageSource>
500-
<packageSource key="nuget.org">
501-
<package pattern="*" />
502-
</packageSource>
503-
</packageSourceMapping>
504-
</configuration>
505-
"#,
506-
bsatn_source.display(),
507-
runtime_source.display(),
508-
);
509-
fs::write(&nuget_config_path, nuget_config_contents)?;
510-
511-
let nuget_config_path_str = nuget_config_path.to_string_lossy().to_string();
512-
513-
clear_restored_package_dirs("spacetimedb.bsatn.runtime")?;
514-
clear_restored_package_dirs("spacetimedb.runtime")?;
515-
516-
cmd!(
517-
"dotnet",
518-
"restore",
519-
"SpacetimeDB.ClientSDK.csproj",
520-
"--configfile",
521-
&nuget_config_path_str,
522-
)
523-
.dir("sdks/csharp")
524-
.run()?;
525-
526-
overlay_unity_meta_skeleton("spacetimedb.bsatn.runtime")?;
527-
overlay_unity_meta_skeleton("spacetimedb.runtime")?;
528-
529-
cmd!(
530-
"dotnet",
531-
"pack",
532-
"SpacetimeDB.ClientSDK.csproj",
533-
"-c",
534-
"Release",
535-
"--no-restore"
536-
)
537-
.dir("sdks/csharp")
538-
.run()?;
544+
run_dlls()?;
539545
}
540546

541547
Some(CiCmd::Smoketests(args)) => {

0 commit comments

Comments
 (0)