Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 79 additions & 73 deletions tools/ci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,84 @@ fn tracked_rs_files_under(path: &str) -> Result<Vec<PathBuf>> {
.collect())
}

fn run_dlls() -> Result<()> {
ensure_repo_root()?;

cmd!(
"dotnet",
"pack",
"crates/bindings-csharp/BSATN.Runtime",
"-c",
"Release"
)
.run()?;
cmd!("dotnet", "pack", "crates/bindings-csharp/Runtime", "-c", "Release").run()?;

let repo_root = env::current_dir()?;
let bsatn_source = repo_root.join("crates/bindings-csharp/BSATN.Runtime/bin/Release");
let runtime_source = repo_root.join("crates/bindings-csharp/Runtime/bin/Release");

let nuget_config_dir = tempfile::tempdir()?;
let nuget_config_path = nuget_config_dir.path().join("nuget.config");
let nuget_config_contents = format!(
r#"<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="Local SpacetimeDB.BSATN.Runtime" value="{}" />
<add key="Local SpacetimeDB.Runtime" value="{}" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="Local SpacetimeDB.BSATN.Runtime">
<package pattern="SpacetimeDB.BSATN.Runtime" />
</packageSource>
<packageSource key="Local SpacetimeDB.Runtime">
<package pattern="SpacetimeDB.Runtime" />
</packageSource>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
"#,
bsatn_source.display(),
runtime_source.display(),
);
fs::write(&nuget_config_path, nuget_config_contents)?;

let nuget_config_path_str = nuget_config_path.to_string_lossy().to_string();

clear_restored_package_dirs("spacetimedb.bsatn.runtime")?;
clear_restored_package_dirs("spacetimedb.runtime")?;

cmd!(
"dotnet",
"restore",
"SpacetimeDB.ClientSDK.csproj",
"--configfile",
&nuget_config_path_str,
)
.dir("sdks/csharp")
.run()?;

overlay_unity_meta_skeleton("spacetimedb.bsatn.runtime")?;
overlay_unity_meta_skeleton("spacetimedb.runtime")?;

cmd!(
"dotnet",
"pack",
"SpacetimeDB.ClientSDK.csproj",
"-c",
"Release",
"--no-restore"
)
.dir("sdks/csharp")
.run()?;

Ok(())
}

fn main() -> Result<()> {
env_logger::init();

Expand Down Expand Up @@ -463,79 +541,7 @@ fn main() -> Result<()> {
}

Some(CiCmd::Dlls) => {
ensure_repo_root()?;

cmd!(
"dotnet",
"pack",
"crates/bindings-csharp/BSATN.Runtime",
"-c",
"Release"
)
.run()?;
cmd!("dotnet", "pack", "crates/bindings-csharp/Runtime", "-c", "Release").run()?;

let repo_root = env::current_dir()?;
let bsatn_source = repo_root.join("crates/bindings-csharp/BSATN.Runtime/bin/Release");
let runtime_source = repo_root.join("crates/bindings-csharp/Runtime/bin/Release");

let nuget_config_dir = tempfile::tempdir()?;
let nuget_config_path = nuget_config_dir.path().join("nuget.config");
let nuget_config_contents = format!(
r#"<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="Local SpacetimeDB.BSATN.Runtime" value="{}" />
<add key="Local SpacetimeDB.Runtime" value="{}" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="Local SpacetimeDB.BSATN.Runtime">
<package pattern="SpacetimeDB.BSATN.Runtime" />
</packageSource>
<packageSource key="Local SpacetimeDB.Runtime">
<package pattern="SpacetimeDB.Runtime" />
</packageSource>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
"#,
bsatn_source.display(),
runtime_source.display(),
);
fs::write(&nuget_config_path, nuget_config_contents)?;

let nuget_config_path_str = nuget_config_path.to_string_lossy().to_string();

clear_restored_package_dirs("spacetimedb.bsatn.runtime")?;
clear_restored_package_dirs("spacetimedb.runtime")?;

cmd!(
"dotnet",
"restore",
"SpacetimeDB.ClientSDK.csproj",
"--configfile",
&nuget_config_path_str,
)
.dir("sdks/csharp")
.run()?;

overlay_unity_meta_skeleton("spacetimedb.bsatn.runtime")?;
overlay_unity_meta_skeleton("spacetimedb.runtime")?;

cmd!(
"dotnet",
"pack",
"SpacetimeDB.ClientSDK.csproj",
"-c",
"Release",
"--no-restore"
)
.dir("sdks/csharp")
.run()?;
run_dlls()?;
}

Some(CiCmd::Smoketests(args)) => {
Expand Down
Loading