Skip to content

Commit

Permalink
Add workaround when building from tags on github action with `mode: M…
Browse files Browse the repository at this point in the history
…ainline`
  • Loading branch information
D3-LucaPiombino committed Sep 18, 2022
1 parent b24e9ed commit fbf4f24
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ on:
- 'feature/**'
- 'release/**'
tags:
- 'v1*'
- 'v2*'
- 'v3*'
- 'v4*'
- 'v5*'
- '*.*.*'
- 'v*.*.*'
paths-ignore:
- 'docs/**/*'
- '**/*.md'
Expand All @@ -39,11 +36,8 @@ on:
- 'feature/**'
- 'release/**'
tags:
- 'v1*'
- 'v2*'
- 'v3*'
- 'v4*'
- 'v5*'
- '*.*.*'
- 'v*.*.*'
paths-ignore:
- 'docs/**/*'
- '**/*.md'
Expand Down
19 changes: 18 additions & 1 deletion build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Build : NukeBuild
/// - Microsoft VisualStudio https://nuke.build/visualstudio
/// - Microsoft VSCode https://nuke.build/vscode

public static int Main () => Execute<Build>(x => x.Compile);
public static int Main() => Execute<Build>(x => x.Compile);

[Nuke.Common.Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
Expand All @@ -83,6 +83,23 @@ class Build : NukeBuild
static string PackageContentType => "application/octet-stream";
static string ChangeLogFile => RootDirectory / "CHANGELOG.md";


protected override void OnBuildCreated()
{
var githubRef = Environment.GetEnvironmentVariable("GITHUB_REF");
if (githubRef?.StartsWith("refs/tags", StringComparison.InvariantCultureIgnoreCase) == true)
{
Serilog.Log.Information(
"GITHUB_REF is {GITHUB_REF}. " +
"Apply workaround for GitVersion when building release tags with GitHubActions. Clear GITHUB_REF",
githubRef
);
Environment.SetEnvironmentVariable("GITHUB_REF", "", EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("GITHUB_REF", "", EnvironmentVariableTarget.User);
}
base.OnBuildCreated();
}

Target Clean => _ => _
.Description($"Clean")
.Before(Compile)
Expand Down

0 comments on commit fbf4f24

Please sign in to comment.