From 278ed46213cdd3bd8bdcc6d239204241c0406f51 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Thu, 13 Nov 2025 16:35:03 +0100 Subject: [PATCH 01/13] Initial version of the script --- Setup.cs | 443 ++++++++++++++++++++++++++++++ cli/cli/.config/dotnet-tools.json | 2 +- 2 files changed, 444 insertions(+), 1 deletion(-) create mode 100755 Setup.cs diff --git a/Setup.cs b/Setup.cs new file mode 100755 index 0000000000..e406ca95ac --- /dev/null +++ b/Setup.cs @@ -0,0 +1,443 @@ +#!/usr/bin/env dotnet run +#:package clapnet@0.2.* +#:package Spectre.Console.Cli@0.53.0 + +using System; +using System.IO; +using System.Diagnostics; +using System.Text.RegularExpressions; +using System.Runtime.InteropServices; +using Spectre.Console; + + +return clapnet.CommandBuilder.New() + .With(Setup, "Setup") + .With(SyncRiderSettings, "Sync Rider Settings", "sync") + .With(SyncRiderUnity, "Sync Rider Settings for Unity(shortcut command)", "sync-unity") + .With(SyncRiderUnreal, "Sync Rider Settings for Unreal(shortcut command)", "sync-unreal") + .Run(args); + +void Setup(SetupSettingsOptions cfg) +{ + AnsiConsole.MarkupLine("Setting up the [bold][blue]Beamables[/][/]!"); + + // Load environment variables from .dev.env file + LoadDevEnvironment(); + string root = GetRootDirectory(); + string sourceFolderPath = Path.Combine(root, Environment.GetEnvironmentVariable("SOURCE_FOLDER") ?? ""); + Console.WriteLine("Creating build number file"); + File.WriteAllText(Path.Combine(root, "build-number.txt"), "0"); + var feedName = Environment.GetEnvironmentVariable("FEED_NAME") ?? "BeamableNugetSource"; + var goCheck = CheckAndInstallGo(cfg.accept_any_go_version); + var dotnetConfigRestore = RunProcessAsync("dotnet", $"tool restore --tool-manifest ./cli/cli/.config/dotnet-tools.json"); + var configCreationTask = SetupTemplateDotNetConfig(); + Console.WriteLine($"Setting up {feedName} at {sourceFolderPath}"); + SetupNuGetSource(sourceFolderPath, feedName).Wait(); + goCheck.Wait(1000 * 60 * 5); + configCreationTask.Wait(1000 * 60 * 5); + dotnetConfigRestore.Wait(1000 * 60 * 5); + BuildOtel().Wait(1000 * 60 * 60); +} + +int SyncRiderUnity(SyncSettingsOptions cfg, string pathToWorkingDirectory = "", string pathToRestoreDirectory = "") +{ + return SyncRiderSettings(cfg, "UNITY", pathToWorkingDirectory, pathToRestoreDirectory); +} + +int SyncRiderUnreal(SyncSettingsOptions cfg, string pathToWorkingDirectory = "", string pathToRestoreDirectory = "") +{ + return SyncRiderSettings(cfg, "UNREAL", pathToWorkingDirectory, pathToRestoreDirectory); +} + +int SyncRiderSettings(SyncSettingsOptions cfg, string targetEngine, string pathToWorkingDirectory = "", string pathToRestoreDirectory = "") +{ + var isUnity = targetEngine.Equals("UNITY", StringComparison.OrdinalIgnoreCase); + var isUnreal = targetEngine.Equals("UNREAL", StringComparison.OrdinalIgnoreCase); + + if(!isUnity && !isUnreal) + { + AnsiConsole.MarkupLine($"Invalid target engine argument value. Supported engines are [bold]UNITY[/] and [bold]UNREAL[/], got: [red]{targetEngine}[/]"); + return 1; + } + + string baseDir = GetRootDirectory(); + cfg.VerboseLog(baseDir); + + // Handle PathToWorkingDirectory + if (isUnity && string.IsNullOrEmpty(pathToWorkingDirectory)) + { + pathToWorkingDirectory = Path.Combine(baseDir, "client"); + } + pathToWorkingDirectory = pathToWorkingDirectory.Replace("\\", "/"); + + // Set default PathToRestoreDirectory for UNREAL + if (isUnreal && string.IsNullOrEmpty(pathToRestoreDirectory)) + { + pathToRestoreDirectory = Path.Combine(pathToWorkingDirectory, "Microservices"); + } + var pathToUnixShell = cfg.GetShell().Replace("\\", "/"); + + string cliRunPath = Path.Combine(baseDir, "cli", ".run"); + + if (!Directory.Exists(cliRunPath)) + { + AnsiConsole.WriteLine($"Invalid path to a .run folder. Given Path: {cliRunPath}"); + return 1; + } + AnsiConsole.WriteLine($"Copying all TEMPLATE- configurations into {targetEngine}- configurations."); + + string[] templateFiles = Directory.GetFiles(cliRunPath, "TEMPLATE-*.run.xml"); + + var root = new Tree("Template files"); + + foreach (string templateFile in templateFiles) + { + string fileName = Path.GetFileName(templateFile); + string targetFileName = fileName.Replace("TEMPLATE-", $"{targetEngine}-"); + string targetFilePath = Path.Combine(cliRunPath, targetFileName); + var rule = new Rule($"Building [green]{targetFileName}[/]"); + rule.Justification = Justify.Left; + AnsiConsole.Write(rule); + + cfg.VerboseLog($"cp {templateFile} {targetFilePath}"); + File.Copy(templateFile, targetFilePath, true); + + // Read the file content + string content = File.ReadAllText(targetFilePath); + + // Replace TEMPLATE- with target engine + content = content.Replace("TEMPLATE-", $"{targetEngine}-"); + + // Replace INTERPRETER_PATH + content = Regex.Replace(content, + @"value=""[^""]*"" name=""INTERPRETER_PATH""", + $@"value=""{EscapeXmlAttribute(pathToUnixShell)}"" name=""INTERPRETER_PATH"""); + cfg.VerboseLog($"Replaced INTERPRETER_PATH with {pathToUnixShell}"); + + // Handle special cases for Set-Local-Packages and Set-Install scripts + if (targetFileName.Contains($"{targetEngine}-Set-Local-Packages") || + targetFileName.Contains($"{targetEngine}-Set-Install-")) + { + // Replace $PROJECT_DIR$/../client with PathToWorkingDirectory + content = content.Replace("$PROJECT_DIR$/../client", pathToWorkingDirectory); + cfg.VerboseLog($"Replaced $PROJECT_DIR$/../client with {pathToWorkingDirectory}"); + + // Replace BeamableNugetSource with {TargetEngine}_NugetSource + content = content.Replace("BeamableNugetSource", $"{targetEngine}_NugetSource"); + cfg.VerboseLog($"Replaced BeamableNugetSource with {targetEngine}_NugetSource"); + + // Replace PathToRestore with pathToRestoreDirectory + if (!string.IsNullOrEmpty(pathToRestoreDirectory)) + { + content = content.Replace("PathToRestore", pathToRestoreDirectory); + cfg.VerboseLog($"Replaced PathToRestore with {pathToRestoreDirectory}"); + } + } + else + { + // Replace WORKING_DIRECTORY + content = Regex.Replace(content, + @"value=""[^""]*"" name=""WORKING_DIRECTORY""", + $@"value=""{EscapeXmlAttribute(pathToWorkingDirectory)}"" name=""WORKING_DIRECTORY"""); + cfg.VerboseLog($"Replaced [bold][teal]WORKING_DIRECTORY[/][/] with [bold]{pathToWorkingDirectory}[/]"); + } + + // Write the modified content back to the file + File.WriteAllText(targetFilePath, content); + } + return 0; +} + +static async Task SetupTemplateDotNetConfig() +{ + const string templateDotNetConfigDir = "./cli/beamable.templates/.config"; + + if (!Directory.Exists(templateDotNetConfigDir)) + { + Directory.CreateDirectory(templateDotNetConfigDir); + } + + const string jsonContent = @"{ +""version"": 1, +""isRoot"": true, +""tools"": { +""beamable.tools"": { + ""version"": ""0.0.123.0"", + ""commands"": [ + ""beam"" + ], + ""rollForward"": false +} +} +}"; + + await File.WriteAllTextAsync(Path.Combine(templateDotNetConfigDir, "dotnet-tools.json"), jsonContent); +} + +static async Task SetupNuGetSource(string sourceFolderPath, string feedName) + { + // Delete and recreate source folder + if (Directory.Exists(sourceFolderPath)) + { + Directory.Delete(sourceFolderPath, true); + } + Directory.CreateDirectory(sourceFolderPath); + + // Remove old NuGet source + Console.WriteLine("Removing old source (if none exists, you'll see an error 'Unable to find any package', but that is okay)"); + try + { + await RunProcessAsync("dotnet", $"nuget remove source {feedName}"); + } + catch + { + // Ignore errors when removing non-existent source + } + + // Add new source + Console.WriteLine("Adding new source!"); + await RunProcessAsync("dotnet", $"nuget add source \"{sourceFolderPath}\" --name {feedName}"); +} +static async Task RunProcessAsync(string fileName, string arguments) +{ + using var process = new Process(); + process.StartInfo.FileName = fileName; + process.StartInfo.Arguments = arguments; + process.StartInfo.UseShellExecute = false; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.RedirectStandardError = true; + process.StartInfo.CreateNoWindow = true; + + process.Start(); + + string output = await process.StandardOutput.ReadToEndAsync(); + string error = await process.StandardError.ReadToEndAsync(); + + await process.WaitForExitAsync(); + + if (process.ExitCode != 0) + { + throw new Exception($"Process {fileName} {arguments} failed with exit code {process.ExitCode}. Error: {error}"); + } + + return output; +} + +static async Task BuildOtel() +{ + var currentDirectory = Directory.GetCurrentDirectory(); + try{ + Directory.SetCurrentDirectory("otel-collector"); + var bashPath = SyncSettingsOptions.GetDefaultUnixShell(); + AnsiConsole.WriteLine("Building Otel Collector..."); + await RunProcessAsync(bashPath, "build.sh --version 0.0.123"); + AnsiConsole.WriteLine("Building Otel Collector done."); + } + finally { + Directory.SetCurrentDirectory(currentDirectory); + } +} + +static async Task CheckAndInstallGo(bool acceptAnyGoVersion) +{ + string goVersion = "1.24.1"; + bool goInstalled = false; + + // Check if Go is installed + try + { + var result = await RunProcessAsync("go", "version"); + var match = Regex.Match(result, @"go(\d+\.\d+\.\d+)"); + if (match.Success) + { + string installedVersion = match.Groups[1].Value; + Console.WriteLine($"Go is installed with version: {installedVersion}"); + + if (installedVersion == goVersion) + { + goInstalled = true; + Console.WriteLine("Found GO installation with correct version!"); + } + else + { + goInstalled = true; + Console.WriteLine($"This script needs GO with version {goVersion}, instead found {installedVersion}"); + if(!acceptAnyGoVersion) + { + Environment.Exit(1); + } + } + } + } + catch + { + Console.WriteLine("Go is not installed"); + } + + if (!goInstalled) + { + await InstallGo(goVersion); + } +} + +static async Task InstallGo(string goVersion) +{ + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // Check for Homebrew + try + { + var brewVersion = await RunProcessAsync("brew", "--version"); + Console.WriteLine($"Homebrew is installed"); + Console.WriteLine($"Version: {brewVersion.Split('\n')[0]}"); + } + catch + { + Console.WriteLine("Homebrew is not installed, please install it before running this script!"); + Environment.Exit(1); + } + + try + { + await RunProcessAsync("brew", $"install go@{goVersion}"); + Console.WriteLine($"GO with version {goVersion} was successfully installed!"); + + // Add to PATH + string newPath = $"/opt/homebrew/bin:/usr/local/bin:{Environment.GetEnvironmentVariable("PATH")}"; + Environment.SetEnvironmentVariable("PATH", newPath); + } + catch + { + Console.WriteLine("Failed to install GO using Homebrew!"); + Environment.Exit(1); + } + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + // Check for Chocolatey + try + { + var chocoVersion = await RunProcessAsync("choco", "--version"); + Console.WriteLine($"Chocolatey is installed with version: {chocoVersion.Trim()}"); + } + catch + { + Console.WriteLine("Chocolatey is not installed, please install it before running this script!"); + Environment.Exit(1); + } + + try + { + await RunProcessAsync("choco", $"install golang --version={goVersion} -y"); + Console.WriteLine($"GO with version {goVersion} was successfully installed!"); + + // Add to PATH + string newPath = $"{Environment.GetEnvironmentVariable("PATH")};C:\\Go\\bin"; + Environment.SetEnvironmentVariable("PATH", newPath); + } + catch + { + Console.WriteLine("Failed to install GO using Chocolatey!"); + Environment.Exit(1); + } + } + else + { + Console.WriteLine($"Unsupported OS"); + Environment.Exit(1); + } +} + +static string GetRootDirectory() +{ + return Directory.GetCurrentDirectory().Replace("\\", "/"); +} + +static void LoadDevEnvironment() +{ + string devEnvPath = ".dev.env"; + if (File.Exists(devEnvPath)) + { + string[] lines = File.ReadAllLines(devEnvPath); + foreach (string line in lines) + { + if (string.IsNullOrWhiteSpace(line) || line.StartsWith("#")) + continue; + + var parts = line.Split('=', 2); + if (parts.Length == 2) + { + string key = parts[0].Trim(); + string value = parts[1].Trim().Trim('"'); + Environment.SetEnvironmentVariable(key, value); + } + } + } +} + +static string EscapeXmlAttribute(string value) +{ + if (string.IsNullOrEmpty(value)) + return value; + + return value + .Replace("&", "&") + .Replace("<", "<") + .Replace(">", ">") + .Replace("\"", """) + .Replace("'", "'"); +} + +class SetupSettingsOptions { + public bool Verbose = false; + public bool accept_any_go_version = false; + + public void VerboseLog(string message) + { + if (Verbose) + { + AnsiConsole.MarkupLine(message); + } + } +} + +class SyncSettingsOptions { + public bool Verbose = false; + public string bash_Path = ""; + + public string GetShell() + { + if (!string.IsNullOrWhiteSpace(bash_Path)) + return bash_Path; + return GetDefaultUnixShell(); + } + + public void VerboseLog(string message) + { + if (Verbose) + { + AnsiConsole.MarkupLine(message); + } + } + + public static string GetDefaultUnixShell() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return @"C:/Program Files/Git/bin/bash.exe"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + return "/bin/bash"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return "/usr/bin/bash"; + } + else + { + // Default fallback + return "/bin/bash"; + } + } +} diff --git a/cli/cli/.config/dotnet-tools.json b/cli/cli/.config/dotnet-tools.json index b24dbeb2eb..daaa76395f 100644 --- a/cli/cli/.config/dotnet-tools.json +++ b/cli/cli/.config/dotnet-tools.json @@ -1 +1 @@ -{"version":1,"isRoot":true,"tools":{"dotnet-format":{"version":"5.1.250801","commands":["dotnet-format"]}}} \ No newline at end of file +{ "version": 1, "isRoot": true, "tools": {} } From 49b042ee410bc1975b7ac006a6ef236cfe1b49be Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Fri, 16 Jan 2026 14:25:30 +0100 Subject: [PATCH 02/13] Script cleanup --- Setup.cs | 64 +++++++-------- format-code.bat | 4 - format-code.sh | 7 -- setup.sh | 154 ------------------------------------- sync-rider-run-settings.sh | 83 -------------------- 5 files changed, 34 insertions(+), 278 deletions(-) delete mode 100644 format-code.bat delete mode 100755 format-code.sh delete mode 100755 setup.sh delete mode 100644 sync-rider-run-settings.sh diff --git a/Setup.cs b/Setup.cs index e406ca95ac..7a2be6b20d 100755 --- a/Setup.cs +++ b/Setup.cs @@ -9,6 +9,7 @@ using System.Runtime.InteropServices; using Spectre.Console; +const string GO_VERSION = "1.24"; return clapnet.CommandBuilder.New() .With(Setup, "Setup") @@ -17,6 +18,7 @@ .With(SyncRiderUnreal, "Sync Rider Settings for Unreal(shortcut command)", "sync-unreal") .Run(args); + void Setup(SetupSettingsOptions cfg) { AnsiConsole.MarkupLine("Setting up the [bold][blue]Beamables[/][/]!"); @@ -28,15 +30,15 @@ void Setup(SetupSettingsOptions cfg) Console.WriteLine("Creating build number file"); File.WriteAllText(Path.Combine(root, "build-number.txt"), "0"); var feedName = Environment.GetEnvironmentVariable("FEED_NAME") ?? "BeamableNugetSource"; - var goCheck = CheckAndInstallGo(cfg.accept_any_go_version); + var goCheck = CheckAndInstallGo(cfg.acceptAnyGoVersion); var dotnetConfigRestore = RunProcessAsync("dotnet", $"tool restore --tool-manifest ./cli/cli/.config/dotnet-tools.json"); var configCreationTask = SetupTemplateDotNetConfig(); Console.WriteLine($"Setting up {feedName} at {sourceFolderPath}"); SetupNuGetSource(sourceFolderPath, feedName).Wait(); - goCheck.Wait(1000 * 60 * 5); + var (goInstalled, goPath) = goCheck.Result; configCreationTask.Wait(1000 * 60 * 5); dotnetConfigRestore.Wait(1000 * 60 * 5); - BuildOtel().Wait(1000 * 60 * 60); + BuildOtel(goPath).Wait(1000 * 60 * 60); } int SyncRiderUnity(SyncSettingsOptions cfg, string pathToWorkingDirectory = "", string pathToRestoreDirectory = "") @@ -64,10 +66,11 @@ int SyncRiderSettings(SyncSettingsOptions cfg, string targetEngine, string pathT cfg.VerboseLog(baseDir); // Handle PathToWorkingDirectory - if (isUnity && string.IsNullOrEmpty(pathToWorkingDirectory)) + if (string.IsNullOrEmpty(pathToWorkingDirectory)) { pathToWorkingDirectory = Path.Combine(baseDir, "client"); } + pathToWorkingDirectory = pathToWorkingDirectory.Replace("\\", "/"); // Set default PathToRestoreDirectory for UNREAL @@ -223,14 +226,18 @@ static async Task RunProcessAsync(string fileName, string arguments) return output; } -static async Task BuildOtel() +static async Task BuildOtel(string goPath) { var currentDirectory = Directory.GetCurrentDirectory(); + var goBinDir = Path.GetDirectoryName(goPath); try{ - Directory.SetCurrentDirectory("otel-collector"); + Directory.SetCurrentDirectory(Path.Combine(currentDirectory,"otel-collector")); var bashPath = SyncSettingsOptions.GetDefaultUnixShell(); AnsiConsole.WriteLine("Building Otel Collector..."); - await RunProcessAsync(bashPath, "build.sh --version 0.0.123"); + var pathExport = string.IsNullOrEmpty(goBinDir) + ? "" + : $"export PATH=\"$PATH:{goBinDir}\" && "; + await RunProcessAsync(bashPath, $"{pathExport} build.sh --version 0.0.123"); AnsiConsole.WriteLine("Building Otel Collector done."); } finally { @@ -238,9 +245,8 @@ static async Task BuildOtel() } } -static async Task CheckAndInstallGo(bool acceptAnyGoVersion) +static async Task<(bool Installed, string GoPath)> CheckAndInstallGo(bool acceptAnyGoVersion) { - string goVersion = "1.24.1"; bool goInstalled = false; // Check if Go is installed @@ -253,7 +259,7 @@ static async Task CheckAndInstallGo(bool acceptAnyGoVersion) string installedVersion = match.Groups[1].Value; Console.WriteLine($"Go is installed with version: {installedVersion}"); - if (installedVersion == goVersion) + if (installedVersion.Contains(GO_VERSION)) { goInstalled = true; Console.WriteLine("Found GO installation with correct version!"); @@ -261,7 +267,7 @@ static async Task CheckAndInstallGo(bool acceptAnyGoVersion) else { goInstalled = true; - Console.WriteLine($"This script needs GO with version {goVersion}, instead found {installedVersion}"); + Console.WriteLine($"This script needs GO with version {GO_VERSION}, instead found {installedVersion}"); if(!acceptAnyGoVersion) { Environment.Exit(1); @@ -276,11 +282,16 @@ static async Task CheckAndInstallGo(bool acceptAnyGoVersion) if (!goInstalled) { - await InstallGo(goVersion); + var (success, goPath) = await InstallGo(); + if (success) + { + return (true, goPath); + } } + return (goInstalled, "go"); } -static async Task InstallGo(string goVersion) +static async Task<(bool Success, string GoPath)> InstallGo() { if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { @@ -299,17 +310,13 @@ static async Task InstallGo(string goVersion) try { - await RunProcessAsync("brew", $"install go@{goVersion}"); - Console.WriteLine($"GO with version {goVersion} was successfully installed!"); - - // Add to PATH - string newPath = $"/opt/homebrew/bin:/usr/local/bin:{Environment.GetEnvironmentVariable("PATH")}"; - Environment.SetEnvironmentVariable("PATH", newPath); + await RunProcessAsync("brew", $"install go@{GO_VERSION}"); + Console.WriteLine($"GO with version {GO_VERSION} was successfully installed!"); + return (true, "/opt/homebrew/bin/go"); } catch { - Console.WriteLine("Failed to install GO using Homebrew!"); - Environment.Exit(1); + Console.WriteLine($"Failed to install GO using Homebrew!"); } } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) @@ -328,17 +335,13 @@ static async Task InstallGo(string goVersion) try { - await RunProcessAsync("choco", $"install golang --version={goVersion} -y"); - Console.WriteLine($"GO with version {goVersion} was successfully installed!"); - - // Add to PATH - string newPath = $"{Environment.GetEnvironmentVariable("PATH")};C:\\Go\\bin"; - Environment.SetEnvironmentVariable("PATH", newPath); + await RunProcessAsync("choco", $"install golang --version={GO_VERSION} -y"); + Console.WriteLine($"GO with version {GO_VERSION} was successfully installed!"); + return (true, "C:\\Go\\bin\\go.exe"); } catch { - Console.WriteLine("Failed to install GO using Chocolatey!"); - Environment.Exit(1); + Console.WriteLine($"Failed to install GO using Chocolatey!"); } } else @@ -346,6 +349,7 @@ static async Task InstallGo(string goVersion) Console.WriteLine($"Unsupported OS"); Environment.Exit(1); } + return (false, ""); } static string GetRootDirectory() @@ -390,7 +394,7 @@ static string EscapeXmlAttribute(string value) class SetupSettingsOptions { public bool Verbose = false; - public bool accept_any_go_version = false; + public bool acceptAnyGoVersion = false; public void VerboseLog(string message) { diff --git a/format-code.bat b/format-code.bat deleted file mode 100644 index 1051fcbde8..0000000000 --- a/format-code.bat +++ /dev/null @@ -1,4 +0,0 @@ -IF "%1"=="" ( SET "FOLDER=client/Packages" ) ELSE ( SET "FOLDER=%1" ) - -dotnet tool restore -dotnet tool run dotnet-format -f %FOLDER% diff --git a/format-code.sh b/format-code.sh deleted file mode 100755 index d661f9827e..0000000000 --- a/format-code.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -default_dir='client/Packages' -dir=${1:-$default_dir} - -dotnet tool restore -dotnet tool run dotnet-format -f $dir diff --git a/setup.sh b/setup.sh deleted file mode 100755 index 9af37d2017..0000000000 --- a/setup.sh +++ /dev/null @@ -1,154 +0,0 @@ -#!/bin/bash - -# This script should be run ONCE after -# you check out the repository for the first time. -# -# It will create a local Nuget package feed/source -# in your Home directory. That feed will be used to -# store local packages as you develop. - -echo "Setting up the Beamables!" - -# the .dev.env file hosts some common variables -source ./.dev.env - -echo "Checking OS=[$OSTYPE] type for root value" - -# Get the current directory in the right format... -case "$OSTYPE" in - solaris*) ROOT=$(pwd) ;; - darwin*) ROOT=$(pwd) ;; - linux*) ROOT=$(pwd) ;; - bsd*) ROOT=$(pwd) ;; - msys*) - ROOT=$(pwd -W) - ROOT="${ROOT:0:2}/${ROOT:2}" - ;; - cygwin*) - ROOT=$(pwd -W) - ROOT="${ROOT:0:2}/${ROOT:2}" - ;; - *) echo "Should never see this!!" ;; -esac - -SOURCE_FOLDER=$ROOT/$SOURCE_FOLDER -echo "Setting up $FEED_NAME at $SOURCE_FOLDER" - - - -# delete contents of old folder, and then re-create it. -# this essentially removes all old packages as well. -rm -rf $SOURCE_FOLDER -mkdir -p $SOURCE_FOLDER - -echo "Removing old source (if none exists, you'll see an error 'Unable to find any package', but that is okay)" -dotnet nuget remove source $FEED_NAME || true - -echo "Adding new source!" -dotnet nuget add source $SOURCE_FOLDER --name $FEED_NAME - -# reset the build number back to zero. -echo "Creating build number file" -echo 0 > build-number.txt - -# restore cli tools -dotnet tool restore --tool-manifest ./cli/cli/.config/dotnet-tools.json - -# reset the template projects to reference the base version number -TEMPLATE_DOTNET_CONFIG_PATH="./cli/beamable.templates/.config/dotnet-tools.json" -ls -a "./cli/beamable.templates/" -mkdir -p "./cli/beamable.templates/.config" -cat > $TEMPLATE_DOTNET_CONFIG_PATH << EOF -{ - "version": 1, - "isRoot": true, - "tools": { - "beamable.tools": { - "version": "0.0.123.0", - "commands": [ - "beam" - ], - "rollForward": false - } - } -} -EOF - - - -GO_VERSION="1.24" -CURRENT_OS="windows" - -GO_INSTALLED=0 - -if command -v go &> /dev/null; then - INSTALLED_GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//') - echo "Go is installed with version: $INSTALLED_GO_VERSION" - if [[ "$INSTALLED_GO_VERSION" == *"$GO_VERSION"* ]]; then - GO_INSTALLED=1 - echo "Found GO installation with correct version!" - else - echo "This script needs GO with version $GO_VERSION, instead found $INSTALLED_GO_VERSION" - exit 1 - fi -fi - - -#TODO This could be improved by actually running through a list of dependencies and check for all of them, better done once we actually have more deps -# if the dependency is not installed by default, then we will need either Chocolatey or Homebrew -if [[ "$GO_INSTALLED" == "0" ]]; then - # check for os type, if windows then we need chocolatey to be installed, otherwise we need homebrew - case "$OSTYPE" in - darwin*) - CURRENT_OS="mac" - if command -v brew &> /dev/null; then - echo "Homebrew is installed" - echo "Version: $(brew --version | head -n 1)" - else - echo "Homebrew is not installed, please install it before running this script!" - exit 1 - fi - ;; - msys*|cygwin*|win32) - CURRENT_OS="windows" - if command -v choco &> /dev/null; then - echo "Chocolatey is installed with version: $(choco --version)" - else - echo "Chocolatey is not installed, please install it before running this script!" - exit 1 - fi - ;; - *) - echo "This message should never be printed, os: $OSTYPE" - exit 1 - ;; - esac - - if [[ "$CURRENT_OS" == "windows" ]]; then - if choco install golang --version=$GO_VERSION -y; then - echo "GO with version $GO_VERSION was successfully installed!" - export PATH="$PATH:/c/Go/bin" #This is the default case for chocolatey, it might not work depending on the user's setup - else - echo "Failed to install GO using Chocolatey!" - exit 1 - fi - else - if brew install go@$GO_VERSION 2>/dev/null; then - echo "GO with version $GO_VERSION was successfully installed!" - export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" #This is the default case for homebrew, it might not work depending on the user's setup - else - echo "Failed to install GO using Homebrew!" - fi - fi -fi - - -# Builds all the otel collector binaries -cd ./otel-collector/ -./build.sh --version 0.0.123 -cd .. - - - -# TODO: Consider running this as part of a post-pull git action -# TODO: Should this run the `sync-rider-run-settings.sh` script? (probably) \ No newline at end of file diff --git a/sync-rider-run-settings.sh b/sync-rider-run-settings.sh deleted file mode 100644 index 8994e9890e..0000000000 --- a/sync-rider-run-settings.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -BASEDIR=$(dirname "$0") -echo "$BASEDIR" - -TargetEngine="$1" - -# For unity, this defaults to /client, but can be overridable -PathToWorkingDirectory="$2" -if [[ $TargetEngine == "UNITY" && $PathToWorkingDirectory == "" ]]; then - PathToWorkingDirectory="$BASEDIR/client" -fi -PathToWorkingDirectory="${PathToWorkingDirectory//\\/\/}" - -# For unreal -PathToRestoreDirectory="$3" -if [[ $TargetEngine == "UNREAL" && $PathToRestoreDirectory == "" ]]; then - PathToRestoreDirectory="$PathToWorkingDirectory"Microservices -fi - -# This argument is the path to GitBash 99% of the time. If not given, assumes C:/Program Files/Git/bin/bash.exe -PathToUnixShell="$3" -if [[ $PathToUnixShell == "" ]]; then - case "$OSTYPE" in - solaris*) echo "/bin/bash" ;; - darwin*) echo "/bin/bash" ;; - linux*) echo "/usr/bin/bash" ;; - bsd*) echo "/usr/bin/bash" ;; - msys*) PathToUnixShell="C:\Program Files\Git\bin\bash.exe" ;; - cygwin*) PathToUnixShell="C:\Program Files\Git\bin\bash.exe" ;; - *) echo "Should never see this!!" ;; - esac - -fi -PathToUnixShell="${PathToUnixShell//\\/\/}" - -# Path to the CLI .run folder. -CliRunPath="$BASEDIR/cli/.run" - -if [ -d "$CliRunPath" ]; then - echo "Copying all TEMPLATE- configurations into $TargetEngine- configurations." - - for i in $(find "$CliRunPath" -name 'TEMPLATE-*.run.xml'); do # Not recommended, will break on whitespace - - TargetFile="${i/TEMPLATE-/"$TargetEngine"-}" - echo "cp -u $i $TargetFile" - cp -u "$i" "$TargetFile" - echo sed -i 's/TEMPLATE-/'"$TargetEngine"'-/g' "$TargetFile" - sed -i 's/TEMPLATE-/'"$TargetEngine"'-/g' "$TargetFile" - - # If there is an INTERPRETER_PATH in the xml, replace it with the given $PathToUnixShell - echo sed -i '\@="INTERPRETER_PATH"@s@value=".*"@value="'"$PathToUnixShell"'"@g' "$TargetFile" - sed -i '\@="INTERPRETER_PATH"@s@value=".*"@value="'"$PathToUnixShell"'"@g' "$TargetFile" - - # For the local packages script we also change the SCRIPT_OPTIONS to point to the $PathToWorkingDirectory - # For every other script, we set the WORKING_DIRECTORY path in the xml, replace it with the given $PathToWorkingDirectory - if [[ $TargetFile == *$TargetEngine-Set-Local-Packages* || $TargetFile == *$TargetEngine-Set-Install-* ]]; then - echo sed -i '\@="SCRIPT_OPTIONS"@s@\$PROJECT_DIR\$\/\.\.\/client@'"$PathToWorkingDirectory"'@g' "$TargetFile" - sed -i '\@="SCRIPT_OPTIONS"@s@\$PROJECT_DIR\$\/\.\.\/client@'"$PathToWorkingDirectory"'@g' "$TargetFile" - - echo sed -i '\@="SCRIPT_OPTIONS"@s@BeamableNugetSource@'"$TargetEngine"'_NugetSource@g' "$TargetFile" - sed -i '\@="SCRIPT_OPTIONS"@s@BeamableNugetSource@'"$TargetEngine"'_NugetSource@g' "$TargetFile" - - echo sed -i '\@="SCRIPT_OPTIONS"@s@PathToRestore@'"$PathToRestoreDirectory"'@g' "$TargetFile" - sed -i '\@="SCRIPT_OPTIONS"@s@PathToRestore@'"$PathToRestoreDirectory"'@g' "$TargetFile" - - continue - else - echo sed -i '\@="WORKING_DIRECTORY"@s@value=".*"@value="'"$PathToWorkingDirectory"'"@g' "$TargetFile" - sed -i '\@="WORKING_DIRECTORY"@s@value=".*"@value="'"$PathToWorkingDirectory"'"@g' "$TargetFile" - fi - done - -else - echo "Invalid path to a .run folder. Given Path: $CliRunPath" -fi - - - - - - - From 2f1b7b84187752d4130425514eb8b57631171587 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Fri, 16 Jan 2026 18:45:03 +0100 Subject: [PATCH 03/13] CLI reworked to C# --- Setup.cs | 485 ++++++++++++++++++++++++++++++++++++++++++------------- dev.sh | 138 ---------------- 2 files changed, 370 insertions(+), 253 deletions(-) delete mode 100755 dev.sh diff --git a/Setup.cs b/Setup.cs index 7a2be6b20d..0f93c4a74a 100755 --- a/Setup.cs +++ b/Setup.cs @@ -1,23 +1,49 @@ #!/usr/bin/env dotnet run -#:package clapnet@0.2.* +#:package clapnet@0.3.* #:package Spectre.Console.Cli@0.53.0 -using System; -using System.IO; using System.Diagnostics; -using System.Text.RegularExpressions; using System.Runtime.InteropServices; using Spectre.Console; +using System.Text.RegularExpressions; const string GO_VERSION = "1.24"; return clapnet.CommandBuilder.New() - .With(Setup, "Setup") + .WithRootCommand(Root, "CLI Helper for Beamable project") + .With(Setup, "Setup project for development") + .With(Dev, "rebuild nuget packages and install beamable cli", "dev") .With(SyncRiderSettings, "Sync Rider Settings", "sync") .With(SyncRiderUnity, "Sync Rider Settings for Unity(shortcut command)", "sync-unity") .With(SyncRiderUnreal, "Sync Rider Settings for Unreal(shortcut command)", "sync-unreal") .Run(args); +void Root() +{ + var tt = AnsiConsole.Prompt( + new SelectionPrompt() + .Title("What's on your mind today?") + .AddChoices("Setup project for development", "dev- rebuild nuget packages and install beamable cli", "Sync Rider Settings for Unity", "Sync Rider Settings for Unreal")); + + + if (tt.StartsWith("Setup")) + { + + Setup(new SetupSettingsOptions()); + } + else if (tt.StartsWith("dev-")) + { + Dev(new DevOptions()); + } + else if (tt.Contains("Unity")) + { + SyncRiderUnity(new SyncSettingsOptions()); + } + else if (tt.StartsWith("Unreal")) + { + SyncRiderUnreal(new SyncSettingsOptions()); + } +} void Setup(SetupSettingsOptions cfg) { @@ -27,18 +53,31 @@ void Setup(SetupSettingsOptions cfg) LoadDevEnvironment(); string root = GetRootDirectory(); string sourceFolderPath = Path.Combine(root, Environment.GetEnvironmentVariable("SOURCE_FOLDER") ?? ""); - Console.WriteLine("Creating build number file"); - File.WriteAllText(Path.Combine(root, "build-number.txt"), "0"); - var feedName = Environment.GetEnvironmentVariable("FEED_NAME") ?? "BeamableNugetSource"; - var goCheck = CheckAndInstallGo(cfg.acceptAnyGoVersion); - var dotnetConfigRestore = RunProcessAsync("dotnet", $"tool restore --tool-manifest ./cli/cli/.config/dotnet-tools.json"); - var configCreationTask = SetupTemplateDotNetConfig(); - Console.WriteLine($"Setting up {feedName} at {sourceFolderPath}"); - SetupNuGetSource(sourceFolderPath, feedName).Wait(); - var (goInstalled, goPath) = goCheck.Result; - configCreationTask.Wait(1000 * 60 * 5); - dotnetConfigRestore.Wait(1000 * 60 * 5); - BuildOtel(goPath).Wait(1000 * 60 * 60); + + + if (File.Exists(Path.Combine(root, "build-number.txt")) && !AnsiConsole.Confirm("Looks like the installation was attempted before. Continue with installation?")) + { + return; + } + + + AnsiConsole.Status() + .StartAsync("Initializing...", async ctx => + { + File.WriteAllText(Path.Combine(root, "build-number.txt"), "0"); + var feedName = Environment.GetEnvironmentVariable("FEED_NAME") ?? "BeamableNugetSource"; + AnsiConsole.MarkupLine("Created build number file"); + ctx.Status("Installing Go"); + var (goInstalled, goPath) = await CheckAndInstallGo(cfg.acceptAnyGoVersion); + await SetupTemplateDotNetConfig(); + await RunProcessAsync("dotnet", $"tool restore --tool-manifest ./cli/cli/.config/dotnet-tools.json"); + ctx.Status($"Setting up {feedName} at {sourceFolderPath}"); + await SetupNuGetSource(sourceFolderPath, feedName); + AnsiConsole.Write($"Setting up {feedName} at {sourceFolderPath} complete"); + ctx.Status("Building otel-collector"); + await BuildOtel(goPath); + + }).Wait(); } int SyncRiderUnity(SyncSettingsOptions cfg, string pathToWorkingDirectory = "", string pathToRestoreDirectory = "") @@ -56,7 +95,7 @@ int SyncRiderSettings(SyncSettingsOptions cfg, string targetEngine, string pathT var isUnity = targetEngine.Equals("UNITY", StringComparison.OrdinalIgnoreCase); var isUnreal = targetEngine.Equals("UNREAL", StringComparison.OrdinalIgnoreCase); - if(!isUnity && !isUnreal) + if (!isUnity && !isUnreal) { AnsiConsole.MarkupLine($"Invalid target engine argument value. Supported engines are [bold]UNITY[/] and [bold]UNREAL[/], got: [red]{targetEngine}[/]"); return 1; @@ -87,68 +126,68 @@ int SyncRiderSettings(SyncSettingsOptions cfg, string targetEngine, string pathT AnsiConsole.WriteLine($"Invalid path to a .run folder. Given Path: {cliRunPath}"); return 1; } - AnsiConsole.WriteLine($"Copying all TEMPLATE- configurations into {targetEngine}- configurations."); + AnsiConsole.WriteLine($"Copying all TEMPLATE- configurations into {targetEngine}- configurations."); - string[] templateFiles = Directory.GetFiles(cliRunPath, "TEMPLATE-*.run.xml"); + string[] templateFiles = Directory.GetFiles(cliRunPath, "TEMPLATE-*.run.xml"); - var root = new Tree("Template files"); + var root = new Tree("Template files"); - foreach (string templateFile in templateFiles) + foreach (string templateFile in templateFiles) + { + string fileName = Path.GetFileName(templateFile); + string targetFileName = fileName.Replace("TEMPLATE-", $"{targetEngine}-"); + string targetFilePath = Path.Combine(cliRunPath, targetFileName); + var rule = new Rule($"Building [green]{targetFileName}[/]"); + rule.Justification = Justify.Left; + AnsiConsole.Write(rule); + + cfg.VerboseLog($"cp {templateFile} {targetFilePath}"); + File.Copy(templateFile, targetFilePath, true); + + // Read the file content + string content = File.ReadAllText(targetFilePath); + + // Replace TEMPLATE- with target engine + content = content.Replace("TEMPLATE-", $"{targetEngine}-"); + + // Replace INTERPRETER_PATH + content = Regex.Replace(content, + @"value=""[^""]*"" name=""INTERPRETER_PATH""", + $@"value=""{EscapeXmlAttribute(pathToUnixShell)}"" name=""INTERPRETER_PATH"""); + cfg.VerboseLog($"Replaced INTERPRETER_PATH with {pathToUnixShell}"); + + // Handle special cases for Set-Local-Packages and Set-Install scripts + if (targetFileName.Contains($"{targetEngine}-Set-Local-Packages") || + targetFileName.Contains($"{targetEngine}-Set-Install-")) { - string fileName = Path.GetFileName(templateFile); - string targetFileName = fileName.Replace("TEMPLATE-", $"{targetEngine}-"); - string targetFilePath = Path.Combine(cliRunPath, targetFileName); - var rule = new Rule($"Building [green]{targetFileName}[/]"); - rule.Justification = Justify.Left; - AnsiConsole.Write(rule); - - cfg.VerboseLog($"cp {templateFile} {targetFilePath}"); - File.Copy(templateFile, targetFilePath, true); - - // Read the file content - string content = File.ReadAllText(targetFilePath); + // Replace $PROJECT_DIR$/../client with PathToWorkingDirectory + content = content.Replace("$PROJECT_DIR$/../client", pathToWorkingDirectory); + cfg.VerboseLog($"Replaced $PROJECT_DIR$/../client with {pathToWorkingDirectory}"); - // Replace TEMPLATE- with target engine - content = content.Replace("TEMPLATE-", $"{targetEngine}-"); + // Replace BeamableNugetSource with {TargetEngine}_NugetSource + content = content.Replace("BeamableNugetSource", $"{targetEngine}_NugetSource"); + cfg.VerboseLog($"Replaced BeamableNugetSource with {targetEngine}_NugetSource"); - // Replace INTERPRETER_PATH - content = Regex.Replace(content, - @"value=""[^""]*"" name=""INTERPRETER_PATH""", - $@"value=""{EscapeXmlAttribute(pathToUnixShell)}"" name=""INTERPRETER_PATH"""); - cfg.VerboseLog($"Replaced INTERPRETER_PATH with {pathToUnixShell}"); - - // Handle special cases for Set-Local-Packages and Set-Install scripts - if (targetFileName.Contains($"{targetEngine}-Set-Local-Packages") || - targetFileName.Contains($"{targetEngine}-Set-Install-")) + // Replace PathToRestore with pathToRestoreDirectory + if (!string.IsNullOrEmpty(pathToRestoreDirectory)) { - // Replace $PROJECT_DIR$/../client with PathToWorkingDirectory - content = content.Replace("$PROJECT_DIR$/../client", pathToWorkingDirectory); - cfg.VerboseLog($"Replaced $PROJECT_DIR$/../client with {pathToWorkingDirectory}"); - - // Replace BeamableNugetSource with {TargetEngine}_NugetSource - content = content.Replace("BeamableNugetSource", $"{targetEngine}_NugetSource"); - cfg.VerboseLog($"Replaced BeamableNugetSource with {targetEngine}_NugetSource"); - - // Replace PathToRestore with pathToRestoreDirectory - if (!string.IsNullOrEmpty(pathToRestoreDirectory)) - { - content = content.Replace("PathToRestore", pathToRestoreDirectory); - cfg.VerboseLog($"Replaced PathToRestore with {pathToRestoreDirectory}"); - } + content = content.Replace("PathToRestore", pathToRestoreDirectory); + cfg.VerboseLog($"Replaced PathToRestore with {pathToRestoreDirectory}"); } - else - { - // Replace WORKING_DIRECTORY - content = Regex.Replace(content, - @"value=""[^""]*"" name=""WORKING_DIRECTORY""", - $@"value=""{EscapeXmlAttribute(pathToWorkingDirectory)}"" name=""WORKING_DIRECTORY"""); - cfg.VerboseLog($"Replaced [bold][teal]WORKING_DIRECTORY[/][/] with [bold]{pathToWorkingDirectory}[/]"); - } - - // Write the modified content back to the file - File.WriteAllText(targetFilePath, content); } - return 0; + else + { + // Replace WORKING_DIRECTORY + content = Regex.Replace(content, + @"value=""[^""]*"" name=""WORKING_DIRECTORY""", + $@"value=""{EscapeXmlAttribute(pathToWorkingDirectory)}"" name=""WORKING_DIRECTORY"""); + cfg.VerboseLog($"Replaced [bold][teal]WORKING_DIRECTORY[/][/] with [bold]{pathToWorkingDirectory}[/]"); + } + + // Write the modified content back to the file + File.WriteAllText(targetFilePath, content); + } + return 0; } static async Task SetupTemplateDotNetConfig() @@ -178,30 +217,219 @@ static async Task SetupTemplateDotNetConfig() } static async Task SetupNuGetSource(string sourceFolderPath, string feedName) +{ + // Delete and recreate source folder + if (Directory.Exists(sourceFolderPath)) + { + Directory.Delete(sourceFolderPath, true); + } + Directory.CreateDirectory(sourceFolderPath); + + // Remove old NuGet source + AnsiConsole.Write("Removing old source (if none exists, you'll see an error 'Unable to find any package', but that is okay)"); + try + { + await RunProcessAsync("dotnet", $"nuget remove source {feedName}"); + } + catch { - // Delete and recreate source folder - if (Directory.Exists(sourceFolderPath)) + // Ignore errors when removing non-existent source + } + + // Add new source + AnsiConsole.Write("Adding new source!"); + await RunProcessAsync("dotnet", $"nuget add source \"{sourceFolderPath}\" --name {feedName}"); +} + +/// +/// This script will be run many times as you develop. +/// Anytime you need to test a change with new code you've written +/// locally, you should run this script. +/// It will... +/// 1. build all the projects that result in Nuget packages, +/// 2. publish them locally to the local package feed +/// 3. update the local templates +/// 4. install the latest CLI globally +/// 5. invalidate the nuget cache for local beamable dev packages, which +/// means that downstream projects will need to run a `dotnet restore`. +/// +void Dev(DevOptions cfg) +{ + LoadDevEnvironment(); + var buildInfo = GetNextBuildNumber(); + RandomCompliment(); + string version = $"0.0.123.{buildInfo.Next}"; + string previousVersion = $"0.0.123.{buildInfo.Previous}"; + string feedName = Environment.GetEnvironmentVariable("FEED_NAME") ?? "BeamableNugetSource"; + string solution = "./build/LocalBuild/LocalBuild.sln"; + string tmpBuildOutput = "TempBuild"; + string buildArgs = $"--configuration Release -p:PackageVersion={version} -p:CombinedVersion={version} -p:InformationalVersion={version} -p:Warn=0 -p:BeamBuild=true"; + string packArgs = $"--configuration Release --no-build -o {tmpBuildOutput} -p:PackageVersion={version} -p:CombinedVersion={version} -p:InformationalVersion={version} -p:SKIP_GENERATION=true -p:BeamBuild=true"; + string pushArgs = $"--source {feedName}"; + AnsiConsole.Status() + .StartAsync("Initializing...", async ctx => { - Directory.Delete(sourceFolderPath, true); - } - Directory.CreateDirectory(sourceFolderPath); + AnsiConsole.MarkupLine($"[bold][green]Building version {version}[/][/]"); + + ctx.Status("[bold]Restoring project...[/]"); + await RunProcessAsync("dotnet", $"restore {solution}"); + + ctx.Status("[bold]Building services...[/]"); + await RunProcessAsync("dotnet", $"build {solution} {buildArgs}"); + await RunProcessAsync("dotnet", "dotnet build cli/cli/cli.csproj -f net10.0"); + AnsiConsole.WriteLine("CLI built successfully"); + if (!cfg.skipUnity) + { + ctx.Status("[bold]Copying code to Unity...[/]"); + RunProcessAsync("dotnet", $"build cli/beamable.common -f net10.0 -t:CopyCodeToUnity -p:BEAM_COPY_CODE_TO_UNITY=true").Wait(); + AnsiConsole.WriteLine("Code copied to Unity successfully"); + } + + ctx.Status("[bold]Packing...[/]"); + await RunProcessAsync("dotnet", $"pack {solution} {packArgs}"); + + ctx.Status("[bold]Pushing packages...[/]"); + RunProcessAsync("dotnet", $"nuget push {tmpBuildOutput}/*.{version}.nupkg {pushArgs}").Wait(); + AnsiConsole.WriteLine("Packages pushed successfully"); + ctx.Status("[bold]Deleting old packages...[/]"); + DeletePackagesAsync(feedName, previousVersion).Wait(); + + ctx.Status("[bold]Updating templates...[/]"); + UpdateTemplatesAsync(tmpBuildOutput, version).Wait(); + + ctx.Status("[bold]Cleaning up...[/]"); + if (Directory.Exists(tmpBuildOutput)) + Directory.Delete(tmpBuildOutput, true); + + InvalidateNugetCache(previousVersion); - // Remove old NuGet source - Console.WriteLine("Removing old source (if none exists, you'll see an error 'Unable to find any package', but that is okay)"); + ctx.Status("[bold]Installing CLI globally...[/]"); + await RunProcessAsync("dotnet", $"tool install Beamable.Tools --version {version} --global --allow-downgrade --no-cache"); + AnsiConsole.WriteLine("CLI installed globally successfully"); + if (!cfg.skipUnity) + { + ctx.Status("[bold]Preparing Unity SDK...[/]"); + RunProcessAsync("beam", "generate-interface --engine unity --output=./client/Packages/com.beamable/Editor/BeamCli/Commands --no-log-file").Wait(); + + ctx.Status("[bold]Updating Unity templates...[/]"); + await RunProcessAsync("dotnet", $"tool update Beamable.Tools --version {version} --allow-downgrade", workingDirectory: Path.GetFullPath("./cli/beamable.templates/templates/BeamService")); + await RunProcessAsync("dotnet", $"restore BeamService.csproj --no-cache --force", workingDirectory: Path.GetFullPath("./cli/beamable.templates/templates/BeamService")); + AnsiConsole.WriteLine("Unity prepared successfully"); + } + var unrealPath = Path.GetFullPath("../UnrealSDK"); + if (!cfg.skipUnreal && Directory.Exists(unrealPath)) + { + ctx.Status("[bold]Preparing UnrealSDK...[/]"); + RunProcessAsync("dotnet", $"tool update Beamable.Tools --version {version} --allow-downgrade", workingDirectory: unrealPath).Wait(); + RestoreAllCsprojInMicroservices(Path.Combine(unrealPath, "Microservices")).Wait(); + AnsiConsole.WriteLine("Unreal prepared successfully"); + } + + var samsLocalSandbox = Path.GetFullPath("../SamsLocalSandbox"); + if (!cfg.skipSamsSandbox && Directory.Exists(samsLocalSandbox)) + { + ctx.Status("[bold]Preparing SamsSandbox...[/]"); + RunProcessAsync("dotnet", $"tool update Beamable.Tools --version {version} --allow-downgrade", workingDirectory: samsLocalSandbox).Wait(); + await RestoreAllCsprojInMicroservices(Path.Combine(samsLocalSandbox, "Microservices")); + AnsiConsole.WriteLine("SamsSandbox prepared successfully"); + } + + }).Wait(); + AnsiConsole.MarkupLine("[bold][green]Done![/][/]"); +} + +static void RandomCompliment() +{ + string[] lines = File.ReadAllLines("compliments.txt"); + var random = new Random(); + string compliment = lines[random.Next(lines.Length)]; + AnsiConsole.MarkupLine(compliment); +} + +static (int Previous, int Next) GetNextBuildNumber() +{ + string root = Directory.GetCurrentDirectory().Replace("\\", "/"); + string buildNumberPath = Path.Combine(root, "build-number.txt"); + if (!File.Exists(buildNumberPath)) + { + AnsiConsole.MarkupLine("[bold][red]Error[/][/] No [bold]build-number.txt[/] file found."); + AnsiConsole.MarkupLine("Call [bold]./Setup.cs setup[/] first."); + Environment.Exit(1); + } + int current = int.Parse(File.ReadAllText(buildNumberPath).Trim()); + int previous = current; + int next = current + 1; + File.WriteAllText(buildNumberPath, next.ToString()); + return (previous, next); +} + +static async Task DeletePackagesAsync(string feedName, string version) +{ + string[] packages = { + "Beamable.Common", + "Beamable.Server.Common", + "Beamable.Microservice.Runtime", + "Beamable.Microservice.SourceGen", + "Beamable.Tooling.Common", + "Beamable.UnityEngine", + "Beamable.UnityEngine.Addressables", + "Beamable.Tools" + }; + var options = new ParallelOptions + { + MaxDegreeOfParallelism = 3 + }; + + await Parallel.ForEachAsync(packages, options, async (package, token) => + { try { - await RunProcessAsync("dotnet", $"nuget remove source {feedName}"); + await RunProcessAsync("dotnet", $"nuget delete {package} {version} --source {feedName} --non-interactive"); } catch { - // Ignore errors when removing non-existent source + // Log error here if needed } + }); +} - // Add new source - Console.WriteLine("Adding new source!"); - await RunProcessAsync("dotnet", $"nuget add source \"{sourceFolderPath}\" --name {feedName}"); +static async Task UpdateTemplatesAsync(string tmpBuildOutput, string version) +{ + await RunProcessAsync("dotnet", "new uninstall Beamable.Templates", true); + string templatePackage = Path.Combine(tmpBuildOutput, $"Beamable.Templates.{version}.nupkg"); + await RunProcessAsync("dotnet", $"dotnet new install {templatePackage} --force"); } -static async Task RunProcessAsync(string fileName, string arguments) + +static void InvalidateNugetCache(string version) +{ + string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + string packagesPath = Path.Combine(home, ".nuget/packages"); + if (Directory.Exists(packagesPath)) + { + foreach (var dir in Directory.GetDirectories(packagesPath, "beamable.*")) + { + string versionPath = Path.Combine(dir, version); + if (Directory.Exists(versionPath)) + { + Directory.Delete(versionPath, true); + } + } + } +} + +static async Task RestoreAllCsprojInMicroservices(string microservicesPath) +{ + if (Directory.Exists(microservicesPath)) + { + foreach (var csproj in Directory.GetFiles(microservicesPath, "*.csproj", SearchOption.AllDirectories)) + { + AnsiConsole.MarkupLine($"[grey]Restoring {csproj}[/]"); + await RunProcessAsync("dotnet", $"restore \"{csproj}\" --no-cache --force", workingDirectory: microservicesPath); + } + } +} + +static async Task RunProcessAsync(string fileName, string arguments, bool canFail = false, string workingDirectory = "") { using var process = new Process(); process.StartInfo.FileName = fileName; @@ -210,45 +438,59 @@ static async Task RunProcessAsync(string fileName, string arguments) process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.CreateNoWindow = true; + if (!string.IsNullOrWhiteSpace(workingDirectory)) + { + process.StartInfo.WorkingDirectory = workingDirectory; + } process.Start(); - string output = await process.StandardOutput.ReadToEndAsync(); - string error = await process.StandardError.ReadToEndAsync(); + string output = string.Empty; + try + { + await process.StandardOutput.ReadToEndAsync(); + string error = await process.StandardError.ReadToEndAsync(); - await process.WaitForExitAsync(); + await process.WaitForExitAsync(); - if (process.ExitCode != 0) + if (process.ExitCode != 0) + { + throw new Exception($"Process {fileName} {arguments} failed with exit code {process.ExitCode}. Error: {error}"); + } + } + catch (Exception) { - throw new Exception($"Process {fileName} {arguments} failed with exit code {process.ExitCode}. Error: {error}"); + if (!canFail) + { + throw; + } } return output; } + static async Task BuildOtel(string goPath) { var currentDirectory = Directory.GetCurrentDirectory(); var goBinDir = Path.GetDirectoryName(goPath); - try{ - Directory.SetCurrentDirectory(Path.Combine(currentDirectory,"otel-collector")); + try + { var bashPath = SyncSettingsOptions.GetDefaultUnixShell(); - AnsiConsole.WriteLine("Building Otel Collector..."); - var pathExport = string.IsNullOrEmpty(goBinDir) - ? "" + var pathExport = string.IsNullOrEmpty(goBinDir) + ? "" : $"export PATH=\"$PATH:{goBinDir}\" && "; - await RunProcessAsync(bashPath, $"{pathExport} build.sh --version 0.0.123"); + await RunProcessAsync(bashPath, $"-c \"{pathExport} ./build.sh --version 0.0.123\"", workingDirectory: Path.Combine(currentDirectory, "otel-collector")); AnsiConsole.WriteLine("Building Otel Collector done."); } - finally { - Directory.SetCurrentDirectory(currentDirectory); + finally + { } } static async Task<(bool Installed, string GoPath)> CheckAndInstallGo(bool acceptAnyGoVersion) { bool goInstalled = false; - // Check if Go is installed try { @@ -257,18 +499,18 @@ static async Task BuildOtel(string goPath) if (match.Success) { string installedVersion = match.Groups[1].Value; - Console.WriteLine($"Go is installed with version: {installedVersion}"); + AnsiConsole.WriteLine($"Go is installed with version: {installedVersion}"); if (installedVersion.Contains(GO_VERSION)) { goInstalled = true; - Console.WriteLine("Found GO installation with correct version!"); + AnsiConsole.WriteLine("Found GO installation with correct version!"); } else { goInstalled = true; - Console.WriteLine($"This script needs GO with version {GO_VERSION}, instead found {installedVersion}"); - if(!acceptAnyGoVersion) + AnsiConsole.WriteLine($"This script needs GO with version {GO_VERSION}, instead found {installedVersion}"); + if (!acceptAnyGoVersion) { Environment.Exit(1); } @@ -277,7 +519,7 @@ static async Task BuildOtel(string goPath) } catch { - Console.WriteLine("Go is not installed"); + AnsiConsole.WriteLine("Go is not installed"); } if (!goInstalled) @@ -299,24 +541,27 @@ static async Task BuildOtel(string goPath) try { var brewVersion = await RunProcessAsync("brew", "--version"); - Console.WriteLine($"Homebrew is installed"); - Console.WriteLine($"Version: {brewVersion.Split('\n')[0]}"); + AnsiConsole.WriteLine($"Homebrew is installed"); + if (!string.IsNullOrWhiteSpace(brewVersion.Replace('\n', ' '))) + { + AnsiConsole.WriteLine($"Version: {brewVersion.Replace('\n', ' ')}"); + } } catch { - Console.WriteLine("Homebrew is not installed, please install it before running this script!"); + AnsiConsole.WriteLine("Homebrew is not installed, please install it before running this script!"); Environment.Exit(1); } try { await RunProcessAsync("brew", $"install go@{GO_VERSION}"); - Console.WriteLine($"GO with version {GO_VERSION} was successfully installed!"); + AnsiConsole.WriteLine($"GO with version {GO_VERSION} was successfully installed!"); return (true, "/opt/homebrew/bin/go"); } catch { - Console.WriteLine($"Failed to install GO using Homebrew!"); + AnsiConsole.WriteLine($"Failed to install GO using Homebrew!"); } } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) @@ -325,28 +570,28 @@ static async Task BuildOtel(string goPath) try { var chocoVersion = await RunProcessAsync("choco", "--version"); - Console.WriteLine($"Chocolatey is installed with version: {chocoVersion.Trim()}"); + AnsiConsole.WriteLine($"Chocolatey is installed with version: {chocoVersion.Trim()}"); } catch { - Console.WriteLine("Chocolatey is not installed, please install it before running this script!"); + AnsiConsole.Write("Chocolatey is not installed, please install it before running this script!"); Environment.Exit(1); } try { await RunProcessAsync("choco", $"install golang --version={GO_VERSION} -y"); - Console.WriteLine($"GO with version {GO_VERSION} was successfully installed!"); + AnsiConsole.Write($"GO with version {GO_VERSION} was successfully installed!"); return (true, "C:\\Go\\bin\\go.exe"); } catch { - Console.WriteLine($"Failed to install GO using Chocolatey!"); + AnsiConsole.Write($"Failed to install GO using Chocolatey!"); } } else { - Console.WriteLine($"Unsupported OS"); + AnsiConsole.Write($"Unsupported OS"); Environment.Exit(1); } return (false, ""); @@ -392,7 +637,8 @@ static string EscapeXmlAttribute(string value) .Replace("'", "'"); } -class SetupSettingsOptions { +class SetupSettingsOptions +{ public bool Verbose = false; public bool acceptAnyGoVersion = false; @@ -405,7 +651,8 @@ public void VerboseLog(string message) } } -class SyncSettingsOptions { +class SyncSettingsOptions +{ public bool Verbose = false; public string bash_Path = ""; @@ -445,3 +692,11 @@ public static string GetDefaultUnixShell() } } } + + +class DevOptions +{ + public bool skipUnity = false; + public bool skipUnreal = false; + public bool skipSamsSandbox = false; +} diff --git a/dev.sh b/dev.sh deleted file mode 100755 index fa2639c11b..0000000000 --- a/dev.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash - -# PREREQ: -# Ensure you've run `setup.sh` at least once before running this - -# This script will be run many times as you develop. -# Anytime you need to test a change with new code you've written -# locally, you should run this script. -# -# It will... -# 1. build all the projects that result in Nuget packages, -# 2. publish them locally to the local package feed -# 3. update the local templates -# 4. install the latest CLI globally -# 5. invalidate the nuget cache for local beamable dev packages, which -# means that downstream projects will need to run a `dotnet restore`. - -compliment=$(awk 'BEGIN{srand()} {a[NR]=$0} END{print a[int(rand()*NR)+1]}' compliments.txt) -echo "$compliment" - -# the .dev.env file hosts some common variables -source ./.dev.env - -# idiomatic parameter and option handling in sh -SHOULD_APPLY_TO_UNITY=true -SHOULD_APPLY_TO_UNREAL=true -SHOULD_APPLY_TO_SAMS_SANDBOX=true -while test $# -gt 0 -do - case "$1" in - --skip-unity) SHOULD_APPLY_TO_UNITY=false - echo "skipping unity $1 $SHOULD_APPLY_TO_UNITY" - ;; - --skip-unreal) SHOULD_APPLY_TO_UNREAL=false - echo "skipping unreal $1 $SHOULD_APPLY_TO_UNREAL" - ;; - --skip-sams-sandbox) SHOULD_APPLY_TO_SAMS_SANDBOX=false - echo "skipping sams-sandbox $1 $SHOULD_APPLY_TO_SAMS_SANDBOX" - ;; - *) echo "argument $1" - ;; - esac - shift -done - -# construct a build number -NEXT_BUILD_NUMBER=`cat build-number.txt` -PREVIOUS_BUILD_NUMBER=$NEXT_BUILD_NUMBER -((NEXT_BUILD_NUMBER+=1)) -echo $NEXT_BUILD_NUMBER > build-number.txt - -# the version is the nuget package version that will be built -VERSION=0.0.123.$NEXT_BUILD_NUMBER -PREVIOUS_VERSION=0.0.123.$PREVIOUS_BUILD_NUMBER - -# the build solution only has references to the projects that we actually want to publish -SOLUTION=./build/LocalBuild/LocalBuild.sln -TMP_BUILD_OUTPUT="TempBuild" - -BUILD_ARGS="--configuration Release -p:PackageVersion=$VERSION -p:CombinedVersion=$VERSION -p:InformationalVersion=$VERSION -p:Warn=0 -p:BeamBuild=true" #- -PACK_ARGS="--configuration Release --no-build -o $TMP_BUILD_OUTPUT -p:PackageVersion=$VERSION -p:CombinedVersion=$VERSION -p:InformationalVersion=$VERSION -p:SKIP_GENERATION=true -p:BeamBuild=true" -PUSH_ARGS="--source $FEED_NAME" - -dotnet restore $SOLUTION -dotnet build $SOLUTION $BUILD_ARGS -dotnet build cli/beamable.common -f net10.0 -t:CopyCodeToUnity -p:BEAM_COPY_CODE_TO_UNITY=$SHOULD_APPLY_TO_UNITY -dotnet pack $SOLUTION $PACK_ARGS -dotnet nuget push $TMP_BUILD_OUTPUT/*.$VERSION.nupkg $PUSH_ARGS - -# remove the old package from the nuget feed, so that we don't accumulate millions of packages over time. -DELETE_ARGS="$PREVIOUS_VERSION --source $FEED_NAME --non-interactive" -echo "Deleting package! ------ $DELETE_ARGS" -dotnet nuget delete Beamable.Common $DELETE_ARGS -dotnet nuget delete Beamable.Server.Common $DELETE_ARGS -dotnet nuget delete Beamable.Microservice.Runtime $DELETE_ARGS -dotnet nuget delete Beamable.Microservice.SourceGen $DELETE_ARGS -dotnet nuget delete Beamable.Tooling.Common $DELETE_ARGS -dotnet nuget delete Beamable.UnityEngine $DELETE_ARGS -dotnet nuget delete Beamable.UnityEngine.Addressables $DELETE_ARGS -dotnet nuget delete Beamable.Tools $DELETE_ARGS - - -# install the latest templates. -# frustratingly, it seems like the version of the install command -# that accepts a nuget feed does not work for local package feeds. -dotnet new uninstall Beamable.Templates || true -dotnet new install $TMP_BUILD_OUTPUT/Beamable.Templates.$VERSION.nupkg --force - -# clean up the build artifacts... -rm -rf $TMP_BUILD_OUTPUT - -# remove the cache keys for beamable projects. This makes them break until a restore operation happens. -rm -rf $HOME/.nuget/packages/beamable.*/$PREVIOUS_VERSION - -# install the latest CLI globally. -dotnet tool install Beamable.Tools --version $VERSION --global --allow-downgrade --no-cache - -# restore the nuget packages (and CLI) for a sample project, thus restoring the -# nuget-cache for all projects. -if [ $SHOULD_APPLY_TO_UNITY = true ]; then - echo "Preparing the Unity SDK project to use locally built CLI" - - # generate unity CLI - beam generate-interface --engine unity --output=./client/Packages/com.beamable/Editor/BeamCli/Commands --no-log-file - - cd cli/beamable.templates/templates/BeamService - dotnet tool update Beamable.Tools --version $VERSION --allow-downgrade - dotnet restore BeamService.csproj --no-cache --force - - # Go back to the project root - cd ../../../.. -fi - -# If the user has the Unreal repo as a sibling, we update the version number there too -if [ $SHOULD_APPLY_TO_UNREAL = true ] && [[ -d "../UnrealSDK" ]]; then - echo "Preparing UnrealSDK project to use locally built CLI" - cd ../UnrealSDK - dotnet tool update Beamable.Tools --version $VERSION --allow-downgrade - cd Microservices - for i in `find . -name "*.csproj" -type f`; do - echo "Restoring Microservice Project: $i" - dotnet restore "$i" --no-cache --force - done - cd ../../BeamableProduct -fi - -# If the user has the Unreal repo as a sibling, we update the version number there too -if [ $SHOULD_APPLY_TO_SAMS_SANDBOX = true ] && [[ -d "../SamsLocalSandbox" ]]; then - echo "Preparing the SamsSandbox local project to use locally built CLI" - cd ../SamsLocalSandbox - dotnet tool update Beamable.Tools --version $VERSION --allow-downgrade - for i in `find . -name "*.csproj" -type f`; do - echo "Restoring Microservice Project: $i" - dotnet restore "$i" --no-cache --force - done - cd ../BeamableProduct -fi - From fcce4ad0f0523caac6ae4cd218fcb79c60fa7119 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Fri, 16 Jan 2026 18:55:16 +0100 Subject: [PATCH 04/13] Update jobs --- .github/workflows/buildPR.yml | 65 +++++++++++----------- .github/workflows/generateApi.yml | 12 ++-- .github/workflows/generateUnityCLI.yml | 8 +-- .github/workflows/loadTestMicroservice.yml | 30 +++++----- .github/workflows/release-nuget.yml | 52 +++++++++-------- .github/workflows/release-unity.yml | 57 ++++++++++--------- .github/workflows/release.yml | 30 +++++----- 7 files changed, 124 insertions(+), 130 deletions(-) diff --git a/.github/workflows/buildPR.yml b/.github/workflows/buildPR.yml index be32a81a9f..1419b19ad3 100644 --- a/.github/workflows/buildPR.yml +++ b/.github/workflows/buildPR.yml @@ -3,12 +3,12 @@ name: PR Build on: pull_request: branches: - - 'main' - - 'staging' - - 'productio*' + - "main" + - "staging" + - "productio*" paths-ignore: - - 'rfc/**' - - 'client_installer/**' + - "rfc/**" + - "client_installer/**" env: DOCKER_REGISTRY: ghcr.io @@ -23,7 +23,7 @@ jobs: strategy: max-parallel: 1 matrix: - dotnet-version: ['10.0.x' ] + dotnet-version: ["10.0.x"] steps: - uses: actions/checkout@v4 - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} @@ -58,7 +58,7 @@ jobs: strategy: max-parallel: 1 matrix: - dotnet-version: ['10.0.x' ] + dotnet-version: ["10.0.x"] steps: - uses: actions/checkout@v4 - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} @@ -87,12 +87,12 @@ jobs: strategy: max-parallel: 2 matrix: - dotnet-version: ['10.0.x' ] - runners: [ windows-latest, ubuntu-latest ] + dotnet-version: ["10.0.x"] + runners: [windows-latest, ubuntu-latest] env: BEAM_DOCKER_WINDOWS_CONTAINERS: ${{ matrix.runners == 'windows-latest' && '1' || '0' }} steps: - - name: Check Docker + - name: Check Docker run: docker version - name: Check concurrency run: echo 'cli-pr-${{ github.sha }}-${{ matrix.dotnet-version }}-${{matrix.runners}}' @@ -117,8 +117,8 @@ jobs: working-directory: ./ shell: bash run: | - ./setup.sh - ./dev.sh + ./Setup.cs setup + ./Setup.cs dev - name: Check CLI run: | cat ./build-number.txt @@ -138,7 +138,7 @@ jobs: strategy: max-parallel: 1 matrix: - dotnet-version: [ '10.0.x' ] + dotnet-version: ["10.0.x"] steps: - uses: actions/checkout@v4 - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} @@ -213,7 +213,7 @@ jobs: - name: Create Unity Mapped Values id: unityMap - env: + env: UNITY_MODE: >- ${{ fromJson('{ "playmode": "player", @@ -222,7 +222,6 @@ jobs: run: | echo "UNITY_MODE=$UNITY_MODE" >> "$GITHUB_OUTPUT" - - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} uses: actions/setup-dotnet@v4 with: @@ -235,11 +234,11 @@ jobs: with: go-version: 1.24.1 cache-dependency-path: ./otel-collector/beamable-collector/go.sum - - name: Build and Install BEAM CLI + - name: Build and Install BEAM CLI working-directory: ./ run: | - ./setup.sh - SKIP_GENERATION=true ./dev.sh --skip-unreal + ./Setup.cs setup + ./Setup.cs dev --skip_unreal env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ - name: Check Beam CLI @@ -250,21 +249,21 @@ jobs: - name: Apply Nuget Version to Unity SDK run: | ReleaseSharedCode=true dotnet build ./cli/beamable.common -t:CopyCodeToUnity - - - name: Apply CLI Versions + + - name: Apply CLI Versions run: jq --arg nextVersion 0.0.123.1 '.nugetPackageVersion = $nextVersion' ./client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json > localtmpfile && mv localtmpfile ./client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json - name: Review Unity version-default file run: | cat ./client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json - + - name: Copy the nuget packages into unity working-directory: ./ run: | mkdir -p client/BeamableNugetSource/ ls BeamableNugetSource cp BeamableNugetSource/*.nupkg client/BeamableNugetSource/ - + - name: Cache Unity Folders uses: actions/cache@v3 with: @@ -279,7 +278,7 @@ jobs: # this might remove tools that are actually needed, # if set to "true" but frees about 6 GB tool-cache: false - + # all of these default to true, but feel free to set to # "false" if necessary for your workflow android: true @@ -343,10 +342,10 @@ jobs: with: fetch-depth: 0 lfs: true - + - name: Create Unity Mapped Values id: unityMap - env: + env: UNITY_PLATFORM: >- ${{ fromJson('{ "Android": "android", @@ -357,11 +356,10 @@ jobs: run: | echo "UNITY_PLATFORM=$UNITY_PLATFORM" >> "$GITHUB_OUTPUT" - - - name: Setup .NET Core SDK + - name: Setup .NET Core SDK uses: actions/setup-dotnet@v4 with: - dotnet-version: '10.0.x' + dotnet-version: "10.0.x" - name: Log in to the Container registry uses: docker/login-action@v3 with: @@ -373,11 +371,11 @@ jobs: with: go-version: 1.24.1 cache-dependency-path: ./otel-collector/beamable-collector/go.sum - - name: Build and Install BEAM CLI + - name: Build and Install BEAM CLI working-directory: ./ run: | - ./setup.sh - SKIP_GENERATION=true ./dev.sh + ./Setup.cs setup + ./Setup.cs dev --skip_unreal env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ - name: Check Beam CLI @@ -386,7 +384,7 @@ jobs: - name: Apply Nuget Version to Unity SDK run: | ReleaseSharedCode=true dotnet build ./cli/beamable.common -t:CopyCodeToUnity - + - name: Prepare Config-Defaults run: | chmod +x ./build/create_config_defaults.sh @@ -413,7 +411,7 @@ jobs: # this might remove tools that are actually needed, # if set to "true" but frees about 6 GB tool-cache: false - + # all of these default to true, but feel free to set to # "false" if necessary for your workflow android: true @@ -440,4 +438,3 @@ jobs: allowDirtyBuild: true buildsPath: dist buildMethod: BuildSampleProject.Development - diff --git a/.github/workflows/generateApi.yml b/.github/workflows/generateApi.yml index 37400fabd3..bbb21c6890 100644 --- a/.github/workflows/generateApi.yml +++ b/.github/workflows/generateApi.yml @@ -30,9 +30,9 @@ jobs: ./setup.sh - name: Install dotnet-format run: dotnet tool install --global --version 5.1.250801 dotnet-format - - name: Build CLI + - name: Build CLI run: | - dotnet build ./cli/cli + dotnet build ./cli/cli - name: Generate API run: | dotnet run -f net10.0 --project ./cli/cli -- --host https://dev.api.beamable.com oapi generate --engine unity --conflict-strategy RenameUncommonConflicts --output ./cli/beamable.common/Runtime/OpenApi --cleaning-strategy RemoveCsFiles @@ -40,8 +40,8 @@ jobs: working-directory: ./ shell: bash run: | - ./setup.sh - ./dev.sh + ./Setup.cs setup + ./Setup.cs dev - name: Check for Changes run: echo "any=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT id: changes @@ -52,9 +52,9 @@ jobs: id: cpr if: ${{ steps.changes.outputs.any == 'true' }} with: - commit-message: syncing sdk from openapi + commit-message: syncing sdk from openapi token: ${{secrets.CODEGEN_PR_GITHUB_TOKEN}} - title: Auto generate SDK from openAPI + title: Auto generate SDK from openAPI body: The CLI autogenerated these changes to the SDK branch: update-openapi base: main diff --git a/.github/workflows/generateUnityCLI.yml b/.github/workflows/generateUnityCLI.yml index f52291ff86..75d8d909c9 100644 --- a/.github/workflows/generateUnityCLI.yml +++ b/.github/workflows/generateUnityCLI.yml @@ -45,13 +45,13 @@ jobs: - name: Restore Tools working-directory: ./cli/cli run: | - dotnet tool restore + dotnet tool restore - name: List files (pre) working-directory: ./client/Packages/com.beamable/Editor/BeamCli/Commands run: ls -a - - name: Build CLI + - name: Build CLI run: | - ./dev.sh + ./Setup.cs dev - name: Delete Trash Files working-directory: ./client/Packages/com.beamable/Editor/BeamCli/Commands run: | @@ -68,7 +68,7 @@ jobs: id: cpr if: ${{ steps.changes.outputs.any == 'true' }} with: - commit-message: syncing Unity SDK from CLI + commit-message: syncing Unity SDK from CLI token: ${{secrets.CODEGEN_PR_GITHUB_TOKEN}} title: Unity SDK-CLI Generation body: The CLI autogenerated these changes to the SDK diff --git a/.github/workflows/loadTestMicroservice.yml b/.github/workflows/loadTestMicroservice.yml index c167c5d078..a1e8f4c860 100644 --- a/.github/workflows/loadTestMicroservice.yml +++ b/.github/workflows/loadTestMicroservice.yml @@ -3,11 +3,11 @@ name: Perf Test Microservices on: pull_request: branches: - - 'main' + - "main" paths-ignore: - - 'rfc/**' - - '.github/**' - - 'client_installer/**' + - "rfc/**" + - ".github/**" + - "client_installer/**" jobs: runPerfTest: timeout-minutes: 15 @@ -32,11 +32,11 @@ jobs: - name: Install Dotnet Counters run: | dotnet tool install --global dotnet-counters --version 7.0.447801 - - name: Build and Install BEAM CLI + - name: Build and Install BEAM CLI working-directory: ./ run: | - ./setup.sh - ./dev.sh --skip-unity --skip-unreal + ./Setup.cs setup + ./Setup.cs dev --skip_unreal --skip_unity env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ - name: Restore tool @@ -46,17 +46,17 @@ jobs: - name: Check BEAM CLI working-directory: ./stress-tests/standalone-microservice run: | - dotnet beam config -q --logs v - + dotnet beam config -q --logs v + - name: Login to BEAM CLI working-directory: ./stress-tests/standalone-microservice run: | dotnet beam login --username ${{ secrets.BEAM_STRESSTEST_EMAIL }} --password ${{ secrets.BEAM_STRESSTEST_PASS }} --save-to-file -q --logs v - + - name: Update Nuget working-directory: ./stress-tests/standalone-microservice run: | - dotnet restore + dotnet restore - name: Build Microservice working-directory: ./stress-tests/standalone-microservice/services/standalone-microservice @@ -66,16 +66,16 @@ jobs: working-directory: ./stress-tests/standalone-microservice/services/ run: | cd ./standalone-microservice/bin/Debug/net10.0 - + echo "starting counters" mkdir ../../../../reports dotnet-counters collect --diagnostic-port ~/myport.sock --refresh-interval 3 --format json --output ../../../../reports/counter.json & - + echo "starting service" mkdir ../../../../logs BEAM_DISABLE_STANDARD_OTEL=1 LOG_PATH=../../../../logs/serviceRuntime.log DOTNET_DiagnosticPorts=~/myport.sock ./standalone-microservice & - + echo "starting profiler" cd ../../../.. echo '{"a":3,"b":4}' > payload.json @@ -89,7 +89,7 @@ jobs: echo "showing logs" cat ./logs/serviceRuntime.log cp ./logs/serviceRuntime.log ./reports/serviceRuntime.log - - name: Save Profiler Data + - name: Save Profiler Data uses: actions/upload-artifact@v4 with: name: profiler diff --git a/.github/workflows/release-nuget.yml b/.github/workflows/release-nuget.yml index c3d3c15ac1..a9bf185044 100644 --- a/.github/workflows/release-nuget.yml +++ b/.github/workflows/release-nuget.yml @@ -60,9 +60,9 @@ jobs: echo patch=${{ inputs.patch }} echo rc=${{ inputs.rcNumber }} echo releaseType=${{ inputs.releaseType }} - + - uses: actions/checkout@v4 - with: + with: ref: ${{ github.event.inputs.commit }} - name: Setup .NET Core SDK @@ -72,7 +72,7 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version: "20.x" registry-url: >- ${{ fromJson('{ "nightly": "https://nexus.beamable.com/nexus/content/repositories/unity-dev", @@ -80,7 +80,7 @@ jobs: "exp": "https://nexus.beamable.com/nexus/content/repositories/unity-preview", "production": "https://nexus.beamable.com/nexus/content/repositories/unity" }')[github.event.inputs.releaseType] }} - + - name: Install JQ run: | sudo apt-get update @@ -100,13 +100,13 @@ jobs: - name: Add collector version run: | - sh ./build/bin/set-collector-version-property.sh + sh ./build/bin/set-collector-version-property.sh - name: Install CLI working-directory: ./ run: | - bash ./setup.sh - bash ./dev.sh + ./Setup.cs setup + ./Setup.cs dev env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ @@ -116,25 +116,25 @@ jobs: beam version construct 0 0 0 --nightly --logs v - name: Get Version Number (Nightly) - if: ${{ inputs.releaseType == 'nightly' }} + if: ${{ inputs.releaseType == 'nightly' }} run: | beam version construct 0 0 0 --nightly > version.txt - + - name: Get Version Number (RC) - if: ${{ inputs.releaseType == 'rc' }} + if: ${{ inputs.releaseType == 'rc' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --rc ${{ inputs.rcNumber }} > version.txt - + - name: Get Version Number (Exp) - if: ${{ inputs.releaseType == 'exp' }} + if: ${{ inputs.releaseType == 'exp' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --exp ${{ inputs.rcNumber }} > version.txt - + - name: Get Version Number (Prod) - if: ${{ inputs.releaseType == 'production' }} + if: ${{ inputs.releaseType == 'production' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --prod > version.txt - + - name: Store version number as output id: version - env: + env: BUILD_ENV: >- ${{ fromJson('{ "nightly": "dev", @@ -155,7 +155,6 @@ jobs: echo version suffix=${{ steps.version.outputs.VERSION_SUFFIX }} echo build-env=${{steps.version.outputs.BUILD_ENV}} - - name: Compress Collector Files working-directory: otel-bin run: find . -type f ! -name '*.gz' -exec gzip -k -9 {} \; @@ -165,22 +164,21 @@ jobs: working-directory: otel-bin run: | AWS_ACCESS_KEY_ID=${{secrets.AWS_KEY_ID}} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} AWS_REGION=us-west-2 aws s3 cp --recursive ./ s3://beamable-otel-collector-ch/version/${{ steps.version.outputs.VERSION }} --exclude "*" --include "*.gz" --acl public-read - + # Invalidate the CDN for collector builds - - name: Prepare Cloudfront Invalidation + - name: Prepare Cloudfront Invalidation run: | CLOUD_DISTRO=E3S54OWVMS4PQH CALLER_REFERENCE=$(date -u +"%Y%m%d%H%M%S") echo '{"DistributionId":"'${CLOUD_DISTRO}'","InvalidationBatch":{"CallerReference":"'${CALLER_REFERENCE}'","Paths":{"Quantity":1,"Items":["/${{ steps.setTriggerContext.outputs.triggerContext }}/*"]}}}' >> cloudfront-invalidation.json - - name: Preview Cloudfront Invalidation + - name: Preview Cloudfront Invalidation run: | cat cloudfront-invalidation.json - name: Do Cloudfront Invalidation run: AWS_ACCESS_KEY_ID=${{secrets.AWS_KEY_ID}} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} AWS_REGION=us-west-2 aws cloudfront create-invalidation --cli-input-json file://cloudfront-invalidation.json - - name: Publish Nuget Packages - if: ${{ inputs.dryRun == false }} + if: ${{ inputs.dryRun == false }} run: sh ./build/bin/release-nuget.sh env: VERSION: ${{ steps.version.outputs.VERSION }} @@ -190,12 +188,12 @@ jobs: NUGET_TOOLS_KEY: ${{ secrets.NUGET_TOOLS_KEY }} - name: Publish Changelog - if: ${{ inputs.dryRun == false }} + if: ${{ inputs.dryRun == false }} run: sh ./build/bin/upload-changelogs.sh env: - COPY_UNITY_SDK: 'false' - COPY_CLI: 'true' - COPY_WEB_SDK: 'false' + COPY_UNITY_SDK: "false" + COPY_CLI: "true" + COPY_WEB_SDK: "false" VERSION: ${{ steps.version.outputs.VERSION }} GITHUB_USERNAME: ${{ secrets.GIT_CHANGELOGS_USERNAME }} GITHUB_PASSWORD: ${{ secrets.GIT_CHANGELOGS_PASSWORD }} @@ -209,7 +207,7 @@ jobs: - name: Create Release id: create_release - if: ${{ inputs.dryRun == false }} + if: ${{ inputs.dryRun == false }} uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token diff --git a/.github/workflows/release-unity.yml b/.github/workflows/release-unity.yml index 947497dc56..3b3e0913d3 100644 --- a/.github/workflows/release-unity.yml +++ b/.github/workflows/release-unity.yml @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-latest permissions: id-token: write - contents: write + contents: write packages: read concurrency: group: release-unity-sdk @@ -72,9 +72,9 @@ jobs: echo patch=${{ inputs.patch }} echo rc=${{ inputs.rcNumber }} echo releaseType=${{ inputs.releaseType }} - + - uses: actions/checkout@v4 - with: + with: ref: ${{ github.event.inputs.commit }} - name: Log in to the Container registry @@ -91,9 +91,9 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: '20.x' - registry-url: 'https://registry.npmjs.org' - + node-version: "20.x" + registry-url: "https://registry.npmjs.org" + - name: Update npm run: npm install -g npm@latest - name: Check Npm version @@ -118,36 +118,36 @@ jobs: - name: Add collector version run: | - sh ./build/bin/set-collector-version-property.sh + sh ./build/bin/set-collector-version-property.sh - name: Install CLI working-directory: ./ run: | - bash ./setup.sh - bash ./dev.sh + ./Setup.cs setup + ./Setup.cs dev - name: Check CLI run: beam version - name: Get Version Number (Nightly) - if: ${{ inputs.releaseType == 'nightly' }} + if: ${{ inputs.releaseType == 'nightly' }} run: beam version construct 0 0 0 --nightly > version.txt - + - name: Get Version Number (RC) - if: ${{ inputs.releaseType == 'rc' }} + if: ${{ inputs.releaseType == 'rc' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --rc ${{ inputs.rcNumber }} > version.txt - + - name: Get Version Number (Exp) - if: ${{ inputs.releaseType == 'exp' }} + if: ${{ inputs.releaseType == 'exp' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --exp ${{ inputs.rcNumber }} > version.txt - + - name: Get Version Number (Prod) - if: ${{ inputs.releaseType == 'production' }} + if: ${{ inputs.releaseType == 'production' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --prod > version.txt - + - name: Store version number as output id: version - env: + env: NPM_TAG: >- ${{ fromJson('{ "nightly": "--tag nightly", @@ -191,7 +191,7 @@ jobs: env: VERSION: ${{ steps.version.outputs.VERSION }} ENVIRONMENT: ${{steps.version.outputs.BUILD_ENV}} - + - name: Apply Nuget Version to Unity SDK run: | beam unity download-all-nuget-packages ./client --logs v @@ -199,7 +199,7 @@ jobs: - name: Prepare Unity Samples run: sh ./../../../build/bin/prepare-samples.sh working-directory: ./client/Packages/com.beamable/ - + - name: Update UPM Versions (com.beamable) run: npm version ${{ steps.version.outputs.VERSION }} working-directory: ./client/Packages/com.beamable/ @@ -220,7 +220,6 @@ jobs: ls ./client/Packages/com.beamable ls ./client/Packages/com.beamable/Samples~ cat client/Packages/com.beamable/package.json - - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main @@ -228,7 +227,7 @@ jobs: # this might remove tools that are actually needed, # if set to "true" but frees about 6 GB tool-cache: false - + # all of these default to true, but feel free to set to # "false" if necessary for your workflow android: true @@ -274,7 +273,7 @@ jobs: if: ${{ inputs.dryRun == false }} run: npm publish ./com.beamable/com.beamable-${{ steps.version.outputs.VERSION }}.tgz ${{steps.version.outputs.NPM_TAG}} working-directory: ./client/build/package_dist/ - env: + env: NODE_AUTH_TOKEN: ${{ secrets.NEXUS_NPM_AUTH }} NPM_AUTH: ${{secrets.NEXUS_NPM_AUTH}} NPM_REGISTRY: ${{steps.version.outputs.NEXUS_REG}} @@ -290,18 +289,18 @@ jobs: if: ${{ inputs.dryRun == false }} run: npm publish ${{steps.version.outputs.NPM_TAG}} working-directory: ./client/Packages/com.beamable.server - env: + env: NODE_AUTH_TOKEN: ${{ secrets.NEXUS_NPM_AUTH }} NPM_AUTH: ${{secrets.NEXUS_NPM_AUTH}} NPM_REGISTRY: ${{steps.version.outputs.NEXUS_REG}} - name: Publish Changelog - if: ${{ inputs.dryRun == false }} + if: ${{ inputs.dryRun == false }} run: sh ./build/bin/upload-changelogs.sh env: - COPY_UNITY_SDK: 'true' - COPY_CLI: 'false' - COPY_WEB_SDK: 'false' + COPY_UNITY_SDK: "true" + COPY_CLI: "false" + COPY_WEB_SDK: "false" VERSION: ${{ steps.version.outputs.VERSION }} GITHUB_USERNAME: ${{ secrets.GIT_CHANGELOGS_USERNAME }} GITHUB_PASSWORD: ${{ secrets.GIT_CHANGELOGS_PASSWORD }} @@ -315,7 +314,7 @@ jobs: - name: Create Release id: create_release - if: ${{ inputs.dryRun == false }} + if: ${{ inputs.dryRun == false }} uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1937981383..70c3455d42 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release Custom SDK and CLI +name: Release Custom SDK and CLI on: workflow_dispatch: @@ -26,9 +26,9 @@ jobs: run: | echo dryRun=${{ inputs.dryRun }} echo commit=${{ inputs.commit }} - + - uses: actions/checkout@v4 - with: + with: ref: ${{ github.event.inputs.commit }} - name: Setup .NET Core SDK @@ -38,9 +38,9 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version: "20.x" registry-url: https://nexus.beamable.com/nexus/content/repositories/unity-dev - + - name: Install JQ run: | sudo apt-get update @@ -49,23 +49,23 @@ jobs: - name: Add collector version run: | - sh ./build/bin/set-collector-version-property.sh + sh ./build/bin/set-collector-version-property.sh - name: Install CLI working-directory: ./ run: | - bash ./setup.sh - bash ./dev.sh + ./Setup.cs setup + ./Setup.cs dev - name: Check CLI run: beam version - - name: Get Version Number + - name: Get Version Number run: beam version construct 0 0 0 --nightly > ./version.txt - + - name: Store version number as output id: version - env: + env: BUILD_ENV: dev run: | echo "VERSION=$(cat version.txt | jq -r .data.versionString)" >> "$GITHUB_OUTPUT" @@ -94,7 +94,7 @@ jobs: env: VERSION: ${{ steps.version.outputs.VERSION }} ENVIRONMENT: ${{steps.version.outputs.BUILD_ENV}} - + - name: Apply Nuget Version run: jq --arg nextVersion ${{ steps.version.outputs.VERSION }} '.nugetPackageVersion = $nextVersion' ./client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json > localtmpfile && mv localtmpfile ./client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json @@ -114,7 +114,7 @@ jobs: - name: Prepare Unity Samples run: sh ./../../../build/bin/prepare-samples.sh working-directory: ./client/Packages/com.beamable/ - + - name: Update UPM Versions (com.beamable) run: npm version ${{ steps.version.outputs.VERSION }} working-directory: ./client/Packages/com.beamable/ @@ -136,7 +136,7 @@ jobs: if: ${{ inputs.dryRun == false }} run: npm publish working-directory: ./client/Packages/com.beamable - env: + env: NODE_AUTH_TOKEN: ${{ secrets.NEXUS_NPM_AUTH }} NPM_AUTH: ${{secrets.NEXUS_NPM_AUTH}} @@ -144,6 +144,6 @@ jobs: if: ${{ inputs.dryRun == false }} run: npm publish working-directory: ./client/Packages/com.beamable.server - env: + env: NODE_AUTH_TOKEN: ${{ secrets.NEXUS_NPM_AUTH }} NPM_AUTH: ${{secrets.NEXUS_NPM_AUTH}} From ab8a2fe0dc291924900f8c550820af53475dbd11 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Fri, 16 Jan 2026 18:59:04 +0100 Subject: [PATCH 05/13] das --- .github/workflows/buildPR.yml | 12 ++++++------ .github/workflows/generateApi.yml | 4 ++-- .github/workflows/generateUnityCLI.yml | 2 +- .github/workflows/loadTestMicroservice.yml | 4 ++-- .github/workflows/release-nuget.yml | 4 ++-- .github/workflows/release-unity.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/buildPR.yml b/.github/workflows/buildPR.yml index 1419b19ad3..78f768c0f7 100644 --- a/.github/workflows/buildPR.yml +++ b/.github/workflows/buildPR.yml @@ -117,8 +117,8 @@ jobs: working-directory: ./ shell: bash run: | - ./Setup.cs setup - ./Setup.cs dev + dotnet run Setup.cs setup + dotnet run Setup.cs dev - name: Check CLI run: | cat ./build-number.txt @@ -237,8 +237,8 @@ jobs: - name: Build and Install BEAM CLI working-directory: ./ run: | - ./Setup.cs setup - ./Setup.cs dev --skip_unreal + dotnet run Setup.cs setup + dotnet run Setup.cs dev --skip_unreal env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ - name: Check Beam CLI @@ -374,8 +374,8 @@ jobs: - name: Build and Install BEAM CLI working-directory: ./ run: | - ./Setup.cs setup - ./Setup.cs dev --skip_unreal + dotnet run Setup.cs setup + dotnet run Setup.cs dev --skip_unreal env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ - name: Check Beam CLI diff --git a/.github/workflows/generateApi.yml b/.github/workflows/generateApi.yml index bbb21c6890..7466d9977e 100644 --- a/.github/workflows/generateApi.yml +++ b/.github/workflows/generateApi.yml @@ -40,8 +40,8 @@ jobs: working-directory: ./ shell: bash run: | - ./Setup.cs setup - ./Setup.cs dev + dotnet run Setup.cs setup + dotnet run Setup.cs dev - name: Check for Changes run: echo "any=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT id: changes diff --git a/.github/workflows/generateUnityCLI.yml b/.github/workflows/generateUnityCLI.yml index 75d8d909c9..b6a487ea54 100644 --- a/.github/workflows/generateUnityCLI.yml +++ b/.github/workflows/generateUnityCLI.yml @@ -51,7 +51,7 @@ jobs: run: ls -a - name: Build CLI run: | - ./Setup.cs dev + dotnet run Setup.cs dev - name: Delete Trash Files working-directory: ./client/Packages/com.beamable/Editor/BeamCli/Commands run: | diff --git a/.github/workflows/loadTestMicroservice.yml b/.github/workflows/loadTestMicroservice.yml index a1e8f4c860..8e48c02bd6 100644 --- a/.github/workflows/loadTestMicroservice.yml +++ b/.github/workflows/loadTestMicroservice.yml @@ -35,8 +35,8 @@ jobs: - name: Build and Install BEAM CLI working-directory: ./ run: | - ./Setup.cs setup - ./Setup.cs dev --skip_unreal --skip_unity + dotnet run Setup.cs setup + dotnet run Setup.cs dev --skip_unreal --skip_unity env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ - name: Restore tool diff --git a/.github/workflows/release-nuget.yml b/.github/workflows/release-nuget.yml index a9bf185044..06f5f8c99d 100644 --- a/.github/workflows/release-nuget.yml +++ b/.github/workflows/release-nuget.yml @@ -105,8 +105,8 @@ jobs: - name: Install CLI working-directory: ./ run: | - ./Setup.cs setup - ./Setup.cs dev + dotnet run Setup.cs setup + dotnet run Setup.cs dev env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ diff --git a/.github/workflows/release-unity.yml b/.github/workflows/release-unity.yml index 3b3e0913d3..bb9a375740 100644 --- a/.github/workflows/release-unity.yml +++ b/.github/workflows/release-unity.yml @@ -123,8 +123,8 @@ jobs: - name: Install CLI working-directory: ./ run: | - ./Setup.cs setup - ./Setup.cs dev + dotnet run Setup.cs setup + dotnet run Setup.cs dev - name: Check CLI run: beam version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70c3455d42..49bbbff7af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,8 +54,8 @@ jobs: - name: Install CLI working-directory: ./ run: | - ./Setup.cs setup - ./Setup.cs dev + dotnet run Setup.cs setup + dotnet run Setup.cs dev - name: Check CLI run: beam version From 9ee8d14394aee1f75396aac7f3da0da0c1c4e209 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Fri, 16 Jan 2026 19:05:18 +0100 Subject: [PATCH 06/13] Update Setup.cs --- Setup.cs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Setup.cs b/Setup.cs index 0f93c4a74a..59131ad9c2 100755 --- a/Setup.cs +++ b/Setup.cs @@ -353,7 +353,7 @@ static void RandomCompliment() if (!File.Exists(buildNumberPath)) { AnsiConsole.MarkupLine("[bold][red]Error[/][/] No [bold]build-number.txt[/] file found."); - AnsiConsole.MarkupLine("Call [bold]./Setup.cs setup[/] first."); + AnsiConsole.MarkupLine("Call [bold]dotnet run Setup.cs setup[/] first."); Environment.Exit(1); } int current = int.Parse(File.ReadAllText(buildNumberPath).Trim()); @@ -589,6 +589,32 @@ static async Task BuildOtel(string goPath) AnsiConsole.Write($"Failed to install GO using Chocolatey!"); } } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + try + { + await RunProcessAsync("apt-get", "--version"); + AnsiConsole.WriteLine("apt-get is available"); + } + catch + { + AnsiConsole.WriteLine("apt-get is not available, trying with sudo..."); + } + + try + { + await RunProcessAsync("wget", $"https://go.dev/dl/go{GO_VERSION}.linux-amd64.tar.gz"); + AnsiConsole.WriteLine($"GO with version {GO_VERSION} was successfully downloaded!"); + await RunProcessAsync("sudo", $"rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go{GO_VERSION}.linux-amd64.tar.gz"); + await RunProcessAsync("rm", $"go{GO_VERSION}.linux-amd64.tar.gz"); + AnsiConsole.WriteLine($"GO with version {GO_VERSION} was successfully installed!"); + return (true, "/usr/local/go/bin/go"); + } + catch + { + AnsiConsole.WriteLine($"Failed to install GO using wget!"); + } + } else { AnsiConsole.Write($"Unsupported OS"); From d4076352327bbb40ed631874c7b63fb0de057139 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Fri, 16 Jan 2026 19:16:16 +0100 Subject: [PATCH 07/13] Update Setup.cs --- Setup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup.cs b/Setup.cs index 59131ad9c2..ea83c56abc 100755 --- a/Setup.cs +++ b/Setup.cs @@ -52,7 +52,7 @@ void Setup(SetupSettingsOptions cfg) // Load environment variables from .dev.env file LoadDevEnvironment(); string root = GetRootDirectory(); - string sourceFolderPath = Path.Combine(root, Environment.GetEnvironmentVariable("SOURCE_FOLDER") ?? ""); + string sourceFolderPath = Path.Combine(root, Environment.GetEnvironmentVariable("SOURCE_FOLDER") ?? "").Replace("\\", "/"); if (File.Exists(Path.Combine(root, "build-number.txt")) && !AnsiConsole.Confirm("Looks like the installation was attempted before. Continue with installation?")) From 4ae7e5d7b6b0e25d63ba38cc675ca0b8d45b66c4 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Fri, 16 Jan 2026 19:16:53 +0100 Subject: [PATCH 08/13] Update Setup.cs --- Setup.cs | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/Setup.cs b/Setup.cs index ea83c56abc..c08ac1a18e 100755 --- a/Setup.cs +++ b/Setup.cs @@ -589,37 +589,7 @@ static async Task BuildOtel(string goPath) AnsiConsole.Write($"Failed to install GO using Chocolatey!"); } } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - try - { - await RunProcessAsync("apt-get", "--version"); - AnsiConsole.WriteLine("apt-get is available"); - } - catch - { - AnsiConsole.WriteLine("apt-get is not available, trying with sudo..."); - } - try - { - await RunProcessAsync("wget", $"https://go.dev/dl/go{GO_VERSION}.linux-amd64.tar.gz"); - AnsiConsole.WriteLine($"GO with version {GO_VERSION} was successfully downloaded!"); - await RunProcessAsync("sudo", $"rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go{GO_VERSION}.linux-amd64.tar.gz"); - await RunProcessAsync("rm", $"go{GO_VERSION}.linux-amd64.tar.gz"); - AnsiConsole.WriteLine($"GO with version {GO_VERSION} was successfully installed!"); - return (true, "/usr/local/go/bin/go"); - } - catch - { - AnsiConsole.WriteLine($"Failed to install GO using wget!"); - } - } - else - { - AnsiConsole.Write($"Unsupported OS"); - Environment.Exit(1); - } return (false, ""); } From de622705715e9e3ee82d555f06edb9e846de847b Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Fri, 16 Jan 2026 19:26:47 +0100 Subject: [PATCH 09/13] Update Setup.cs --- Setup.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Setup.cs b/Setup.cs index c08ac1a18e..f71d20ce10 100755 --- a/Setup.cs +++ b/Setup.cs @@ -52,13 +52,13 @@ void Setup(SetupSettingsOptions cfg) // Load environment variables from .dev.env file LoadDevEnvironment(); string root = GetRootDirectory(); - string sourceFolderPath = Path.Combine(root, Environment.GetEnvironmentVariable("SOURCE_FOLDER") ?? "").Replace("\\", "/"); if (File.Exists(Path.Combine(root, "build-number.txt")) && !AnsiConsole.Confirm("Looks like the installation was attempted before. Continue with installation?")) { return; } + string sourceFolderPath = Path.GetFullPath(Path.Combine(root, Environment.GetEnvironmentVariable("SOURCE_FOLDER") ?? "")); AnsiConsole.Status() @@ -73,7 +73,7 @@ void Setup(SetupSettingsOptions cfg) await RunProcessAsync("dotnet", $"tool restore --tool-manifest ./cli/cli/.config/dotnet-tools.json"); ctx.Status($"Setting up {feedName} at {sourceFolderPath}"); await SetupNuGetSource(sourceFolderPath, feedName); - AnsiConsole.Write($"Setting up {feedName} at {sourceFolderPath} complete"); + AnsiConsole.WriteLine($"Setting up {feedName} at {sourceFolderPath} complete"); ctx.Status("Building otel-collector"); await BuildOtel(goPath); @@ -226,15 +226,8 @@ static async Task SetupNuGetSource(string sourceFolderPath, string feedName) Directory.CreateDirectory(sourceFolderPath); // Remove old NuGet source - AnsiConsole.Write("Removing old source (if none exists, you'll see an error 'Unable to find any package', but that is okay)"); - try - { - await RunProcessAsync("dotnet", $"nuget remove source {feedName}"); - } - catch - { - // Ignore errors when removing non-existent source - } + AnsiConsole.Write("Removing old nuget sources"); + await RunProcessAsync("dotnet", $"nuget remove source {feedName}", true); // Add new source AnsiConsole.Write("Adding new source!"); From d6164b31a9a0cef06fbe347e4d08c4d74cfd735e Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Fri, 16 Jan 2026 19:34:52 +0100 Subject: [PATCH 10/13] Minor script fixes --- Setup.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Setup.cs b/Setup.cs index f71d20ce10..0d2d3fca1b 100755 --- a/Setup.cs +++ b/Setup.cs @@ -226,11 +226,11 @@ static async Task SetupNuGetSource(string sourceFolderPath, string feedName) Directory.CreateDirectory(sourceFolderPath); // Remove old NuGet source - AnsiConsole.Write("Removing old nuget sources"); + AnsiConsole.WriteLine("Removing old nuget sources"); await RunProcessAsync("dotnet", $"nuget remove source {feedName}", true); // Add new source - AnsiConsole.Write("Adding new source!"); + AnsiConsole.WriteLine("Adding new source!"); await RunProcessAsync("dotnet", $"nuget add source \"{sourceFolderPath}\" --name {feedName}"); } @@ -567,19 +567,19 @@ static async Task BuildOtel(string goPath) } catch { - AnsiConsole.Write("Chocolatey is not installed, please install it before running this script!"); + AnsiConsole.WriteLine("Chocolatey is not installed, please install it before running this script!"); Environment.Exit(1); } try { await RunProcessAsync("choco", $"install golang --version={GO_VERSION} -y"); - AnsiConsole.Write($"GO with version {GO_VERSION} was successfully installed!"); + AnsiConsole.WriteLine($"GO with version {GO_VERSION} was successfully installed!"); return (true, "C:\\Go\\bin\\go.exe"); } catch { - AnsiConsole.Write($"Failed to install GO using Chocolatey!"); + AnsiConsole.WriteLine($"Failed to install GO using Chocolatey!"); } } From be48f1f7e5cbb3fa217abb41d680a3cff102d2a7 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Thu, 22 Jan 2026 15:52:16 +0100 Subject: [PATCH 11/13] Restore old scripts --- .github/workflows/buildPR.yml | 65 ++++----- .github/workflows/generateApi.yml | 12 +- .github/workflows/generateUnityCLI.yml | 8 +- .github/workflows/loadTestMicroservice.yml | 30 ++-- .github/workflows/release-nuget.yml | 52 +++---- .github/workflows/release-unity.yml | 57 ++++---- .github/workflows/release.yml | 30 ++-- format-code.bat | 4 + format-code.sh | 7 + setup.sh | 154 +++++++++++++++++++++ sync-rider-run-settings.sh | 83 +++++++++++ 11 files changed, 378 insertions(+), 124 deletions(-) create mode 100644 format-code.bat create mode 100755 format-code.sh create mode 100755 setup.sh create mode 100644 sync-rider-run-settings.sh diff --git a/.github/workflows/buildPR.yml b/.github/workflows/buildPR.yml index 78f768c0f7..be32a81a9f 100644 --- a/.github/workflows/buildPR.yml +++ b/.github/workflows/buildPR.yml @@ -3,12 +3,12 @@ name: PR Build on: pull_request: branches: - - "main" - - "staging" - - "productio*" + - 'main' + - 'staging' + - 'productio*' paths-ignore: - - "rfc/**" - - "client_installer/**" + - 'rfc/**' + - 'client_installer/**' env: DOCKER_REGISTRY: ghcr.io @@ -23,7 +23,7 @@ jobs: strategy: max-parallel: 1 matrix: - dotnet-version: ["10.0.x"] + dotnet-version: ['10.0.x' ] steps: - uses: actions/checkout@v4 - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} @@ -58,7 +58,7 @@ jobs: strategy: max-parallel: 1 matrix: - dotnet-version: ["10.0.x"] + dotnet-version: ['10.0.x' ] steps: - uses: actions/checkout@v4 - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} @@ -87,12 +87,12 @@ jobs: strategy: max-parallel: 2 matrix: - dotnet-version: ["10.0.x"] - runners: [windows-latest, ubuntu-latest] + dotnet-version: ['10.0.x' ] + runners: [ windows-latest, ubuntu-latest ] env: BEAM_DOCKER_WINDOWS_CONTAINERS: ${{ matrix.runners == 'windows-latest' && '1' || '0' }} steps: - - name: Check Docker + - name: Check Docker run: docker version - name: Check concurrency run: echo 'cli-pr-${{ github.sha }}-${{ matrix.dotnet-version }}-${{matrix.runners}}' @@ -117,8 +117,8 @@ jobs: working-directory: ./ shell: bash run: | - dotnet run Setup.cs setup - dotnet run Setup.cs dev + ./setup.sh + ./dev.sh - name: Check CLI run: | cat ./build-number.txt @@ -138,7 +138,7 @@ jobs: strategy: max-parallel: 1 matrix: - dotnet-version: ["10.0.x"] + dotnet-version: [ '10.0.x' ] steps: - uses: actions/checkout@v4 - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} @@ -213,7 +213,7 @@ jobs: - name: Create Unity Mapped Values id: unityMap - env: + env: UNITY_MODE: >- ${{ fromJson('{ "playmode": "player", @@ -222,6 +222,7 @@ jobs: run: | echo "UNITY_MODE=$UNITY_MODE" >> "$GITHUB_OUTPUT" + - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} uses: actions/setup-dotnet@v4 with: @@ -234,11 +235,11 @@ jobs: with: go-version: 1.24.1 cache-dependency-path: ./otel-collector/beamable-collector/go.sum - - name: Build and Install BEAM CLI + - name: Build and Install BEAM CLI working-directory: ./ run: | - dotnet run Setup.cs setup - dotnet run Setup.cs dev --skip_unreal + ./setup.sh + SKIP_GENERATION=true ./dev.sh --skip-unreal env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ - name: Check Beam CLI @@ -249,21 +250,21 @@ jobs: - name: Apply Nuget Version to Unity SDK run: | ReleaseSharedCode=true dotnet build ./cli/beamable.common -t:CopyCodeToUnity - - - name: Apply CLI Versions + + - name: Apply CLI Versions run: jq --arg nextVersion 0.0.123.1 '.nugetPackageVersion = $nextVersion' ./client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json > localtmpfile && mv localtmpfile ./client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json - name: Review Unity version-default file run: | cat ./client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json - + - name: Copy the nuget packages into unity working-directory: ./ run: | mkdir -p client/BeamableNugetSource/ ls BeamableNugetSource cp BeamableNugetSource/*.nupkg client/BeamableNugetSource/ - + - name: Cache Unity Folders uses: actions/cache@v3 with: @@ -278,7 +279,7 @@ jobs: # this might remove tools that are actually needed, # if set to "true" but frees about 6 GB tool-cache: false - + # all of these default to true, but feel free to set to # "false" if necessary for your workflow android: true @@ -342,10 +343,10 @@ jobs: with: fetch-depth: 0 lfs: true - + - name: Create Unity Mapped Values id: unityMap - env: + env: UNITY_PLATFORM: >- ${{ fromJson('{ "Android": "android", @@ -356,10 +357,11 @@ jobs: run: | echo "UNITY_PLATFORM=$UNITY_PLATFORM" >> "$GITHUB_OUTPUT" - - name: Setup .NET Core SDK + + - name: Setup .NET Core SDK uses: actions/setup-dotnet@v4 with: - dotnet-version: "10.0.x" + dotnet-version: '10.0.x' - name: Log in to the Container registry uses: docker/login-action@v3 with: @@ -371,11 +373,11 @@ jobs: with: go-version: 1.24.1 cache-dependency-path: ./otel-collector/beamable-collector/go.sum - - name: Build and Install BEAM CLI + - name: Build and Install BEAM CLI working-directory: ./ run: | - dotnet run Setup.cs setup - dotnet run Setup.cs dev --skip_unreal + ./setup.sh + SKIP_GENERATION=true ./dev.sh env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ - name: Check Beam CLI @@ -384,7 +386,7 @@ jobs: - name: Apply Nuget Version to Unity SDK run: | ReleaseSharedCode=true dotnet build ./cli/beamable.common -t:CopyCodeToUnity - + - name: Prepare Config-Defaults run: | chmod +x ./build/create_config_defaults.sh @@ -411,7 +413,7 @@ jobs: # this might remove tools that are actually needed, # if set to "true" but frees about 6 GB tool-cache: false - + # all of these default to true, but feel free to set to # "false" if necessary for your workflow android: true @@ -438,3 +440,4 @@ jobs: allowDirtyBuild: true buildsPath: dist buildMethod: BuildSampleProject.Development + diff --git a/.github/workflows/generateApi.yml b/.github/workflows/generateApi.yml index 7466d9977e..37400fabd3 100644 --- a/.github/workflows/generateApi.yml +++ b/.github/workflows/generateApi.yml @@ -30,9 +30,9 @@ jobs: ./setup.sh - name: Install dotnet-format run: dotnet tool install --global --version 5.1.250801 dotnet-format - - name: Build CLI + - name: Build CLI run: | - dotnet build ./cli/cli + dotnet build ./cli/cli - name: Generate API run: | dotnet run -f net10.0 --project ./cli/cli -- --host https://dev.api.beamable.com oapi generate --engine unity --conflict-strategy RenameUncommonConflicts --output ./cli/beamable.common/Runtime/OpenApi --cleaning-strategy RemoveCsFiles @@ -40,8 +40,8 @@ jobs: working-directory: ./ shell: bash run: | - dotnet run Setup.cs setup - dotnet run Setup.cs dev + ./setup.sh + ./dev.sh - name: Check for Changes run: echo "any=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT id: changes @@ -52,9 +52,9 @@ jobs: id: cpr if: ${{ steps.changes.outputs.any == 'true' }} with: - commit-message: syncing sdk from openapi + commit-message: syncing sdk from openapi token: ${{secrets.CODEGEN_PR_GITHUB_TOKEN}} - title: Auto generate SDK from openAPI + title: Auto generate SDK from openAPI body: The CLI autogenerated these changes to the SDK branch: update-openapi base: main diff --git a/.github/workflows/generateUnityCLI.yml b/.github/workflows/generateUnityCLI.yml index b6a487ea54..f52291ff86 100644 --- a/.github/workflows/generateUnityCLI.yml +++ b/.github/workflows/generateUnityCLI.yml @@ -45,13 +45,13 @@ jobs: - name: Restore Tools working-directory: ./cli/cli run: | - dotnet tool restore + dotnet tool restore - name: List files (pre) working-directory: ./client/Packages/com.beamable/Editor/BeamCli/Commands run: ls -a - - name: Build CLI + - name: Build CLI run: | - dotnet run Setup.cs dev + ./dev.sh - name: Delete Trash Files working-directory: ./client/Packages/com.beamable/Editor/BeamCli/Commands run: | @@ -68,7 +68,7 @@ jobs: id: cpr if: ${{ steps.changes.outputs.any == 'true' }} with: - commit-message: syncing Unity SDK from CLI + commit-message: syncing Unity SDK from CLI token: ${{secrets.CODEGEN_PR_GITHUB_TOKEN}} title: Unity SDK-CLI Generation body: The CLI autogenerated these changes to the SDK diff --git a/.github/workflows/loadTestMicroservice.yml b/.github/workflows/loadTestMicroservice.yml index 8e48c02bd6..c167c5d078 100644 --- a/.github/workflows/loadTestMicroservice.yml +++ b/.github/workflows/loadTestMicroservice.yml @@ -3,11 +3,11 @@ name: Perf Test Microservices on: pull_request: branches: - - "main" + - 'main' paths-ignore: - - "rfc/**" - - ".github/**" - - "client_installer/**" + - 'rfc/**' + - '.github/**' + - 'client_installer/**' jobs: runPerfTest: timeout-minutes: 15 @@ -32,11 +32,11 @@ jobs: - name: Install Dotnet Counters run: | dotnet tool install --global dotnet-counters --version 7.0.447801 - - name: Build and Install BEAM CLI + - name: Build and Install BEAM CLI working-directory: ./ run: | - dotnet run Setup.cs setup - dotnet run Setup.cs dev --skip_unreal --skip_unity + ./setup.sh + ./dev.sh --skip-unity --skip-unreal env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ - name: Restore tool @@ -46,17 +46,17 @@ jobs: - name: Check BEAM CLI working-directory: ./stress-tests/standalone-microservice run: | - dotnet beam config -q --logs v - + dotnet beam config -q --logs v + - name: Login to BEAM CLI working-directory: ./stress-tests/standalone-microservice run: | dotnet beam login --username ${{ secrets.BEAM_STRESSTEST_EMAIL }} --password ${{ secrets.BEAM_STRESSTEST_PASS }} --save-to-file -q --logs v - + - name: Update Nuget working-directory: ./stress-tests/standalone-microservice run: | - dotnet restore + dotnet restore - name: Build Microservice working-directory: ./stress-tests/standalone-microservice/services/standalone-microservice @@ -66,16 +66,16 @@ jobs: working-directory: ./stress-tests/standalone-microservice/services/ run: | cd ./standalone-microservice/bin/Debug/net10.0 - + echo "starting counters" mkdir ../../../../reports dotnet-counters collect --diagnostic-port ~/myport.sock --refresh-interval 3 --format json --output ../../../../reports/counter.json & - + echo "starting service" mkdir ../../../../logs BEAM_DISABLE_STANDARD_OTEL=1 LOG_PATH=../../../../logs/serviceRuntime.log DOTNET_DiagnosticPorts=~/myport.sock ./standalone-microservice & - + echo "starting profiler" cd ../../../.. echo '{"a":3,"b":4}' > payload.json @@ -89,7 +89,7 @@ jobs: echo "showing logs" cat ./logs/serviceRuntime.log cp ./logs/serviceRuntime.log ./reports/serviceRuntime.log - - name: Save Profiler Data + - name: Save Profiler Data uses: actions/upload-artifact@v4 with: name: profiler diff --git a/.github/workflows/release-nuget.yml b/.github/workflows/release-nuget.yml index 06f5f8c99d..c3d3c15ac1 100644 --- a/.github/workflows/release-nuget.yml +++ b/.github/workflows/release-nuget.yml @@ -60,9 +60,9 @@ jobs: echo patch=${{ inputs.patch }} echo rc=${{ inputs.rcNumber }} echo releaseType=${{ inputs.releaseType }} - + - uses: actions/checkout@v4 - with: + with: ref: ${{ github.event.inputs.commit }} - name: Setup .NET Core SDK @@ -72,7 +72,7 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: "20.x" + node-version: '20.x' registry-url: >- ${{ fromJson('{ "nightly": "https://nexus.beamable.com/nexus/content/repositories/unity-dev", @@ -80,7 +80,7 @@ jobs: "exp": "https://nexus.beamable.com/nexus/content/repositories/unity-preview", "production": "https://nexus.beamable.com/nexus/content/repositories/unity" }')[github.event.inputs.releaseType] }} - + - name: Install JQ run: | sudo apt-get update @@ -100,13 +100,13 @@ jobs: - name: Add collector version run: | - sh ./build/bin/set-collector-version-property.sh + sh ./build/bin/set-collector-version-property.sh - name: Install CLI working-directory: ./ run: | - dotnet run Setup.cs setup - dotnet run Setup.cs dev + bash ./setup.sh + bash ./dev.sh env: PROJECT_DIR_OVERRIDE: ${{ github.workspace }}/NugetBuildDir/ @@ -116,25 +116,25 @@ jobs: beam version construct 0 0 0 --nightly --logs v - name: Get Version Number (Nightly) - if: ${{ inputs.releaseType == 'nightly' }} + if: ${{ inputs.releaseType == 'nightly' }} run: | beam version construct 0 0 0 --nightly > version.txt - + - name: Get Version Number (RC) - if: ${{ inputs.releaseType == 'rc' }} + if: ${{ inputs.releaseType == 'rc' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --rc ${{ inputs.rcNumber }} > version.txt - + - name: Get Version Number (Exp) - if: ${{ inputs.releaseType == 'exp' }} + if: ${{ inputs.releaseType == 'exp' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --exp ${{ inputs.rcNumber }} > version.txt - + - name: Get Version Number (Prod) - if: ${{ inputs.releaseType == 'production' }} + if: ${{ inputs.releaseType == 'production' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --prod > version.txt - + - name: Store version number as output id: version - env: + env: BUILD_ENV: >- ${{ fromJson('{ "nightly": "dev", @@ -155,6 +155,7 @@ jobs: echo version suffix=${{ steps.version.outputs.VERSION_SUFFIX }} echo build-env=${{steps.version.outputs.BUILD_ENV}} + - name: Compress Collector Files working-directory: otel-bin run: find . -type f ! -name '*.gz' -exec gzip -k -9 {} \; @@ -164,21 +165,22 @@ jobs: working-directory: otel-bin run: | AWS_ACCESS_KEY_ID=${{secrets.AWS_KEY_ID}} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} AWS_REGION=us-west-2 aws s3 cp --recursive ./ s3://beamable-otel-collector-ch/version/${{ steps.version.outputs.VERSION }} --exclude "*" --include "*.gz" --acl public-read - + # Invalidate the CDN for collector builds - - name: Prepare Cloudfront Invalidation + - name: Prepare Cloudfront Invalidation run: | CLOUD_DISTRO=E3S54OWVMS4PQH CALLER_REFERENCE=$(date -u +"%Y%m%d%H%M%S") echo '{"DistributionId":"'${CLOUD_DISTRO}'","InvalidationBatch":{"CallerReference":"'${CALLER_REFERENCE}'","Paths":{"Quantity":1,"Items":["/${{ steps.setTriggerContext.outputs.triggerContext }}/*"]}}}' >> cloudfront-invalidation.json - - name: Preview Cloudfront Invalidation + - name: Preview Cloudfront Invalidation run: | cat cloudfront-invalidation.json - name: Do Cloudfront Invalidation run: AWS_ACCESS_KEY_ID=${{secrets.AWS_KEY_ID}} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} AWS_REGION=us-west-2 aws cloudfront create-invalidation --cli-input-json file://cloudfront-invalidation.json + - name: Publish Nuget Packages - if: ${{ inputs.dryRun == false }} + if: ${{ inputs.dryRun == false }} run: sh ./build/bin/release-nuget.sh env: VERSION: ${{ steps.version.outputs.VERSION }} @@ -188,12 +190,12 @@ jobs: NUGET_TOOLS_KEY: ${{ secrets.NUGET_TOOLS_KEY }} - name: Publish Changelog - if: ${{ inputs.dryRun == false }} + if: ${{ inputs.dryRun == false }} run: sh ./build/bin/upload-changelogs.sh env: - COPY_UNITY_SDK: "false" - COPY_CLI: "true" - COPY_WEB_SDK: "false" + COPY_UNITY_SDK: 'false' + COPY_CLI: 'true' + COPY_WEB_SDK: 'false' VERSION: ${{ steps.version.outputs.VERSION }} GITHUB_USERNAME: ${{ secrets.GIT_CHANGELOGS_USERNAME }} GITHUB_PASSWORD: ${{ secrets.GIT_CHANGELOGS_PASSWORD }} @@ -207,7 +209,7 @@ jobs: - name: Create Release id: create_release - if: ${{ inputs.dryRun == false }} + if: ${{ inputs.dryRun == false }} uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token diff --git a/.github/workflows/release-unity.yml b/.github/workflows/release-unity.yml index bb9a375740..947497dc56 100644 --- a/.github/workflows/release-unity.yml +++ b/.github/workflows/release-unity.yml @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-latest permissions: id-token: write - contents: write + contents: write packages: read concurrency: group: release-unity-sdk @@ -72,9 +72,9 @@ jobs: echo patch=${{ inputs.patch }} echo rc=${{ inputs.rcNumber }} echo releaseType=${{ inputs.releaseType }} - + - uses: actions/checkout@v4 - with: + with: ref: ${{ github.event.inputs.commit }} - name: Log in to the Container registry @@ -91,9 +91,9 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: "20.x" - registry-url: "https://registry.npmjs.org" - + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + - name: Update npm run: npm install -g npm@latest - name: Check Npm version @@ -118,36 +118,36 @@ jobs: - name: Add collector version run: | - sh ./build/bin/set-collector-version-property.sh + sh ./build/bin/set-collector-version-property.sh - name: Install CLI working-directory: ./ run: | - dotnet run Setup.cs setup - dotnet run Setup.cs dev + bash ./setup.sh + bash ./dev.sh - name: Check CLI run: beam version - name: Get Version Number (Nightly) - if: ${{ inputs.releaseType == 'nightly' }} + if: ${{ inputs.releaseType == 'nightly' }} run: beam version construct 0 0 0 --nightly > version.txt - + - name: Get Version Number (RC) - if: ${{ inputs.releaseType == 'rc' }} + if: ${{ inputs.releaseType == 'rc' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --rc ${{ inputs.rcNumber }} > version.txt - + - name: Get Version Number (Exp) - if: ${{ inputs.releaseType == 'exp' }} + if: ${{ inputs.releaseType == 'exp' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --exp ${{ inputs.rcNumber }} > version.txt - + - name: Get Version Number (Prod) - if: ${{ inputs.releaseType == 'production' }} + if: ${{ inputs.releaseType == 'production' }} run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --prod > version.txt - + - name: Store version number as output id: version - env: + env: NPM_TAG: >- ${{ fromJson('{ "nightly": "--tag nightly", @@ -191,7 +191,7 @@ jobs: env: VERSION: ${{ steps.version.outputs.VERSION }} ENVIRONMENT: ${{steps.version.outputs.BUILD_ENV}} - + - name: Apply Nuget Version to Unity SDK run: | beam unity download-all-nuget-packages ./client --logs v @@ -199,7 +199,7 @@ jobs: - name: Prepare Unity Samples run: sh ./../../../build/bin/prepare-samples.sh working-directory: ./client/Packages/com.beamable/ - + - name: Update UPM Versions (com.beamable) run: npm version ${{ steps.version.outputs.VERSION }} working-directory: ./client/Packages/com.beamable/ @@ -220,6 +220,7 @@ jobs: ls ./client/Packages/com.beamable ls ./client/Packages/com.beamable/Samples~ cat client/Packages/com.beamable/package.json + - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main @@ -227,7 +228,7 @@ jobs: # this might remove tools that are actually needed, # if set to "true" but frees about 6 GB tool-cache: false - + # all of these default to true, but feel free to set to # "false" if necessary for your workflow android: true @@ -273,7 +274,7 @@ jobs: if: ${{ inputs.dryRun == false }} run: npm publish ./com.beamable/com.beamable-${{ steps.version.outputs.VERSION }}.tgz ${{steps.version.outputs.NPM_TAG}} working-directory: ./client/build/package_dist/ - env: + env: NODE_AUTH_TOKEN: ${{ secrets.NEXUS_NPM_AUTH }} NPM_AUTH: ${{secrets.NEXUS_NPM_AUTH}} NPM_REGISTRY: ${{steps.version.outputs.NEXUS_REG}} @@ -289,18 +290,18 @@ jobs: if: ${{ inputs.dryRun == false }} run: npm publish ${{steps.version.outputs.NPM_TAG}} working-directory: ./client/Packages/com.beamable.server - env: + env: NODE_AUTH_TOKEN: ${{ secrets.NEXUS_NPM_AUTH }} NPM_AUTH: ${{secrets.NEXUS_NPM_AUTH}} NPM_REGISTRY: ${{steps.version.outputs.NEXUS_REG}} - name: Publish Changelog - if: ${{ inputs.dryRun == false }} + if: ${{ inputs.dryRun == false }} run: sh ./build/bin/upload-changelogs.sh env: - COPY_UNITY_SDK: "true" - COPY_CLI: "false" - COPY_WEB_SDK: "false" + COPY_UNITY_SDK: 'true' + COPY_CLI: 'false' + COPY_WEB_SDK: 'false' VERSION: ${{ steps.version.outputs.VERSION }} GITHUB_USERNAME: ${{ secrets.GIT_CHANGELOGS_USERNAME }} GITHUB_PASSWORD: ${{ secrets.GIT_CHANGELOGS_PASSWORD }} @@ -314,7 +315,7 @@ jobs: - name: Create Release id: create_release - if: ${{ inputs.dryRun == false }} + if: ${{ inputs.dryRun == false }} uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 49bbbff7af..1937981383 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release Custom SDK and CLI +name: Release Custom SDK and CLI on: workflow_dispatch: @@ -26,9 +26,9 @@ jobs: run: | echo dryRun=${{ inputs.dryRun }} echo commit=${{ inputs.commit }} - + - uses: actions/checkout@v4 - with: + with: ref: ${{ github.event.inputs.commit }} - name: Setup .NET Core SDK @@ -38,9 +38,9 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: "20.x" + node-version: '20.x' registry-url: https://nexus.beamable.com/nexus/content/repositories/unity-dev - + - name: Install JQ run: | sudo apt-get update @@ -49,23 +49,23 @@ jobs: - name: Add collector version run: | - sh ./build/bin/set-collector-version-property.sh + sh ./build/bin/set-collector-version-property.sh - name: Install CLI working-directory: ./ run: | - dotnet run Setup.cs setup - dotnet run Setup.cs dev + bash ./setup.sh + bash ./dev.sh - name: Check CLI run: beam version - - name: Get Version Number + - name: Get Version Number run: beam version construct 0 0 0 --nightly > ./version.txt - + - name: Store version number as output id: version - env: + env: BUILD_ENV: dev run: | echo "VERSION=$(cat version.txt | jq -r .data.versionString)" >> "$GITHUB_OUTPUT" @@ -94,7 +94,7 @@ jobs: env: VERSION: ${{ steps.version.outputs.VERSION }} ENVIRONMENT: ${{steps.version.outputs.BUILD_ENV}} - + - name: Apply Nuget Version run: jq --arg nextVersion ${{ steps.version.outputs.VERSION }} '.nugetPackageVersion = $nextVersion' ./client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json > localtmpfile && mv localtmpfile ./client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json @@ -114,7 +114,7 @@ jobs: - name: Prepare Unity Samples run: sh ./../../../build/bin/prepare-samples.sh working-directory: ./client/Packages/com.beamable/ - + - name: Update UPM Versions (com.beamable) run: npm version ${{ steps.version.outputs.VERSION }} working-directory: ./client/Packages/com.beamable/ @@ -136,7 +136,7 @@ jobs: if: ${{ inputs.dryRun == false }} run: npm publish working-directory: ./client/Packages/com.beamable - env: + env: NODE_AUTH_TOKEN: ${{ secrets.NEXUS_NPM_AUTH }} NPM_AUTH: ${{secrets.NEXUS_NPM_AUTH}} @@ -144,6 +144,6 @@ jobs: if: ${{ inputs.dryRun == false }} run: npm publish working-directory: ./client/Packages/com.beamable.server - env: + env: NODE_AUTH_TOKEN: ${{ secrets.NEXUS_NPM_AUTH }} NPM_AUTH: ${{secrets.NEXUS_NPM_AUTH}} diff --git a/format-code.bat b/format-code.bat new file mode 100644 index 0000000000..1051fcbde8 --- /dev/null +++ b/format-code.bat @@ -0,0 +1,4 @@ +IF "%1"=="" ( SET "FOLDER=client/Packages" ) ELSE ( SET "FOLDER=%1" ) + +dotnet tool restore +dotnet tool run dotnet-format -f %FOLDER% diff --git a/format-code.sh b/format-code.sh new file mode 100755 index 0000000000..d661f9827e --- /dev/null +++ b/format-code.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +default_dir='client/Packages' +dir=${1:-$default_dir} + +dotnet tool restore +dotnet tool run dotnet-format -f $dir diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000000..9af37d2017 --- /dev/null +++ b/setup.sh @@ -0,0 +1,154 @@ +#!/bin/bash + +# This script should be run ONCE after +# you check out the repository for the first time. +# +# It will create a local Nuget package feed/source +# in your Home directory. That feed will be used to +# store local packages as you develop. + +echo "Setting up the Beamables!" + +# the .dev.env file hosts some common variables +source ./.dev.env + +echo "Checking OS=[$OSTYPE] type for root value" + +# Get the current directory in the right format... +case "$OSTYPE" in + solaris*) ROOT=$(pwd) ;; + darwin*) ROOT=$(pwd) ;; + linux*) ROOT=$(pwd) ;; + bsd*) ROOT=$(pwd) ;; + msys*) + ROOT=$(pwd -W) + ROOT="${ROOT:0:2}/${ROOT:2}" + ;; + cygwin*) + ROOT=$(pwd -W) + ROOT="${ROOT:0:2}/${ROOT:2}" + ;; + *) echo "Should never see this!!" ;; +esac + +SOURCE_FOLDER=$ROOT/$SOURCE_FOLDER +echo "Setting up $FEED_NAME at $SOURCE_FOLDER" + + + +# delete contents of old folder, and then re-create it. +# this essentially removes all old packages as well. +rm -rf $SOURCE_FOLDER +mkdir -p $SOURCE_FOLDER + +echo "Removing old source (if none exists, you'll see an error 'Unable to find any package', but that is okay)" +dotnet nuget remove source $FEED_NAME || true + +echo "Adding new source!" +dotnet nuget add source $SOURCE_FOLDER --name $FEED_NAME + +# reset the build number back to zero. +echo "Creating build number file" +echo 0 > build-number.txt + +# restore cli tools +dotnet tool restore --tool-manifest ./cli/cli/.config/dotnet-tools.json + +# reset the template projects to reference the base version number +TEMPLATE_DOTNET_CONFIG_PATH="./cli/beamable.templates/.config/dotnet-tools.json" +ls -a "./cli/beamable.templates/" +mkdir -p "./cli/beamable.templates/.config" +cat > $TEMPLATE_DOTNET_CONFIG_PATH << EOF +{ + "version": 1, + "isRoot": true, + "tools": { + "beamable.tools": { + "version": "0.0.123.0", + "commands": [ + "beam" + ], + "rollForward": false + } + } +} +EOF + + + +GO_VERSION="1.24" +CURRENT_OS="windows" + +GO_INSTALLED=0 + +if command -v go &> /dev/null; then + INSTALLED_GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//') + echo "Go is installed with version: $INSTALLED_GO_VERSION" + if [[ "$INSTALLED_GO_VERSION" == *"$GO_VERSION"* ]]; then + GO_INSTALLED=1 + echo "Found GO installation with correct version!" + else + echo "This script needs GO with version $GO_VERSION, instead found $INSTALLED_GO_VERSION" + exit 1 + fi +fi + + +#TODO This could be improved by actually running through a list of dependencies and check for all of them, better done once we actually have more deps +# if the dependency is not installed by default, then we will need either Chocolatey or Homebrew +if [[ "$GO_INSTALLED" == "0" ]]; then + # check for os type, if windows then we need chocolatey to be installed, otherwise we need homebrew + case "$OSTYPE" in + darwin*) + CURRENT_OS="mac" + if command -v brew &> /dev/null; then + echo "Homebrew is installed" + echo "Version: $(brew --version | head -n 1)" + else + echo "Homebrew is not installed, please install it before running this script!" + exit 1 + fi + ;; + msys*|cygwin*|win32) + CURRENT_OS="windows" + if command -v choco &> /dev/null; then + echo "Chocolatey is installed with version: $(choco --version)" + else + echo "Chocolatey is not installed, please install it before running this script!" + exit 1 + fi + ;; + *) + echo "This message should never be printed, os: $OSTYPE" + exit 1 + ;; + esac + + if [[ "$CURRENT_OS" == "windows" ]]; then + if choco install golang --version=$GO_VERSION -y; then + echo "GO with version $GO_VERSION was successfully installed!" + export PATH="$PATH:/c/Go/bin" #This is the default case for chocolatey, it might not work depending on the user's setup + else + echo "Failed to install GO using Chocolatey!" + exit 1 + fi + else + if brew install go@$GO_VERSION 2>/dev/null; then + echo "GO with version $GO_VERSION was successfully installed!" + export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" #This is the default case for homebrew, it might not work depending on the user's setup + else + echo "Failed to install GO using Homebrew!" + fi + fi +fi + + +# Builds all the otel collector binaries +cd ./otel-collector/ +./build.sh --version 0.0.123 +cd .. + + + +# TODO: Consider running this as part of a post-pull git action +# TODO: Should this run the `sync-rider-run-settings.sh` script? (probably) \ No newline at end of file diff --git a/sync-rider-run-settings.sh b/sync-rider-run-settings.sh new file mode 100644 index 0000000000..8994e9890e --- /dev/null +++ b/sync-rider-run-settings.sh @@ -0,0 +1,83 @@ +#!/bin/sh + +BASEDIR=$(dirname "$0") +echo "$BASEDIR" + +TargetEngine="$1" + +# For unity, this defaults to /client, but can be overridable +PathToWorkingDirectory="$2" +if [[ $TargetEngine == "UNITY" && $PathToWorkingDirectory == "" ]]; then + PathToWorkingDirectory="$BASEDIR/client" +fi +PathToWorkingDirectory="${PathToWorkingDirectory//\\/\/}" + +# For unreal +PathToRestoreDirectory="$3" +if [[ $TargetEngine == "UNREAL" && $PathToRestoreDirectory == "" ]]; then + PathToRestoreDirectory="$PathToWorkingDirectory"Microservices +fi + +# This argument is the path to GitBash 99% of the time. If not given, assumes C:/Program Files/Git/bin/bash.exe +PathToUnixShell="$3" +if [[ $PathToUnixShell == "" ]]; then + case "$OSTYPE" in + solaris*) echo "/bin/bash" ;; + darwin*) echo "/bin/bash" ;; + linux*) echo "/usr/bin/bash" ;; + bsd*) echo "/usr/bin/bash" ;; + msys*) PathToUnixShell="C:\Program Files\Git\bin\bash.exe" ;; + cygwin*) PathToUnixShell="C:\Program Files\Git\bin\bash.exe" ;; + *) echo "Should never see this!!" ;; + esac + +fi +PathToUnixShell="${PathToUnixShell//\\/\/}" + +# Path to the CLI .run folder. +CliRunPath="$BASEDIR/cli/.run" + +if [ -d "$CliRunPath" ]; then + echo "Copying all TEMPLATE- configurations into $TargetEngine- configurations." + + for i in $(find "$CliRunPath" -name 'TEMPLATE-*.run.xml'); do # Not recommended, will break on whitespace + + TargetFile="${i/TEMPLATE-/"$TargetEngine"-}" + echo "cp -u $i $TargetFile" + cp -u "$i" "$TargetFile" + echo sed -i 's/TEMPLATE-/'"$TargetEngine"'-/g' "$TargetFile" + sed -i 's/TEMPLATE-/'"$TargetEngine"'-/g' "$TargetFile" + + # If there is an INTERPRETER_PATH in the xml, replace it with the given $PathToUnixShell + echo sed -i '\@="INTERPRETER_PATH"@s@value=".*"@value="'"$PathToUnixShell"'"@g' "$TargetFile" + sed -i '\@="INTERPRETER_PATH"@s@value=".*"@value="'"$PathToUnixShell"'"@g' "$TargetFile" + + # For the local packages script we also change the SCRIPT_OPTIONS to point to the $PathToWorkingDirectory + # For every other script, we set the WORKING_DIRECTORY path in the xml, replace it with the given $PathToWorkingDirectory + if [[ $TargetFile == *$TargetEngine-Set-Local-Packages* || $TargetFile == *$TargetEngine-Set-Install-* ]]; then + echo sed -i '\@="SCRIPT_OPTIONS"@s@\$PROJECT_DIR\$\/\.\.\/client@'"$PathToWorkingDirectory"'@g' "$TargetFile" + sed -i '\@="SCRIPT_OPTIONS"@s@\$PROJECT_DIR\$\/\.\.\/client@'"$PathToWorkingDirectory"'@g' "$TargetFile" + + echo sed -i '\@="SCRIPT_OPTIONS"@s@BeamableNugetSource@'"$TargetEngine"'_NugetSource@g' "$TargetFile" + sed -i '\@="SCRIPT_OPTIONS"@s@BeamableNugetSource@'"$TargetEngine"'_NugetSource@g' "$TargetFile" + + echo sed -i '\@="SCRIPT_OPTIONS"@s@PathToRestore@'"$PathToRestoreDirectory"'@g' "$TargetFile" + sed -i '\@="SCRIPT_OPTIONS"@s@PathToRestore@'"$PathToRestoreDirectory"'@g' "$TargetFile" + + continue + else + echo sed -i '\@="WORKING_DIRECTORY"@s@value=".*"@value="'"$PathToWorkingDirectory"'"@g' "$TargetFile" + sed -i '\@="WORKING_DIRECTORY"@s@value=".*"@value="'"$PathToWorkingDirectory"'"@g' "$TargetFile" + fi + done + +else + echo "Invalid path to a .run folder. Given Path: $CliRunPath" +fi + + + + + + + From 9b36638b2ee0492d1977357cb9a109ccb0699539 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Thu, 22 Jan 2026 15:52:53 +0100 Subject: [PATCH 12/13] Restore dev script --- dev.sh | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100755 dev.sh diff --git a/dev.sh b/dev.sh new file mode 100755 index 0000000000..fa2639c11b --- /dev/null +++ b/dev.sh @@ -0,0 +1,138 @@ +#!/bin/bash + +# PREREQ: +# Ensure you've run `setup.sh` at least once before running this + +# This script will be run many times as you develop. +# Anytime you need to test a change with new code you've written +# locally, you should run this script. +# +# It will... +# 1. build all the projects that result in Nuget packages, +# 2. publish them locally to the local package feed +# 3. update the local templates +# 4. install the latest CLI globally +# 5. invalidate the nuget cache for local beamable dev packages, which +# means that downstream projects will need to run a `dotnet restore`. + +compliment=$(awk 'BEGIN{srand()} {a[NR]=$0} END{print a[int(rand()*NR)+1]}' compliments.txt) +echo "$compliment" + +# the .dev.env file hosts some common variables +source ./.dev.env + +# idiomatic parameter and option handling in sh +SHOULD_APPLY_TO_UNITY=true +SHOULD_APPLY_TO_UNREAL=true +SHOULD_APPLY_TO_SAMS_SANDBOX=true +while test $# -gt 0 +do + case "$1" in + --skip-unity) SHOULD_APPLY_TO_UNITY=false + echo "skipping unity $1 $SHOULD_APPLY_TO_UNITY" + ;; + --skip-unreal) SHOULD_APPLY_TO_UNREAL=false + echo "skipping unreal $1 $SHOULD_APPLY_TO_UNREAL" + ;; + --skip-sams-sandbox) SHOULD_APPLY_TO_SAMS_SANDBOX=false + echo "skipping sams-sandbox $1 $SHOULD_APPLY_TO_SAMS_SANDBOX" + ;; + *) echo "argument $1" + ;; + esac + shift +done + +# construct a build number +NEXT_BUILD_NUMBER=`cat build-number.txt` +PREVIOUS_BUILD_NUMBER=$NEXT_BUILD_NUMBER +((NEXT_BUILD_NUMBER+=1)) +echo $NEXT_BUILD_NUMBER > build-number.txt + +# the version is the nuget package version that will be built +VERSION=0.0.123.$NEXT_BUILD_NUMBER +PREVIOUS_VERSION=0.0.123.$PREVIOUS_BUILD_NUMBER + +# the build solution only has references to the projects that we actually want to publish +SOLUTION=./build/LocalBuild/LocalBuild.sln +TMP_BUILD_OUTPUT="TempBuild" + +BUILD_ARGS="--configuration Release -p:PackageVersion=$VERSION -p:CombinedVersion=$VERSION -p:InformationalVersion=$VERSION -p:Warn=0 -p:BeamBuild=true" #- +PACK_ARGS="--configuration Release --no-build -o $TMP_BUILD_OUTPUT -p:PackageVersion=$VERSION -p:CombinedVersion=$VERSION -p:InformationalVersion=$VERSION -p:SKIP_GENERATION=true -p:BeamBuild=true" +PUSH_ARGS="--source $FEED_NAME" + +dotnet restore $SOLUTION +dotnet build $SOLUTION $BUILD_ARGS +dotnet build cli/beamable.common -f net10.0 -t:CopyCodeToUnity -p:BEAM_COPY_CODE_TO_UNITY=$SHOULD_APPLY_TO_UNITY +dotnet pack $SOLUTION $PACK_ARGS +dotnet nuget push $TMP_BUILD_OUTPUT/*.$VERSION.nupkg $PUSH_ARGS + +# remove the old package from the nuget feed, so that we don't accumulate millions of packages over time. +DELETE_ARGS="$PREVIOUS_VERSION --source $FEED_NAME --non-interactive" +echo "Deleting package! ------ $DELETE_ARGS" +dotnet nuget delete Beamable.Common $DELETE_ARGS +dotnet nuget delete Beamable.Server.Common $DELETE_ARGS +dotnet nuget delete Beamable.Microservice.Runtime $DELETE_ARGS +dotnet nuget delete Beamable.Microservice.SourceGen $DELETE_ARGS +dotnet nuget delete Beamable.Tooling.Common $DELETE_ARGS +dotnet nuget delete Beamable.UnityEngine $DELETE_ARGS +dotnet nuget delete Beamable.UnityEngine.Addressables $DELETE_ARGS +dotnet nuget delete Beamable.Tools $DELETE_ARGS + + +# install the latest templates. +# frustratingly, it seems like the version of the install command +# that accepts a nuget feed does not work for local package feeds. +dotnet new uninstall Beamable.Templates || true +dotnet new install $TMP_BUILD_OUTPUT/Beamable.Templates.$VERSION.nupkg --force + +# clean up the build artifacts... +rm -rf $TMP_BUILD_OUTPUT + +# remove the cache keys for beamable projects. This makes them break until a restore operation happens. +rm -rf $HOME/.nuget/packages/beamable.*/$PREVIOUS_VERSION + +# install the latest CLI globally. +dotnet tool install Beamable.Tools --version $VERSION --global --allow-downgrade --no-cache + +# restore the nuget packages (and CLI) for a sample project, thus restoring the +# nuget-cache for all projects. +if [ $SHOULD_APPLY_TO_UNITY = true ]; then + echo "Preparing the Unity SDK project to use locally built CLI" + + # generate unity CLI + beam generate-interface --engine unity --output=./client/Packages/com.beamable/Editor/BeamCli/Commands --no-log-file + + cd cli/beamable.templates/templates/BeamService + dotnet tool update Beamable.Tools --version $VERSION --allow-downgrade + dotnet restore BeamService.csproj --no-cache --force + + # Go back to the project root + cd ../../../.. +fi + +# If the user has the Unreal repo as a sibling, we update the version number there too +if [ $SHOULD_APPLY_TO_UNREAL = true ] && [[ -d "../UnrealSDK" ]]; then + echo "Preparing UnrealSDK project to use locally built CLI" + cd ../UnrealSDK + dotnet tool update Beamable.Tools --version $VERSION --allow-downgrade + cd Microservices + for i in `find . -name "*.csproj" -type f`; do + echo "Restoring Microservice Project: $i" + dotnet restore "$i" --no-cache --force + done + cd ../../BeamableProduct +fi + +# If the user has the Unreal repo as a sibling, we update the version number there too +if [ $SHOULD_APPLY_TO_SAMS_SANDBOX = true ] && [[ -d "../SamsLocalSandbox" ]]; then + echo "Preparing the SamsSandbox local project to use locally built CLI" + cd ../SamsLocalSandbox + dotnet tool update Beamable.Tools --version $VERSION --allow-downgrade + for i in `find . -name "*.csproj" -type f`; do + echo "Restoring Microservice Project: $i" + dotnet restore "$i" --no-cache --force + done + cd ../BeamableProduct +fi + From a42794c5ac89b73ba381307ed5d6328fc2f48b28 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Thu, 22 Jan 2026 15:55:26 +0100 Subject: [PATCH 13/13] Restore old config --- cli/cli/.config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cli/.config/dotnet-tools.json b/cli/cli/.config/dotnet-tools.json index daaa76395f..b24dbeb2eb 100644 --- a/cli/cli/.config/dotnet-tools.json +++ b/cli/cli/.config/dotnet-tools.json @@ -1 +1 @@ -{ "version": 1, "isRoot": true, "tools": {} } +{"version":1,"isRoot":true,"tools":{"dotnet-format":{"version":"5.1.250801","commands":["dotnet-format"]}}} \ No newline at end of file