From f9d5b5f86117f6b60b251816c843bbfa1c89a84e Mon Sep 17 00:00:00 2001 From: Talen Fisher Date: Mon, 5 Oct 2020 18:08:23 -0500 Subject: [PATCH 1/2] Github Actions: Use Environment File --- .../CloudBuildServices/GitHubActions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs b/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs index 6965d4f2..db8e766e 100644 --- a/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs +++ b/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs @@ -19,6 +19,8 @@ internal class GitHubActions : ICloudBuild private static string BuildingRef => Environment.GetEnvironmentVariable("GITHUB_REF"); + private static string EnvironmentFile => Environment.GetEnvironmentVariable("GITHUB_ENV"); + public IReadOnlyDictionary SetCloudBuildNumber(string buildNumber, TextWriter stdout, TextWriter stderr) { return new Dictionary(); @@ -26,7 +28,7 @@ public IReadOnlyDictionary SetCloudBuildNumber(string buildNumbe public IReadOnlyDictionary SetCloudBuildVariable(string name, string value, TextWriter stdout, TextWriter stderr) { - (stdout ?? Console.Out).WriteLine($"##[set-env name={name};]{value}"); + File.AppendAllText(EnvironmentFile, $"{name}={value}{Environment.NewLine}"); return GetDictionaryFor(name, value); } From 795f5dfa2d483cf36f0f17299700d1a80ac8037e Mon Sep 17 00:00:00 2001 From: Talen Fisher Date: Mon, 5 Oct 2020 23:07:43 -0500 Subject: [PATCH 2/2] Add Newline at String Start --- src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs b/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs index db8e766e..55eac257 100644 --- a/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs +++ b/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs @@ -28,7 +28,7 @@ public IReadOnlyDictionary SetCloudBuildNumber(string buildNumbe public IReadOnlyDictionary SetCloudBuildVariable(string name, string value, TextWriter stdout, TextWriter stderr) { - File.AppendAllText(EnvironmentFile, $"{name}={value}{Environment.NewLine}"); + File.AppendAllText(EnvironmentFile, $"{Environment.NewLine}{name}={value}{Environment.NewLine}"); return GetDictionaryFor(name, value); }