mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 16:28:36 -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.
35 lines
857 B
C#
35 lines
857 B
C#
using static Facepunch.Constants;
|
|
|
|
namespace Facepunch.Steps;
|
|
|
|
/// <summary>
|
|
/// Step to write version information to a file
|
|
/// </summary>
|
|
internal class WriteVersion
|
|
{
|
|
internal ExitCode Run()
|
|
{
|
|
try
|
|
{
|
|
Log.Info( "Writing version information..." );
|
|
|
|
string target = "game/.version";
|
|
string contents = $"{Utility.VersionName()}\n" +
|
|
$"{Environment.GetEnvironmentVariable( "GITHUB_RUN_ID" )}\n" +
|
|
$"{Environment.GetEnvironmentVariable( "GITHUB_JOB" )}\n" +
|
|
$"{Environment.GetEnvironmentVariable( "GITHUB_ACTOR" )}\n" +
|
|
$"{DateTime.UtcNow}\n";
|
|
|
|
File.WriteAllText( target, contents );
|
|
|
|
Log.Info( $"Version information written to {target}" );
|
|
return ExitCode.Success;
|
|
}
|
|
catch ( Exception ex )
|
|
{
|
|
Log.Error( $"Failed to write version information: {ex}" );
|
|
return ExitCode.Failure;
|
|
}
|
|
}
|
|
}
|