@@ -29,36 +29,44 @@ public override string GenerateSetVersionMessage(VersionVariables variables)
29
29
30
30
public override string [ ] GenerateSetParameterMessage ( string name , string value )
31
31
{
32
+ // There is no equivalent function in GitHub Actions.
33
+
34
+ return new string [ 0 ] ;
35
+ }
36
+
37
+ public override void WriteIntegration ( System . Action < string > writer , VersionVariables variables , bool updateBuildNumber = true )
38
+ {
39
+ base . WriteIntegration ( writer , variables , updateBuildNumber ) ;
40
+
32
41
// https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
33
- // However it's important that GitHub Actions does not parse the log output. The outgoing environment variables must be
34
- // written to a temporary file (identified by the $GITHUB_ENV environment variable, which changes for every step in a workflow)
35
- // which is then parsed. That file must also be UTF-8 or it will fail.
42
+ // The outgoing environment variables must be written to a temporary file (identified by the $GITHUB_ENV environment
43
+ // variable, which changes for every step in a workflow) which is then parsed. That file must also be UTF-8 or it will fail.
36
44
37
- if ( ! string . IsNullOrWhiteSpace ( value ) )
45
+ if ( writer == null || ! updateBuildNumber )
38
46
{
39
- var gitHubSetEnvFilePath = environment . GetEnvironmentVariable ( GitHubSetEnvTempFileEnvironmentVariableName ) ;
40
- var assignment = $ "GitVersion_{ name } ={ value } ";
47
+ return ;
48
+ }
49
+
50
+ var gitHubSetEnvFilePath = environment . GetEnvironmentVariable ( GitHubSetEnvTempFileEnvironmentVariableName ) ;
41
51
42
- if ( gitHubSetEnvFilePath != null )
52
+ if ( gitHubSetEnvFilePath != null )
53
+ {
54
+ writer ( $ "Writing version variables to $GITHUB_ENV file for '{ GetType ( ) . Name } '.") ;
55
+ using ( var streamWriter = File . AppendText ( gitHubSetEnvFilePath ) ) // Already uses UTF-8 as required by GitHub
43
56
{
44
- using ( var streamWriter = File . AppendText ( gitHubSetEnvFilePath ) ) // Already uses UTF-8 as required by GitHub
57
+ foreach ( var variable in variables )
45
58
{
46
- streamWriter . WriteLine ( assignment ) ;
59
+ if ( ! string . IsNullOrEmpty ( variable . Value ) )
60
+ {
61
+ streamWriter . WriteLine ( $ "GitVersion_{ variable . Key } ={ variable . Value } ") ;
62
+ }
47
63
}
48
-
49
- return new [ ]
50
- {
51
- $ "Writing \" { assignment } \" to the file at ${ GitHubSetEnvTempFileEnvironmentVariableName } "
52
- } ;
53
64
}
54
-
55
- return new [ ]
56
- {
57
- $ "Unable to write \" { assignment } \" to ${ GitHubSetEnvTempFileEnvironmentVariableName } because the environment variable is not set."
58
- } ;
59
65
}
60
-
61
- return new string [ 0 ] ;
66
+ else
67
+ {
68
+ writer ( $ "Unable to write GitVersion variables to ${ GitHubSetEnvTempFileEnvironmentVariableName } because the environment variable is not set.") ;
69
+ }
62
70
}
63
71
64
72
public override string GetCurrentBranch ( bool usingDynamicRepos )
0 commit comments