From 71df0ac4d5e5ceaddf78888611a7c8692ce75ee6 Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 14:02:05 -0500
Subject: [PATCH 01/11] wip

---
 CI/pipeline.ps1 | 2 ++
 CMakeLists.txt  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/CI/pipeline.ps1 b/CI/pipeline.ps1
index 7a38f08b..dc77459c 100644
--- a/CI/pipeline.ps1
+++ b/CI/pipeline.ps1
@@ -20,6 +20,8 @@ $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE SL_OBS_VERSION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE SL_OBS_VERSION=`"$($env:SL_OBS_VERSION)`")"
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser PRIVATE GITHUB_REVISION=""\)', "target_compile_definitions(sl-browser PRIVATE GITHUB_REVISION=`"${revision}`")"
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE GITHUB_REVISION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE GITHUB_REVISION=`"${revision}`")"
+$cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser PRIVATE SL_REVISION=""\)', "target_compile_definitions(sl-browser PRIVATE SL_REVISION=`"${revision}`")"
+$cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE SL_REVISION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE SL_REVISION=`"${revision}`")"
 
 # Write the updated content back to CMakeLists.txt
 Set-Content -Path .\CMakeLists.txt -Value $cmakeContent
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0f09381c..eb4ab982 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,7 @@ add_executable(sl-browser WIN32)
 
 #target_compile_definitions(sl-browser PRIVATE SL_OBS_VERSION="")
 #target_compile_definitions(sl-browser PRIVATE GITHUB_REVISION="")
+#target_compile_definitions(sl-browser-plugin PRIVATE SL_REVISION="")
 target_compile_options(sl-browser PRIVATE $<IF:$<CONFIG:DEBUG>,/MTd,/MT>)
 target_link_options(sl-browser PRIVATE /NODEFAULTLIB:msvcrt)
 
@@ -149,6 +150,7 @@ target_compile_features(sl-browser-plugin PRIVATE cxx_std_17)
 target_compile_definitions(sl-browser-plugin PRIVATE BROWSER_AVAILABLE)
 #target_compile_definitions(sl-browser-plugin PRIVATE SL_OBS_VERSION="")
 #target_compile_definitions(sl-browser-plugin PRIVATE GITHUB_REVISION="")
+#target_compile_definitions(sl-browser-plugin PRIVATE SL_REVISION="")
 
 target_link_libraries(sl-browser-plugin PRIVATE OBS::libobs OBS::frontend-api)
 target_link_libraries(sl-browser-plugin PRIVATE ZLIB::ZLIB)

From b7a7f19fd9f09a5174c981741714808593d77ac3 Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 14:21:15 -0500
Subject: [PATCH 02/11] Builds build with next_rev from metadata

---
 CI/pipeline.ps1 | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/CI/pipeline.ps1 b/CI/pipeline.ps1
index dc77459c..adbcf7dc 100644
--- a/CI/pipeline.ps1
+++ b/CI/pipeline.ps1
@@ -6,6 +6,22 @@ param(
 Write-Output "Workspace is $github_workspace"
 Write-Output "Revision is $revision"
 
+$slRevision = 0
+
+try {
+	# Download data for revisions
+	$urlJsonObsVersions = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/meta_publish.json"
+
+	$filepathJsonPublish = ".\meta_publish.json"
+	Invoke-WebRequest -Uri $urlJsonObsVersions -OutFile $filepathJsonPublish
+	$jsonContent = Get-Content -Path $filepathJsonPublish -Raw | ConvertFrom-Json
+	
+	$slRevision = $jsonContent.next_rev
+}
+catch {
+	throw "Error: An error occurred. Details: $($_.Exception.Message)"
+}
+
 $env:Protobuf_DIR = "${github_workspace}\..\grpc_dist\cmake"
 $env:absl_DIR = "${github_workspace}\..\grpc_dist\lib\cmake\absl"
 $env:gRPC_DIR = "${github_workspace}\..\grpc_dist\lib\cmake\grpc"
@@ -21,7 +37,7 @@ $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser PRIVATE GITHUB_REVISION=""\)', "target_compile_definitions(sl-browser PRIVATE GITHUB_REVISION=`"${revision}`")"
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE GITHUB_REVISION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE GITHUB_REVISION=`"${revision}`")"
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser PRIVATE SL_REVISION=""\)', "target_compile_definitions(sl-browser PRIVATE SL_REVISION=`"${revision}`")"
-$cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE SL_REVISION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE SL_REVISION=`"${revision}`")"
+$cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE SL_REVISION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE SL_REVISION=`"${slRevision}`")"
 
 # Write the updated content back to CMakeLists.txt
 Set-Content -Path .\CMakeLists.txt -Value $cmakeContent

From 19cd09be69ee624efc5e4fe6a07793dd38cb28c2 Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 15:49:37 -0500
Subject: [PATCH 03/11] wip

---
 CI/pipeline.ps1     | 61 ++++++++++++++++++++++++++++++++++++++++++++-
 CrashHandler.h      | 10 +++++++-
 PluginJsHandler.cpp |  4 +--
 SlBrowser.cpp       | 35 ++++++++++++++++++++++++--
 4 files changed, 104 insertions(+), 6 deletions(-)

diff --git a/CI/pipeline.ps1 b/CI/pipeline.ps1
index adbcf7dc..c8eedb9e 100644
--- a/CI/pipeline.ps1
+++ b/CI/pipeline.ps1
@@ -4,7 +4,7 @@ param(
 )
 
 Write-Output "Workspace is $github_workspace"
-Write-Output "Revision is $revision"
+Write-Output "Github revision is $revision"
 
 $slRevision = 0
 
@@ -17,6 +17,7 @@ try {
 	$jsonContent = Get-Content -Path $filepathJsonPublish -Raw | ConvertFrom-Json
 	
 	$slRevision = $jsonContent.next_rev
+	Write-Output "Streamlabs revision is $slRevision"
 }
 catch {
 	throw "Error: An error occurred. Details: $($_.Exception.Message)"
@@ -141,3 +142,61 @@ Write-Output "Archive created: $archiveFileName"
 
 # Move the 7z archive to the $github_workspace directory
 Move-Item -Path $archiveFileName -Destination "${github_workspace}\"
+
+# Add information to the revision library
+$slRevision = 0
+
+try {
+    # Download data for revisions
+    $urlJsonObsVersions = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/meta_publish.json"
+    $filepathJsonPublish = ".\meta_publish.json"
+    Invoke-WebRequest -Uri $urlJsonObsVersions -OutFile $filepathJsonPublish
+    $jsonContent = Get-Content -Path $filepathJsonPublish -Raw | ConvertFrom-Json
+    
+    $slRevision = $jsonContent.next_rev
+    Write-Output "Streamlabs revision is $slRevision"
+    
+    # Attempt to download existing revision builds JSON
+    $urlJsonRevisionBuilds = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/revision_builds.json"
+    $filepathJsonRevisionBuilds = ".\revision_builds.json"
+    
+    try {
+        Invoke-WebRequest -Uri $urlJsonRevisionBuilds -OutFile $filepathJsonRevisionBuilds
+    }
+    catch {
+        # If download fails, assume file does not exist and create a new JSON array
+        Set-Content -Path $filepathJsonRevisionBuilds -Value "[]"
+    }
+
+    # Load or initialize the revision builds JSON
+    $revisionBuilds = Get-Content -Path $filepathJsonRevisionBuilds -Raw | ConvertFrom-Json
+    
+    # Prepare the new entry
+    $newEntry = @{
+        "rev" = $slRevision
+        "date" = (Get-Date -UFormat %s)
+        "gitrev" = $revision
+    }
+
+    # Check if the entry already exists (based on rev and gitrev)
+    $exists = $false
+    foreach ($entry in $revisionBuilds) {
+        if ($entry.rev -eq $newEntry.rev -and $entry.gitrev -eq $newEntry.gitrev) {
+            $exists = $true
+            break
+        }
+    }
+    
+    # If the entry does not exist, add it
+    if (-not $exists) {
+        $revisionBuilds += $newEntry
+    }
+    
+    # Save the updated JSON back to the file
+    $revisionBuilds | ConvertTo-Json -Depth 100 | Set-Content -Path $filepathJsonRevisionBuilds
+    
+    Write-Output "Revision builds updated successfully."
+}
+catch {
+    throw "Error: An error occurred. Details: $($_.Exception.Message)"
+}
\ No newline at end of file
diff --git a/CrashHandler.h b/CrashHandler.h
index ef46745b..f56b7075 100644
--- a/CrashHandler.h
+++ b/CrashHandler.h
@@ -137,6 +137,7 @@ class CrashHandler
 		std::string payload;
 		std::string version;
 		std::string githubRevision;
+		std::string revision;
 
 		#ifdef SL_OBS_VERSION
 			version = SL_OBS_VERSION;
@@ -150,6 +151,12 @@ class CrashHandler
 			githubRevision = "debug";
 		#endif
 
+		#ifdef SL_REVISION
+			revision = SL_REVISION;
+		#else
+			revision = "debug";
+		#endif
+
 		// Read .dmp file content
 		std::ifstream minidump_file(minidump_path, std::ios::binary);
 		std::string minidumpContent((std::istreambuf_iterator<char>(minidump_file)), std::istreambuf_iterator<char>());
@@ -191,9 +198,10 @@ class CrashHandler
 		// Construct tags payload
 		payload += "Content-Disposition: form-data; name=\"sentry\"\r\n";
 		payload += "\r\n";
-		payload += "{\"release\":\"" + version + "\", \"tags\":{\"gitrev\":\"" + githubRevision + "\"}}\r\n";
+		payload += "{\"release\":\"" + version + "\", \"tags\":{\"gitrev\":\"" + githubRevision + "\", \"revision\":\"" + revision + "\"}}\r\n";
 		payload += "--BOUNDARY--\r\n";
 
+
 		// Ship it
 		WindowsFunctions::HTTPRequest(uri, method, headers, &httpCode, timeoutMS, response, payload, "application/json");
 	}
diff --git a/PluginJsHandler.cpp b/PluginJsHandler.cpp
index 992e95dc..90cf7481 100644
--- a/PluginJsHandler.cpp
+++ b/PluginJsHandler.cpp
@@ -304,9 +304,9 @@ void PluginJsHandler::JS_CLEAR_AUTH_TOKEN(const json11::Json &params, std::strin
 void PluginJsHandler::JS_SL_VERSION_INFO(const json11::Json &params, std::string &out_jsonReturn)
 {
 #ifdef GITHUB_REVISION
-	out_jsonReturn = Json(Json::object{{"branch", SL_OBS_VERSION}, {"git_sha", GITHUB_REVISION}}).dump();
+	out_jsonReturn = Json(Json::object{{"branch", SL_OBS_VERSION}, {"git_sha", GITHUB_REVISION}, {"rev", SL_REVISION}}).dump();
 #else
-	out_jsonReturn = Json(Json::object{{"branch", "debug"}, {"git_sha", "debug"}}).dump();
+	out_jsonReturn = Json(Json::object{{"branch", "debug"}, {"git_sha", "debug"}, {"rev", "debug"}}).dump();
 #endif
 }
 
diff --git a/SlBrowser.cpp b/SlBrowser.cpp
index aeb9939b..68be8257 100644
--- a/SlBrowser.cpp
+++ b/SlBrowser.cpp
@@ -120,6 +120,28 @@ void SlBrowser::CreateCefBrowser(int arg)
 
 void SlBrowser::browserInit()
 {
+	std::string version;
+	std::string githubRevision;
+	std::string revision;
+
+#ifdef SL_OBS_VERSION
+	version = SL_OBS_VERSION;
+#else
+	version = "debug";
+#endif
+
+#ifdef GITHUB_REVISION
+	githubRevision = GITHUB_REVISION;
+#else
+	githubRevision = "debug";
+#endif
+
+#ifdef SL_REVISION
+	revision = SL_REVISION;
+#else
+	revision = "debug";
+#endif
+
 	TCHAR moduleFileName[MAX_PATH]{};
 	GetModuleFileName(NULL, moduleFileName, MAX_PATH);
 	std::filesystem::path fsPath(moduleFileName);
@@ -133,11 +155,20 @@ void SlBrowser::browserInit()
 	settings.log_severity = LOGSEVERITY_VERBOSE;
 
 	CefString(&settings.user_agent_product) = "Streamlabs";
-
-	// TODO
 	CefString(&settings.locale) = "en-US";
 	CefString(&settings.accept_language_list) = "en-US,en";
 
+	// Value that will be inserted as the product portion of the default
+	// User-Agent string. If empty the Chromium product version will be used. If
+	// |userAgent| is specified this value will be ignored. Also configurable
+	// using the "user-agent-product" command-line switch.
+	std::stringstream prod_ver;
+	prod_ver << "Chrome/";
+	prod_ver << std::to_string(cef_version_info(4)) << "." << std::to_string(cef_version_info(5)) << "." << std::to_string(cef_version_info(6)) << "." << std::to_string(cef_version_info(7));
+	prod_ver << " SLABS/";
+	prod_ver << version << "." << githubRevision;
+	CefString(&settings.user_agent_product) = prod_ver.str();
+
 	settings.persist_user_preferences = 1;
 
 	char cache_path[MAX_PATH];

From 902da58db3f5aeafd81aca8ceea53a9cd603e026 Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 16:07:59 -0500
Subject: [PATCH 04/11] wip

---
 CI/pipeline.ps1 | 58 ----------------------------------------
 CI/sign.ps1     | 70 +++++++++++++++++++++++++++++++++++++++++++++++++
 SlBrowser.cpp   |  2 +-
 3 files changed, 71 insertions(+), 59 deletions(-)

diff --git a/CI/pipeline.ps1 b/CI/pipeline.ps1
index c8eedb9e..9519e76c 100644
--- a/CI/pipeline.ps1
+++ b/CI/pipeline.ps1
@@ -142,61 +142,3 @@ Write-Output "Archive created: $archiveFileName"
 
 # Move the 7z archive to the $github_workspace directory
 Move-Item -Path $archiveFileName -Destination "${github_workspace}\"
-
-# Add information to the revision library
-$slRevision = 0
-
-try {
-    # Download data for revisions
-    $urlJsonObsVersions = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/meta_publish.json"
-    $filepathJsonPublish = ".\meta_publish.json"
-    Invoke-WebRequest -Uri $urlJsonObsVersions -OutFile $filepathJsonPublish
-    $jsonContent = Get-Content -Path $filepathJsonPublish -Raw | ConvertFrom-Json
-    
-    $slRevision = $jsonContent.next_rev
-    Write-Output "Streamlabs revision is $slRevision"
-    
-    # Attempt to download existing revision builds JSON
-    $urlJsonRevisionBuilds = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/revision_builds.json"
-    $filepathJsonRevisionBuilds = ".\revision_builds.json"
-    
-    try {
-        Invoke-WebRequest -Uri $urlJsonRevisionBuilds -OutFile $filepathJsonRevisionBuilds
-    }
-    catch {
-        # If download fails, assume file does not exist and create a new JSON array
-        Set-Content -Path $filepathJsonRevisionBuilds -Value "[]"
-    }
-
-    # Load or initialize the revision builds JSON
-    $revisionBuilds = Get-Content -Path $filepathJsonRevisionBuilds -Raw | ConvertFrom-Json
-    
-    # Prepare the new entry
-    $newEntry = @{
-        "rev" = $slRevision
-        "date" = (Get-Date -UFormat %s)
-        "gitrev" = $revision
-    }
-
-    # Check if the entry already exists (based on rev and gitrev)
-    $exists = $false
-    foreach ($entry in $revisionBuilds) {
-        if ($entry.rev -eq $newEntry.rev -and $entry.gitrev -eq $newEntry.gitrev) {
-            $exists = $true
-            break
-        }
-    }
-    
-    # If the entry does not exist, add it
-    if (-not $exists) {
-        $revisionBuilds += $newEntry
-    }
-    
-    # Save the updated JSON back to the file
-    $revisionBuilds | ConvertTo-Json -Depth 100 | Set-Content -Path $filepathJsonRevisionBuilds
-    
-    Write-Output "Revision builds updated successfully."
-}
-catch {
-    throw "Error: An error occurred. Details: $($_.Exception.Message)"
-}
\ No newline at end of file
diff --git a/CI/sign.ps1 b/CI/sign.ps1
index 746fb094..db95e1ca 100644
--- a/CI/sign.ps1
+++ b/CI/sign.ps1
@@ -87,3 +87,73 @@ cd archive/RelWithDebInfo
 
 # Move the signed archive to the specified workspace
 Move-Item -Path "..\$signedArchiveFileName" -Destination "${github_workspace}\"
+
+# Add information to the revision library
+$slRevision = 0
+
+try {
+    # Download data for revisions
+    $urlJsonObsVersions = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/meta_publish.json"
+    $filepathJsonPublish = ".\meta_publish.json"
+    Invoke-WebRequest -Uri $urlJsonObsVersions -OutFile $filepathJsonPublish
+    $jsonContent = Get-Content -Path $filepathJsonPublish -Raw | ConvertFrom-Json
+    
+    $slRevision = $jsonContent.next_rev
+    Write-Output "Streamlabs revision is $slRevision"
+    
+    # Attempt to download existing revision builds JSON
+    $urlJsonRevisionBuilds = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/revision_builds.json"
+    $filepathJsonRevisionBuilds = ".\revision_builds.json"
+    
+    try {
+        Invoke-WebRequest -Uri $urlJsonRevisionBuilds -OutFile $filepathJsonRevisionBuilds
+    }
+    catch {
+        # If download fails, assume file does not exist and create a new JSON array
+        Set-Content -Path $filepathJsonRevisionBuilds -Value "[]"
+    }
+
+    # Load or initialize the revision builds JSON
+    $revisionBuilds = Get-Content -Path $filepathJsonRevisionBuilds -Raw | ConvertFrom-Json
+    
+    # Prepare the new entry
+    $newEntry = @{
+        "rev" = $slRevision
+        "date" = (Get-Date -UFormat %s)
+        "gitrev" = $revision
+    }
+
+    # Check if the entry already exists (based on rev and gitrev)
+    $exists = $false
+    foreach ($entry in $revisionBuilds) {
+        if ($entry.rev -eq $newEntry.rev -and $entry.gitrev -eq $newEntry.gitrev) {
+            $exists = $true
+            break
+        }
+    }
+    
+    # If the entry does not exist, add it
+    if (-not $exists) {
+        $revisionBuilds += $newEntry
+    }
+    
+    # Save the updated JSON back to the file
+    $revisionBuilds | ConvertTo-Json -Depth 100 | Set-Content -Path $filepathJsonRevisionBuilds
+    
+    Write-Output "Revision builds json formed. Uploading back to AWS."
+	
+	# Local environment variables, even if there are system ones with the same name, these are used for the cmd below
+	$Env:AWS_ACCESS_KEY_ID = $Env:AWS_RELEASE_ACCESS_KEY_ID
+	$Env:AWS_SECRET_ACCESS_KEY = $Env:AWS_RELEASE_SECRET_ACCESS_KEY
+	$Env:AWS_DEFAULT_REGION = "us-west-2"
+	
+	try {
+		aws s3 cp $jsonFilePath https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/ --acl public-read --metadata-directive REPLACE --cache-control "max-age=0, no-cache, no-store, must-revalidate"
+		
+		if ($LASTEXITCODE -ne 0) {
+			throw "AWS CLI returned a non-zero exit code: $LASTEXITCODE"
+		}
+}
+catch {
+    throw "Error: An error occurred during revision updating. Details: $($_.Exception.Message)"
+}
\ No newline at end of file
diff --git a/SlBrowser.cpp b/SlBrowser.cpp
index 68be8257..90a9d95a 100644
--- a/SlBrowser.cpp
+++ b/SlBrowser.cpp
@@ -166,7 +166,7 @@ void SlBrowser::browserInit()
 	prod_ver << "Chrome/";
 	prod_ver << std::to_string(cef_version_info(4)) << "." << std::to_string(cef_version_info(5)) << "." << std::to_string(cef_version_info(6)) << "." << std::to_string(cef_version_info(7));
 	prod_ver << " SLABS/";
-	prod_ver << version << "." << githubRevision;
+	prod_ver << revision << "." << version << "." << githubRevision;
 	CefString(&settings.user_agent_product) = prod_ver.str();
 
 	settings.persist_user_preferences = 1;

From c7c7613a2bfd4db2aa4d6279643d0a99f03c61d3 Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 16:47:10 -0500
Subject: [PATCH 05/11] testing

---
 CI/pipeline.ps1 | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/CI/pipeline.ps1 b/CI/pipeline.ps1
index 9519e76c..7a38f08b 100644
--- a/CI/pipeline.ps1
+++ b/CI/pipeline.ps1
@@ -4,24 +4,7 @@ param(
 )
 
 Write-Output "Workspace is $github_workspace"
-Write-Output "Github revision is $revision"
-
-$slRevision = 0
-
-try {
-	# Download data for revisions
-	$urlJsonObsVersions = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/meta_publish.json"
-
-	$filepathJsonPublish = ".\meta_publish.json"
-	Invoke-WebRequest -Uri $urlJsonObsVersions -OutFile $filepathJsonPublish
-	$jsonContent = Get-Content -Path $filepathJsonPublish -Raw | ConvertFrom-Json
-	
-	$slRevision = $jsonContent.next_rev
-	Write-Output "Streamlabs revision is $slRevision"
-}
-catch {
-	throw "Error: An error occurred. Details: $($_.Exception.Message)"
-}
+Write-Output "Revision is $revision"
 
 $env:Protobuf_DIR = "${github_workspace}\..\grpc_dist\cmake"
 $env:absl_DIR = "${github_workspace}\..\grpc_dist\lib\cmake\absl"
@@ -37,8 +20,6 @@ $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE SL_OBS_VERSION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE SL_OBS_VERSION=`"$($env:SL_OBS_VERSION)`")"
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser PRIVATE GITHUB_REVISION=""\)', "target_compile_definitions(sl-browser PRIVATE GITHUB_REVISION=`"${revision}`")"
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE GITHUB_REVISION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE GITHUB_REVISION=`"${revision}`")"
-$cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser PRIVATE SL_REVISION=""\)', "target_compile_definitions(sl-browser PRIVATE SL_REVISION=`"${revision}`")"
-$cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE SL_REVISION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE SL_REVISION=`"${slRevision}`")"
 
 # Write the updated content back to CMakeLists.txt
 Set-Content -Path .\CMakeLists.txt -Value $cmakeContent

From 1c49bd7e94700d60fe3e848cc253acfc88195a34 Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 16:52:56 -0500
Subject: [PATCH 06/11] fix previous

---
 CI/pipeline.ps1 | 21 ++++++++++++++++++++-
 CMakeLists.txt  |  2 +-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/CI/pipeline.ps1 b/CI/pipeline.ps1
index 7a38f08b..2f9a4b1b 100644
--- a/CI/pipeline.ps1
+++ b/CI/pipeline.ps1
@@ -4,7 +4,24 @@ param(
 )
 
 Write-Output "Workspace is $github_workspace"
-Write-Output "Revision is $revision"
+Write-Output "Github revision is $revision"
+
+$slRevision = 0
+
+try {
+	# Download data for revisions
+	$urlJsonObsVersions = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/meta_publish.json"
+
+	$filepathJsonPublish = ".\meta_publish.json"
+	Invoke-WebRequest -Uri $urlJsonObsVersions -OutFile $filepathJsonPublish
+	$jsonContent = Get-Content -Path $filepathJsonPublish -Raw | ConvertFrom-Json
+	
+	$slRevision = $jsonContent.next_rev
+	Write-Output "Streamlabs revision is $slRevision"
+}
+catch {
+	throw "Error: An error occurred. Details: $($_.Exception.Message)"
+}
 
 $env:Protobuf_DIR = "${github_workspace}\..\grpc_dist\cmake"
 $env:absl_DIR = "${github_workspace}\..\grpc_dist\lib\cmake\absl"
@@ -20,6 +37,8 @@ $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE SL_OBS_VERSION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE SL_OBS_VERSION=`"$($env:SL_OBS_VERSION)`")"
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser PRIVATE GITHUB_REVISION=""\)', "target_compile_definitions(sl-browser PRIVATE GITHUB_REVISION=`"${revision}`")"
 $cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE GITHUB_REVISION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE GITHUB_REVISION=`"${revision}`")"
+$cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser PRIVATE SL_REVISION=""\)', "target_compile_definitions(sl-browser PRIVATE SL_REVISION=`"${slRevision}`")"
+$cmakeContent = $cmakeContent -replace '#target_compile_definitions\(sl-browser-plugin PRIVATE SL_REVISION=""\)', "target_compile_definitions(sl-browser-plugin PRIVATE SL_REVISION=`"${slRevision}`")"
 
 # Write the updated content back to CMakeLists.txt
 Set-Content -Path .\CMakeLists.txt -Value $cmakeContent
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb4ab982..2174cbef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,7 +52,7 @@ add_executable(sl-browser WIN32)
 
 #target_compile_definitions(sl-browser PRIVATE SL_OBS_VERSION="")
 #target_compile_definitions(sl-browser PRIVATE GITHUB_REVISION="")
-#target_compile_definitions(sl-browser-plugin PRIVATE SL_REVISION="")
+#target_compile_definitions(sl-browser PRIVATE SL_REVISION="")
 target_compile_options(sl-browser PRIVATE $<IF:$<CONFIG:DEBUG>,/MTd,/MT>)
 target_link_options(sl-browser PRIVATE /NODEFAULTLIB:msvcrt)
 

From 5b3db040e38f71922be2805ae83e88c4348b9ca9 Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 17:19:01 -0500
Subject: [PATCH 07/11] Fix typo

---
 CI/sign.ps1 | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/CI/sign.ps1 b/CI/sign.ps1
index db95e1ca..b5099200 100644
--- a/CI/sign.ps1
+++ b/CI/sign.ps1
@@ -147,12 +147,11 @@ try {
 	$Env:AWS_SECRET_ACCESS_KEY = $Env:AWS_RELEASE_SECRET_ACCESS_KEY
 	$Env:AWS_DEFAULT_REGION = "us-west-2"
 	
-	try {
-		aws s3 cp $jsonFilePath https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/ --acl public-read --metadata-directive REPLACE --cache-control "max-age=0, no-cache, no-store, must-revalidate"
-		
-		if ($LASTEXITCODE -ne 0) {
-			throw "AWS CLI returned a non-zero exit code: $LASTEXITCODE"
-		}
+	aws s3 cp $jsonFilePath https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/ --acl public-read --metadata-directive REPLACE --cache-control "max-age=0, no-cache, no-store, must-revalidate"
+	
+	if ($LASTEXITCODE -ne 0) {
+		throw "AWS CLI returned a non-zero exit code: $LASTEXITCODE"
+	}
 }
 catch {
     throw "Error: An error occurred during revision updating. Details: $($_.Exception.Message)"

From 051c7cff20cb26d2da23e9d1f8bca395bcd68a6a Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 17:40:41 -0500
Subject: [PATCH 08/11] Remove meta_publish logic, needs to be db

---
 CI/sign.ps1 | 71 +----------------------------------------------------
 1 file changed, 1 insertion(+), 70 deletions(-)

diff --git a/CI/sign.ps1 b/CI/sign.ps1
index b5099200..5f92df98 100644
--- a/CI/sign.ps1
+++ b/CI/sign.ps1
@@ -86,73 +86,4 @@ cd archive/RelWithDebInfo
 7z a "../$signedArchiveFileName" .\*
 
 # Move the signed archive to the specified workspace
-Move-Item -Path "..\$signedArchiveFileName" -Destination "${github_workspace}\"
-
-# Add information to the revision library
-$slRevision = 0
-
-try {
-    # Download data for revisions
-    $urlJsonObsVersions = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/meta_publish.json"
-    $filepathJsonPublish = ".\meta_publish.json"
-    Invoke-WebRequest -Uri $urlJsonObsVersions -OutFile $filepathJsonPublish
-    $jsonContent = Get-Content -Path $filepathJsonPublish -Raw | ConvertFrom-Json
-    
-    $slRevision = $jsonContent.next_rev
-    Write-Output "Streamlabs revision is $slRevision"
-    
-    # Attempt to download existing revision builds JSON
-    $urlJsonRevisionBuilds = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/revision_builds.json"
-    $filepathJsonRevisionBuilds = ".\revision_builds.json"
-    
-    try {
-        Invoke-WebRequest -Uri $urlJsonRevisionBuilds -OutFile $filepathJsonRevisionBuilds
-    }
-    catch {
-        # If download fails, assume file does not exist and create a new JSON array
-        Set-Content -Path $filepathJsonRevisionBuilds -Value "[]"
-    }
-
-    # Load or initialize the revision builds JSON
-    $revisionBuilds = Get-Content -Path $filepathJsonRevisionBuilds -Raw | ConvertFrom-Json
-    
-    # Prepare the new entry
-    $newEntry = @{
-        "rev" = $slRevision
-        "date" = (Get-Date -UFormat %s)
-        "gitrev" = $revision
-    }
-
-    # Check if the entry already exists (based on rev and gitrev)
-    $exists = $false
-    foreach ($entry in $revisionBuilds) {
-        if ($entry.rev -eq $newEntry.rev -and $entry.gitrev -eq $newEntry.gitrev) {
-            $exists = $true
-            break
-        }
-    }
-    
-    # If the entry does not exist, add it
-    if (-not $exists) {
-        $revisionBuilds += $newEntry
-    }
-    
-    # Save the updated JSON back to the file
-    $revisionBuilds | ConvertTo-Json -Depth 100 | Set-Content -Path $filepathJsonRevisionBuilds
-    
-    Write-Output "Revision builds json formed. Uploading back to AWS."
-	
-	# Local environment variables, even if there are system ones with the same name, these are used for the cmd below
-	$Env:AWS_ACCESS_KEY_ID = $Env:AWS_RELEASE_ACCESS_KEY_ID
-	$Env:AWS_SECRET_ACCESS_KEY = $Env:AWS_RELEASE_SECRET_ACCESS_KEY
-	$Env:AWS_DEFAULT_REGION = "us-west-2"
-	
-	aws s3 cp $jsonFilePath https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/ --acl public-read --metadata-directive REPLACE --cache-control "max-age=0, no-cache, no-store, must-revalidate"
-	
-	if ($LASTEXITCODE -ne 0) {
-		throw "AWS CLI returned a non-zero exit code: $LASTEXITCODE"
-	}
-}
-catch {
-    throw "Error: An error occurred during revision updating. Details: $($_.Exception.Message)"
-}
\ No newline at end of file
+Move-Item -Path "..\$signedArchiveFileName" -Destination "${github_workspace}\"
\ No newline at end of file

From b30a3fe71c9ef8805639036e14985e4a39943a6a Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 18:18:51 -0500
Subject: [PATCH 09/11] Save in the bucket which revision was used

---
 .github/workflows/main.yml |  2 ++
 CI/pipeline.ps1            | 23 ++++++++++++++++++++---
 CI/release.ps1             |  3 ++-
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 300406e5..e9fc02b2 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -9,6 +9,8 @@ env:
   GRPC_VERSION: v1.58.0
   AWS_SYMB_ACCESS_KEY_ID: ${{secrets.AWS_SYMB_ACCESS_KEY_ID}}
   AWS_SYMB_SECRET_ACCESS_KEY: ${{secrets.AWS_SYMB_SECRET_ACCESS_KEY}}
+  AWS_RELEASE_ACCESS_KEY_ID: ${{secrets.AWS_RELEASE_ACCESS_KEY_ID}}
+  AWS_RELEASE_SECRET_ACCESS_KEY: ${{secrets.AWS_RELEASE_SECRET_ACCESS_KEY}}
   RELEASE_BUCKET: "slobs-cdn.streamlabs.com/obsplugin/intermediary_packages/"
     
 jobs:
diff --git a/CI/pipeline.ps1 b/CI/pipeline.ps1
index 2f9a4b1b..0d1e73f5 100644
--- a/CI/pipeline.ps1
+++ b/CI/pipeline.ps1
@@ -6,11 +6,12 @@ param(
 Write-Output "Workspace is $github_workspace"
 Write-Output "Github revision is $revision"
 
+# Get the revision we're using
 $slRevision = 0
 
 try {
 	# Download data for revisions
-	$urlJsonObsVersions = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/meta_publish.json"
+	$urlJsonObsVersions = "https://slobs-cdn.streamlabs.com/obsplugin/meta_publish.json"
 
 	$filepathJsonPublish = ".\meta_publish.json"
 	Invoke-WebRequest -Uri $urlJsonObsVersions -OutFile $filepathJsonPublish
@@ -23,6 +24,23 @@ catch {
 	throw "Error: An error occurred. Details: $($_.Exception.Message)"
 }
 
+# Save in the bucket which revision was used
+$Env:AWS_ACCESS_KEY_ID = $Env:AWS_RELEASE_ACCESS_KEY_ID
+$Env:AWS_SECRET_ACCESS_KEY = $Env:AWS_RELEASE_SECRET_ACCESS_KEY
+$Env:AWS_DEFAULT_REGION = "us-west-2"
+
+$revisionFilePath = Join-Path -Path $github_workspace -ChildPath "${revision}.json"=
+$newJsonContent = @{ rev = $slRevision } | ConvertTo-Json
+$newJsonContent | Out-File -FilePath $revisionFilePath
+Write-Output "New JSON file created at $revisionFilePath with content: $newJsonContent"
+
+aws s3 cp $jsonFilePath s3://slobs-cdn.streamlabs.com/obsplugin/meta_sha/ --acl public-read --metadata-directive REPLACE --cache-control "max-age=0, no-cache, no-store, must-revalidate"
+
+if ($LASTEXITCODE -ne 0) {
+	throw "AWS CLI returned a non-zero exit code: $LASTEXITCODE"
+}
+
+# Begin
 $env:Protobuf_DIR = "${github_workspace}\..\grpc_dist\cmake"
 $env:absl_DIR = "${github_workspace}\..\grpc_dist\lib\cmake\absl"
 $env:gRPC_DIR = "${github_workspace}\..\grpc_dist\lib\cmake\grpc"
@@ -118,7 +136,6 @@ if ($lastExitCode -ne 0) {
     throw "Symbol processing script exited with error code $lastExitCode"
 }
 
-
 # Define the output file name for the 7z archive
 Write-Output "-- 7z"
 $pathToArchive = "${github_workspace}\..\${revision}\build64\plugins\obs-sl-browser\RelWithDebInfo"
@@ -141,4 +158,4 @@ if (Test-Path -Path $pathToArchive) {
 Write-Output "Archive created: $archiveFileName"
 
 # Move the 7z archive to the $github_workspace directory
-Move-Item -Path $archiveFileName -Destination "${github_workspace}\"
+Move-Item -Path $archiveFileName -Destination "${github_workspace}\"
\ No newline at end of file
diff --git a/CI/release.ps1 b/CI/release.ps1
index 3056ad76..88335f97 100644
--- a/CI/release.ps1
+++ b/CI/release.ps1
@@ -1,5 +1,5 @@
 # URL to the JSON data for known OBS versions 
-$urlJsonObsVersions = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/obsversions.json"
+$urlJsonObsVersions = "https://slobs-cdn.streamlabs.com/obsplugin/obsversions.json"
 
 # Fetch the JSON content
 $jsonContent = Invoke-RestMethod -Uri $urlJsonObsVersions
@@ -109,6 +109,7 @@ function CreateJsonFile($folder, $branchName) {
     $jsonContent = @{}
     $jsonContent.package = $zipFile.Name
     $jsonContent.installer = $branchInstallerUrls[$branchName]
+    $jsonContent.revision = $revNumberOutgoing
     $jsonContent.files = $filesInBranch | Where-Object { -not $_.PSIsContainer } | ForEach-Object {
         $subPath = $_.FullName.Substring($_.FullName.IndexOf("$branchName\$branchName") + $branchName.Length * 2 + 2)
         @{

From da0ad77becd6c6b0556ed8c1ba7c96892116f683 Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 18:19:16 -0500
Subject: [PATCH 10/11] typo

---
 CI/pipeline.ps1 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CI/pipeline.ps1 b/CI/pipeline.ps1
index 0d1e73f5..0e5cc565 100644
--- a/CI/pipeline.ps1
+++ b/CI/pipeline.ps1
@@ -29,7 +29,7 @@ $Env:AWS_ACCESS_KEY_ID = $Env:AWS_RELEASE_ACCESS_KEY_ID
 $Env:AWS_SECRET_ACCESS_KEY = $Env:AWS_RELEASE_SECRET_ACCESS_KEY
 $Env:AWS_DEFAULT_REGION = "us-west-2"
 
-$revisionFilePath = Join-Path -Path $github_workspace -ChildPath "${revision}.json"=
+$revisionFilePath = Join-Path -Path $github_workspace -ChildPath "${revision}.json"
 $newJsonContent = @{ rev = $slRevision } | ConvertTo-Json
 $newJsonContent | Out-File -FilePath $revisionFilePath
 Write-Output "New JSON file created at $revisionFilePath with content: $newJsonContent"

From 4f6cdb67981532818355826e097eff2c8b0b930a Mon Sep 17 00:00:00 2001
From: unknown <stevensoftware52@gmail.com>
Date: Thu, 8 Feb 2024 18:26:13 -0500
Subject: [PATCH 11/11] fix typo

---
 CI/pipeline.ps1 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CI/pipeline.ps1 b/CI/pipeline.ps1
index 0e5cc565..b8c9e69a 100644
--- a/CI/pipeline.ps1
+++ b/CI/pipeline.ps1
@@ -34,7 +34,7 @@ $newJsonContent = @{ rev = $slRevision } | ConvertTo-Json
 $newJsonContent | Out-File -FilePath $revisionFilePath
 Write-Output "New JSON file created at $revisionFilePath with content: $newJsonContent"
 
-aws s3 cp $jsonFilePath s3://slobs-cdn.streamlabs.com/obsplugin/meta_sha/ --acl public-read --metadata-directive REPLACE --cache-control "max-age=0, no-cache, no-store, must-revalidate"
+aws s3 cp $revisionFilePath s3://slobs-cdn.streamlabs.com/obsplugin/meta_sha/ --acl public-read --metadata-directive REPLACE --cache-control "max-age=0, no-cache, no-store, must-revalidate"
 
 if ($LASTEXITCODE -ne 0) {
 	throw "AWS CLI returned a non-zero exit code: $LASTEXITCODE"