mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 08:18:20 -04:00
Allows us to get rid of a ton of abstraction in SboxBuild, and gets rid of a lot of GitHub API plumbing. I feel like now that our workflows are more complex it's nicer to just use GitHub directly rather than having our own pipeline abstraction in SboxBuild. This way we get nicer logging and error reporting, which we can\t achieve through GitHub API.
78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
using static Facepunch.Constants;
|
|
|
|
namespace Facepunch.Steps;
|
|
|
|
internal class SentryRelease( string org, string project )
|
|
{
|
|
public string Organization { get; } = org;
|
|
public string Project { get; } = project;
|
|
|
|
internal ExitCode Run()
|
|
{
|
|
try
|
|
{
|
|
string version = Utility.VersionName();
|
|
Log.Info( $"Creating Sentry release for version {version}..." );
|
|
|
|
var projectStr = $"--project {Project}";
|
|
bool success;
|
|
|
|
// Create new release
|
|
Log.Info( "Creating new release" );
|
|
success = RunSentryCommand( $"releases new \"{version}\" --org \"{Organization}\" {projectStr}" );
|
|
if ( !success ) return ExitCode.Failure;
|
|
|
|
// Set commits
|
|
Log.Info( "Setting commits" );
|
|
success = RunSentryCommand( $"releases set-commits \"{version}\" --auto --org \"{Organization}\" {projectStr}" );
|
|
if ( !success ) return ExitCode.Failure;
|
|
|
|
// Create deploy
|
|
Log.Info( "Creating deploy" );
|
|
success = RunSentryCommand( $"releases deploys \"{version}\" new -e retail --org \"{Organization}\" {projectStr}" );
|
|
if ( !success ) return ExitCode.Failure;
|
|
|
|
// Finalize release
|
|
Log.Info( "Finalizing release" );
|
|
success = RunSentryCommand( $"releases finalize \"{version}\" --org \"{Organization}\" {projectStr}" );
|
|
if ( !success ) return ExitCode.Failure;
|
|
|
|
Log.Info( "Successfully created and finalized Sentry release" );
|
|
return ExitCode.Success;
|
|
}
|
|
catch ( Exception ex )
|
|
{
|
|
Log.Error( $"Sentry release creation failed with error: {ex}" );
|
|
return ExitCode.Failure;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Runs a Sentry CLI command with the appropriate auth token from environment variables
|
|
/// </summary>
|
|
public static bool RunSentryCommand( string arguments, string workingDirectory = null )
|
|
{
|
|
var token = Environment.GetEnvironmentVariable( "SENTRY_AUTH_TOKEN" );
|
|
|
|
if ( string.IsNullOrEmpty( token ) )
|
|
{
|
|
Log.Warning( "SENTRY_AUTH_TOKEN was empty" );
|
|
return false;
|
|
}
|
|
|
|
// Create a custom environment variable dictionary for the auth token
|
|
var envVars = new Dictionary<string, string>
|
|
{
|
|
{ "SENTRY_AUTH_TOKEN", token }
|
|
};
|
|
|
|
return Utility.RunProcess(
|
|
"sentry-cli.exe",
|
|
arguments,
|
|
workingDirectory,
|
|
envVars,
|
|
1200000
|
|
);
|
|
}
|
|
}
|