Skip to content

Commit

Permalink
Allow update-dependencies to update product base URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jander-msft committed Aug 23, 2024
1 parent 58d8cdf commit e33048b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 4 deletions.
4 changes: 4 additions & 0 deletions eng/DependencyManagement.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
11 changes: 10 additions & 1 deletion eng/Set-DotnetVersions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" }
Expand Down
2 changes: 2 additions & 0 deletions eng/pipelines/steps/update-dotnet-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
1 change: 1 addition & 0 deletions eng/pipelines/update-dependencies-monitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ stages:
MonitorVersion = "$(monitorVer)"
AzdoVariableName = 'updateDepsArgs'
UseStableBranding = [bool]::Parse("$(stableBranding)")
ReleaseState = $(Get-ProductReleaseState)
}
$(engPath)/Set-DotnetVersions.ps1 @scriptArgs
Expand Down
4 changes: 4 additions & 0 deletions eng/update-dependencies/BaseUrlUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ protected override string TryGetDesiredValue(IEnumerable<IDependencyInfo> 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
Expand Down
19 changes: 18 additions & 1 deletion eng/update-dependencies/ManifestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static string GetBaseUrl(JObject manifestVariables, Options options) =>
ResolveVariableValue(GetBaseUrlVariableName(options.DockerfileVersion, options.SourceBranch, options.VersionSourceName), manifestVariables);

/// <summary>
/// Constructs the name of the base URL variable.
/// Constructs the name of the product version base URL variable.
/// </summary>
/// <param name="dockerfileVersion">Dockerfile version.</param>
/// <param name="branch">Name of the branch.</param>
Expand All @@ -43,6 +43,23 @@ string v when v.Contains("aspire-dashboard") => $"aspire-dashboard",
return $"{product}|{dockerfileVersion}|base-url|{branch}";
}

/// <summary>
/// Constructs the name of the shared base URL variable.
/// </summary>
/// <param name="releaseState">Release state of the product assets.</param>
/// <param name="branch">Name of the branch.</param>
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";

Expand Down
15 changes: 13 additions & 2 deletions eng/update-dependencies/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,6 +68,8 @@ public Options(string dockerfileVersion, string[] productVersion, string version
{
ProductVersions["dotnet"] = ProductVersions["aspnet"];
}

ReleaseState = releaseState;
}

public static IEnumerable<Symbol> GetCliSymbols() =>
Expand All @@ -86,8 +90,15 @@ public static IEnumerable<Symbol> GetCliSymbols() =>
new Option<string>("--org", "Name of the AzDO organization"),
new Option<string>("--project", "Name of the AzDO project"),
new Option<string>("--repo", "Name of the AzDO repo"),
new Option<string>("--checksums-file", "File containing a list of checksums for each product asset")
new Option<string>("--checksums-file", "File containing a list of checksums for each product asset"),
new Option<ReleaseState?>("--release-state", "The release state of the product assets")
};
}

public enum ReleaseState
{
Prerelease,
Release
}
}
#nullable disable

0 comments on commit e33048b

Please sign in to comment.