Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SL revision in builds #19

Merged
merged 11 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
42 changes: 39 additions & 3 deletions CI/pipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,43 @@ param(
)

Write-Output "Workspace is $github_workspace"
Write-Output "Revision is $revision"
Write-Output "Github revision is $revision"

# Get the revision we're using
$slRevision = 0

try {
# Download data for revisions
$urlJsonObsVersions = "https://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)"
}

# 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 $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"
}

# 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"
Expand All @@ -20,6 +55,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
Expand Down Expand Up @@ -99,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"
Expand All @@ -122,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}\"
3 changes: 2 additions & 1 deletion CI/release.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
@{
Expand Down
2 changes: 1 addition & 1 deletion CI/sign.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ cd archive/RelWithDebInfo
7z a "../$signedArchiveFileName" .\*

# Move the signed archive to the specified workspace
Move-Item -Path "..\$signedArchiveFileName" -Destination "${github_workspace}\"
Move-Item -Path "..\$signedArchiveFileName" -Destination "${github_workspace}\"
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 PRIVATE SL_REVISION="")
target_compile_options(sl-browser PRIVATE $<IF:$<CONFIG:DEBUG>,/MTd,/MT>)
target_link_options(sl-browser PRIVATE /NODEFAULTLIB:msvcrt)

Expand Down Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion CrashHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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>());
Expand Down Expand Up @@ -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");
}
Expand Down
4 changes: 2 additions & 2 deletions PluginJsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
35 changes: 33 additions & 2 deletions SlBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 << revision << "." << version << "." << githubRevision;
CefString(&settings.user_agent_product) = prod_ver.str();

settings.persist_user_preferences = 1;

char cache_path[MAX_PATH];
Expand Down