diff --git a/eng/DependencyManagement.psm1 b/eng/DependencyManagement.psm1 index 8f9746c203..83ffd37acd 100644 --- a/eng/DependencyManagement.psm1 +++ b/eng/DependencyManagement.psm1 @@ -25,3 +25,7 @@ function Resolve-DotnetProductUrl([string] $akaMsUrl) { Write-Host "Resolved URL: $resolvedUrl" return $resolvedUrl } + +function Get-ProductReleaseState() { + return $(Get-Branch) -ieq 'main' ? 'Release' : 'Prerelease' +} diff --git a/eng/Set-DotnetVersions.ps1 b/eng/Set-DotnetVersions.ps1 index 8c4ba4bd33..091dfcd86a 100644 --- a/eng/Set-DotnetVersions.ps1 +++ b/eng/Set-DotnetVersions.ps1 @@ -58,7 +58,12 @@ param( # File containing checksums for each product asset; used to override the behavior of locating the checksums from blob storage accounts. [string] - $ChecksumsFile + $ChecksumsFile, + + # The release state of the product assets + [ValidateSet("Prerelease", "Release")] + [string] + $ReleaseState ) Import-Module -force $PSScriptRoot/DependencyManagement.psm1 @@ -113,6 +118,10 @@ if ($UseStableBranding) { $updateDepsArgs += "--stable-branding" } +if ($ReleaseState) { + $updateDepsArgs += "--release-state=$ReleaseState" +} + $versionSourceName = switch ($PSCmdlet.ParameterSetName) { "DotnetSdk" { "dotnet/sdk" } "DotnetMonitor" { "dotnet/dotnet-monitor/$ProductVersion" } diff --git a/eng/pipelines/steps/update-dotnet-dependencies.yml b/eng/pipelines/steps/update-dotnet-dependencies.yml index bb6670ce2d..ed825bfcbf 100644 --- a/eng/pipelines/steps/update-dotnet-dependencies.yml +++ b/eng/pipelines/steps/update-dotnet-dependencies.yml @@ -43,6 +43,8 @@ steps: if ("${{ parameters.useInternalBuild }}" -eq "true") { $args["ChecksumSasQueryString"] = '"$(dotnetchecksumsstage-account-sas-read-token)"' $args["BinarySasQueryString"] = '"$(dotnetstage-account-sas-read-token)"' + } else { + $args["ReleaseState"] = $(Get-ProductReleaseState) } Write-Host "Executing Set-DotnetVersions.ps1 for $($versionInfo.DockerfileVersion)" diff --git a/eng/pipelines/update-dependencies-monitor.yml b/eng/pipelines/update-dependencies-monitor.yml index 1017e16dec..9e56aff615 100644 --- a/eng/pipelines/update-dependencies-monitor.yml +++ b/eng/pipelines/update-dependencies-monitor.yml @@ -35,6 +35,7 @@ stages: MonitorVersion = "$(monitorVer)" AzdoVariableName = 'updateDepsArgs' UseStableBranding = [bool]::Parse("$(stableBranding)") + ReleaseState = $(Get-ProductReleaseState) } $(engPath)/Set-DotnetVersions.ps1 @scriptArgs diff --git a/eng/update-dependencies/BaseUrlUpdater.cs b/eng/update-dependencies/BaseUrlUpdater.cs index 5dab05fbbf..ffff926400 100644 --- a/eng/update-dependencies/BaseUrlUpdater.cs +++ b/eng/update-dependencies/BaseUrlUpdater.cs @@ -51,6 +51,10 @@ protected override string TryGetDesiredValue(IEnumerable depend unresolvedBaseUrl = $"https://dotnetstage.blob.core.windows.net/{sdkVersion}-internal"; } + else if (_options.ReleaseState.HasValue) + { + unresolvedBaseUrl = $"$({ManifestHelper.GetBaseUrlVariableName(_options.ReleaseState.Value, _options.TargetBranch)})"; + } else { // Modifying the URL from internal to public is not suppported because it's not possible to know diff --git a/eng/update-dependencies/ManifestHelper.cs b/eng/update-dependencies/ManifestHelper.cs index 75b9d768f5..a2ddb40455 100644 --- a/eng/update-dependencies/ManifestHelper.cs +++ b/eng/update-dependencies/ManifestHelper.cs @@ -27,7 +27,7 @@ public static string GetBaseUrl(JObject manifestVariables, Options options) => ResolveVariableValue(GetBaseUrlVariableName(options.DockerfileVersion, options.SourceBranch, options.VersionSourceName), manifestVariables); /// - /// Constructs the name of the base URL variable. + /// Constructs the name of the product version base URL variable. /// /// Dockerfile version. /// Name of the branch. @@ -43,6 +43,23 @@ string v when v.Contains("aspire-dashboard") => $"aspire-dashboard", return $"{product}|{dockerfileVersion}|base-url|{branch}"; } + /// + /// Constructs the name of the shared base URL variable. + /// + /// Release state of the product assets. + /// Name of the branch. + public static string GetBaseUrlVariableName(ReleaseState releaseState, string branch) + { + string qualityString = releaseState switch + { + ReleaseState.Prerelease => "preview", + ReleaseState.Release => "maintenance", + _ => throw new NotSupportedException() + }; + + return $"base-url|public|{qualityString}|{branch}"; + } + public static string GetVersionVariableName(VersionType versionType, string productName, string dockerfileVersion) => $"{productName}|{dockerfileVersion}|{versionType.ToString().ToLowerInvariant()}-version"; diff --git a/eng/update-dependencies/Options.cs b/eng/update-dependencies/Options.cs index 9be3a57206..75a05cf0f4 100644 --- a/eng/update-dependencies/Options.cs +++ b/eng/update-dependencies/Options.cs @@ -31,9 +31,11 @@ public class Options public bool UpdateOnly => Email == null || Password == null || User == null || TargetBranch == null; public bool IsInternal => !string.IsNullOrEmpty(BinarySasQueryString) || !string.IsNullOrEmpty(ChecksumSasQueryString); public string ChecksumsFile { get; } + public ReleaseState? ReleaseState { get; } public Options(string dockerfileVersion, string[] productVersion, string versionSourceName, string email, string password, string user, - bool computeShas, bool stableBranding, string binarySas, string checksumSas, string sourceBranch, string targetBranch, string org, string project, string repo, string checksumsFile) + bool computeShas, bool stableBranding, string binarySas, string checksumSas, string sourceBranch, string targetBranch, string org, + string project, string repo, string checksumsFile, ReleaseState? releaseState) { DockerfileVersion = dockerfileVersion; ProductVersions = productVersion @@ -66,6 +68,8 @@ public Options(string dockerfileVersion, string[] productVersion, string version { ProductVersions["dotnet"] = ProductVersions["aspnet"]; } + + ReleaseState = releaseState; } public static IEnumerable GetCliSymbols() => @@ -86,8 +90,15 @@ public static IEnumerable GetCliSymbols() => new Option("--org", "Name of the AzDO organization"), new Option("--project", "Name of the AzDO project"), new Option("--repo", "Name of the AzDO repo"), - new Option("--checksums-file", "File containing a list of checksums for each product asset") + new Option("--checksums-file", "File containing a list of checksums for each product asset"), + new Option("--release-state", "The release state of the product assets") }; } + + public enum ReleaseState + { + Prerelease, + Release + } } #nullable disable