Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OutputVersion nuke target #14890

Merged
merged 4 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"CreateNugetPackages",
"GenerateCppHeaders",
"OutputApiDiff",
"OutputVersion",
"Package",
"RunCoreLibsTests",
"RunHtmlPreviewerTests",
Expand Down Expand Up @@ -121,6 +122,7 @@
"CreateNugetPackages",
"GenerateCppHeaders",
"OutputApiDiff",
"OutputVersion",
"Package",
"RunCoreLibsTests",
"RunHtmlPreviewerTests",
Expand All @@ -145,6 +147,9 @@
"Quiet",
"Verbose"
]
},
"version-output-dir": {
"type": "string"
}
}
}
Expand Down
30 changes: 9 additions & 21 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,19 @@ jobs:

- job: GetPRNumber
pool:
vmImage: 'windows-2022'
vmImage: 'ubuntu-20.04'
variables:
SolutionDir: '$(Build.SourcesDirectory)'
steps:
- task: PowerShell@2
displayName: Get PR Number
- task: UseDotNet@2
displayName: 'Use .NET 8.0 SDK'
inputs:
targetType: 'inline'
script: |
$Namespace = @{ msbuild = "http://schemas.microsoft.com/developer/msbuild/2003" }
$versionBase = Select-Xml -Path build\SharedVersion.props -XPath /msbuild:Project/msbuild:PropertyGroup/msbuild:Version -Namespace $Namespace |ForEach-Object {$_.Node.Innerxml}
Write-Host "Base Version Number is:-" $versionBase

$prId = $env:System_PullRequest_PullRequestNumber
Write-Host "PR Number is:-" $env:System_PullRequest_PullRequestNumber

if (!([string]::IsNullOrWhiteSpace($prId)))
{
Set-Content -Path $env:Build_ArtifactStagingDirectory\prId.txt -Value $prId
}
if (!([string]::IsNullOrWhiteSpace($versionBase)))
{
Set-Content -Path $env:Build_ArtifactStagingDirectory\versionBase.txt -Value $versionBase
}

packageType: sdk
useGlobalJson: true
- task: CmdLine@2
displayName: 'Run Build'
inputs:
script: ./build.sh --target OutputVersion --version-output-dir $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
Expand Down
15 changes: 15 additions & 0 deletions nukebuild/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,21 @@ DotNetTestSettings ApplySetting(DotNetTestSettings c, Configure<DotNetTestSettin
);
});

Target OutputVersion => _ => _
.Requires(() => VersionOutputDir)
.Executes(() =>
{
var versionFile = Path.Combine(Parameters.VersionOutputDir, "version.txt");
var currentBuildVersion = Parameters.Version;
Console.WriteLine("Version is: " + currentBuildVersion);
File.WriteAllText(versionFile, currentBuildVersion);

var prIdFile = Path.Combine(Parameters.VersionOutputDir, "prId.txt");
var prId = Environment.GetEnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTNUMBER");
Console.WriteLine("PR Number is: " + prId);
File.WriteAllText(prIdFile, prId);
});

void RunCoreTest(string projectName)
{
Information($"Running tests from {projectName}");
Expand Down
7 changes: 6 additions & 1 deletion nukebuild/BuildParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ public partial class Build

[Parameter(Name = "api-baseline")]
public string ApiValidationBaseline { get; set; }

[Parameter(Name = "update-api-suppression")]
public bool? UpdateApiValidationSuppression { get; set; }

[Parameter(Name = "version-output-dir")]
public AbsolutePath VersionOutputDir { get; set; }

public class BuildParameters
{
public string Configuration { get; }
Expand Down Expand Up @@ -70,6 +73,7 @@ public class BuildParameters
public string ApiValidationBaseline { get; }
public bool UpdateApiValidationSuppression { get; }
public AbsolutePath ApiValidationSuppressionFiles { get; }
public AbsolutePath VersionOutputDir { get; }

public BuildParameters(Build b, bool isPackingToLocalCache)
{
Expand Down Expand Up @@ -146,6 +150,7 @@ public BuildParameters(Build b, bool isPackingToLocalCache)
ZipCoreArtifacts = ZipRoot / ("Avalonia-" + FileZipSuffix);
ZipNuGetArtifacts = ZipRoot / ("Avalonia-NuGet-" + FileZipSuffix);
ApiValidationSuppressionFiles = RootDirectory / "api";
VersionOutputDir = b.VersionOutputDir;
}

string GetVersion()
Expand Down
Loading