Skip to content
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
4 changes: 4 additions & 0 deletions .github/instructions/csharp.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ Other patterns:
- Comments inside methods should explain "why," not "what".
- Comments should provide context and rationale behind the code.
- Avoid redundant comments that restate the code - not all code needs comments.

## Testing

- Do not add comments like `// Arrange`, `// Act`, or `// Assert` in unit tests.
1 change: 1 addition & 0 deletions .github/linters/.linkspector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dirs:
- .
- .github
excludedDirs:
- eng/announcement-templates
- eng/readme-templates
ignorePatterns:
- pattern: "^https://github.com/microsoft/mcr.*$"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-code-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
uses: github/super-linter@v6 # https://github.com/github/super-linter
env:
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: eng/docker-tools/.*|eng/readme-templates/.*|.portal-docs/.*
FILTER_REGEX_EXCLUDE: eng/announcement-templates/.*|eng/docker-tools/.*|eng/readme-templates/.*|.portal-docs/.*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_MARKDOWN: true
218 changes: 218 additions & 0 deletions eng/announcement-templates/Render.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
#!/usr/bin/env dotnet
#:package Fluid.Core@2.31.0
#:package Spectre.Console@0.54.1-alpha.0.26
#:package System.CommandLine@2.0.2

using System.CommandLine;
using Fluid;
using Spectre.Console;

var renderCommand = new RenderTemplateCommand(templateFileInfo =>
{
if (!templateFileInfo.Exists)
{
Console.Error.WriteLine($"Template file not found: {templateFileInfo.FullName}");
return 1;
}

if (!TemplateDefinitions.TemplateIsSupported(templateFileInfo))
{
Console.Error.WriteLine($"Unsupported template file: {templateFileInfo.Name}");
return 1;
}

// Parse the template first, so any errors are caught before prompting for input
var template = TemplateDefinitions.ParseTemplate(templateFileInfo, out var parseError);
if (template is null)
{
Console.Error.WriteLine($"Failed to parse template: {parseError}");
return 1;
}

// Display some helpful reference information right before prompting the user for input.
DisplayPatchTuesdayReferenceText();

// This will prompt the user for the template parameters.
TemplateContext context = TemplateDefinitions.GetTemplateContext(templateFileInfo);

// Finally, render the template with the provided parameters.
var result = template.Render(context);

AnsiConsole.WriteLine();
AnsiConsole.Write(new Rule("[green]Generated Announcement[/]"));
AnsiConsole.WriteLine();
Console.WriteLine(result);

return 0;
});

var parseResult = renderCommand.Parse(args);
return parseResult.Invoke();


static void DisplayPatchTuesdayReferenceText()
{
AnsiConsole.WriteLine();
AnsiConsole.MarkupLine("[grey]Patch Tuesdays Reference:[/]");
for (int i = -4; i <= 4; i++)
{
var pt = DateOnly.GetPatchTuesday(i);
var label = i == 0 ? "this month" : i.ToString("+0;-0");
AnsiConsole.MarkupLine($"[grey] {label,11}: {pt:yyyy-MM-dd}[/]");
}

AnsiConsole.WriteLine();
}

static class TemplateDefinitions
{
// All supported templates and their associated context factories.
private static readonly Dictionary<string, Func<TemplateContext>> s_templateContexts = new()
{
["alpine-floating-tag-update.md"] = AlpineFloatingTagTemplateParameters.ContextFactory,
};

public static TemplateContext GetTemplateContext(FileInfo templateFileInfo)
{
var contextFactory = s_templateContexts[templateFileInfo.Name];
var templateContext = contextFactory();
return templateContext;
}

public static IFluidTemplate? ParseTemplate(FileInfo templateFile, out string? error)
{
var parser = new FluidParser();
var templateText = File.ReadAllText(templateFile.FullName);

if (!parser.TryParse(templateText, out var template, out string? internalError))
{
error = internalError;
return null;
}

error = null;
return template;
}

public static bool TemplateIsSupported(FileInfo templateFile) =>
s_templateContexts.ContainsKey(templateFile.Name);
}

sealed class RenderTemplateCommand : RootCommand
{
public RenderTemplateCommand(Func<FileInfo, int> handler) : base("Render announcement template")
{
var templateFileArgument = new Argument<FileInfo>("templateFile")
{
Description = "The template file to read and display on the console",
};
Arguments.Add(templateFileArgument);

SetAction(parseResult =>
{
var templateFileResult = parseResult.GetValue(templateFileArgument);
if (parseResult.Errors.Count == 0 && templateFileResult is FileInfo validTemplateFile)
{
return handler(validTemplateFile);
}

if (parseResult.Errors.Count > 0)
{
foreach (var error in parseResult.Errors)
Console.Error.WriteLine(error.Message);

return 1;
}

// Show help text
Parse("-h").Invoke();

return 0;
});
}
}

sealed record AlpineFloatingTagTemplateParameters(
string NewVersion,
string OldVersion,
DateTime PublishDate,
DateTime ReleaseDate,
DateTime EolDate,
string PublishDiscussionUrl,
string DotnetExampleVersion)
{
public static Func<TemplateContext> ContextFactory { get; } = () =>
{
var model = PromptForInput();
return new TemplateContext(model);
};

public static AlpineFloatingTagTemplateParameters PromptForInput()
{
var newVersion = AnsiConsole.Prompt(
new TextPrompt<string>("New Alpine version:")
.DefaultValue("3.XX"));

var oldVersion = AnsiConsole.Prompt(
new TextPrompt<string>("Previous Alpine version:")
.DefaultValue("3.XX"));

var publishDate = AnsiConsole.Prompt(
new TextPrompt<DateOnly>($"When was Alpine {newVersion} published?")
.DefaultValue(DateOnly.GetPatchTuesday(-1)));

const string DiscussionQueryLink = "https://github.com/dotnet/dotnet-docker/discussions/categories/announcements?discussions_q=is%3Aopen+category%3AAnnouncements+alpine";
var publishDiscussionUrl = AnsiConsole.Prompt(
new TextPrompt<string>($"Link to announcement for publishing Alpine {newVersion} images (see {DiscussionQueryLink}):"));

var releaseDate = AnsiConsole.Prompt(
new TextPrompt<DateOnly>($"When were floating tags moved from Alpine {oldVersion} to {newVersion}?")
.DefaultValue(DateOnly.GetPatchTuesday(0)));

var eolDate = AnsiConsole.Prompt(
new TextPrompt<DateOnly>($"When will we stop publishing Alpine {oldVersion} images?")
.DefaultValue(DateOnly.GetPatchTuesday(3)));

var dotnetExampleVersion = AnsiConsole.Prompt(
new TextPrompt<string>(".NET example version for tags:")
.DefaultValue("10.0"));

return new AlpineFloatingTagTemplateParameters(
newVersion,
oldVersion,
publishDate.ToDateTime(TimeOnly.MinValue),
releaseDate.ToDateTime(TimeOnly.MinValue),
eolDate.ToDateTime(TimeOnly.MinValue),
publishDiscussionUrl,
dotnetExampleVersion);
}
}

internal static class DateOnlyExtensions
{
extension(DateOnly date)
{
/// <summary>
/// Gets the Patch Tuesday (second Tuesday of the month) for a month
/// relative to the current month.
/// </summary>
/// <param name="offset">
/// The number of months from the current month.
/// 0 = this month, 1 = next month, -3 = three months ago.
/// </param>
/// <returns>The date of Patch Tuesday for the target month.</returns>
public static DateOnly GetPatchTuesday(int offset = 0)
{
var today = DateOnly.FromDateTime(DateTime.Today);
var targetMonth = today.AddMonths(offset);
var firstOfMonth = new DateOnly(targetMonth.Year, targetMonth.Month, 1);

// Find the first Tuesday
var daysUntilTuesday = ((int)DayOfWeek.Tuesday - (int)firstOfMonth.DayOfWeek + 7) % 7;
var firstTuesday = firstOfMonth.AddDays(daysUntilTuesday);

// Second Tuesday is 7 days later
return firstTuesday.AddDays(7);
}
}
}
23 changes: 23 additions & 0 deletions eng/announcement-templates/alpine-floating-tag-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Alpine Floating Tags Updated to Alpine {{ NewVersion }}

In {{ PublishDate | date: "%B %Y" }}, [Alpine {{ NewVersion }} container images were published]({{ PublishDiscussionUrl }}). For today's {{ ReleaseDate | date: "%B %Y" }} .NET release, all Alpine floating tags now point to Alpine {{ NewVersion }} instead of Alpine {{ OldVersion }} according to our [tagging policy](https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-tags.md).

Per the [.NET Docker platform support policy](https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-platforms.md#linux), Alpine {{ OldVersion }} images will no longer be maintained starting on {{ EolDate | date: "%B %-d, %Y" }} (3 months after Alpine {{ NewVersion }} images were released).

## Details

Please review the [Alpine {{ NewVersion }} changelog](https://alpinelinux.org/posts/Alpine-{{ NewVersion }}.0-released.html) for more details on changes that were made in this version of Alpine.

The affected floating tags use this naming pattern:

* `<version>-alpine` (e.g. `{{ DotnetExampleVersion }}-alpine`)
* `<version>-alpine-<variant>` (e.g. `{{ DotnetExampleVersion }}-alpine-extra`)
* `<version>-alpine-<arch>` (e.g. `{{ DotnetExampleVersion }}-alpine-amd64`)
* `<version>-alpine-<variant>-<arch>` (e.g. `{{ DotnetExampleVersion }}-alpine-extra-amd64`)

The following image repos have been updated:

* dotnet/sdk - [Microsoft Artifact Registry](https://mcr.microsoft.com/product/dotnet/sdk/about)
* dotnet/aspnet - [Microsoft Artifact Registry](https://mcr.microsoft.com/product/dotnet/aspnet/about)
* dotnet/runtime - [Microsoft Artifact Registry](https://mcr.microsoft.com/product/dotnet/runtime/about)
* dotnet/runtime-deps - [Microsoft Artifact Registry](https://mcr.microsoft.com/product/dotnet/runtime-deps/about)
3 changes: 0 additions & 3 deletions eng/pipelines/dotnet-core-samples-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ pr:

variables:
- template: /eng/pipelines/variables/samples.yml@self
- name: publishEolAnnotations
value: false
readonly: true

resources:
repositories:
Expand Down
3 changes: 0 additions & 3 deletions eng/pipelines/dotnet-core-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ parameters:
variables:
- template: /eng/pipelines/variables/samples.yml@self
- template: /eng/docker-tools/templates/variables/dotnet/secrets.yml@self
- name: publishEolAnnotations
value: true
readonly: true

resources:
repositories:
Expand Down
10 changes: 5 additions & 5 deletions eng/pipelines/pipelines/update-dependencies-internal.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
parameters:
# Build ID of the .NET staging pipeline to fetch updates from. This can be a
# pipeline run of the real staging pipeline or the staging test pipeline, but
# the stagingStorageAccount parameter must match which pipeline is used here.
- name: buildId
# Stage container name (e.g., "stage-1234567") to fetch updates from. This can be
# from the real staging pipeline or the staging test pipeline, but the
# stagingStorageAccount parameter must match which pipeline is used here.
- name: stageContainer
type: string
default: ""
# Staging storage account for .NET release artifacts
Expand Down Expand Up @@ -42,7 +42,7 @@ extends:
inlineScript: >-
dotnet run --project eng/update-dependencies/update-dependencies.csproj --
from-staging-pipeline
${{ parameters.buildId }}
${{ parameters.stageContainer }}
--mode Remote
--azdo-organization "$(System.CollectionUri)"
--azdo-project "$(System.TeamProject)"
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/update-dependencies-internal-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resources:
extends:
template: /eng/pipelines/pipelines/update-dependencies-internal.yml@self
parameters:
buildId: "$(resources.pipeline.dotnet-staging-pipeline.runID)"
stageContainer: "stage-$(resources.pipeline.dotnet-staging-pipeline.runID)"
stagingStorageAccount: "dotnetstage"
targetBranch: "$(targetBranch)"
gitServiceConnectionName: "$(updateDepsInt.serviceConnectionName)"
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resources:
extends:
template: /eng/pipelines/pipelines/update-dependencies-internal.yml@self
parameters:
buildId: "$(resources.pipeline.dotnet-staging-pipeline.runID)"
stageContainer: "stage-$(resources.pipeline.dotnet-staging-pipeline.runID)"
stagingStorageAccount: "dotnetstage"
targetBranch: "${{ parameters.targetBranch }}"
gitServiceConnectionName: "$(updateDepsInt-test.serviceConnectionName)"
4 changes: 1 addition & 3 deletions eng/pipelines/update-dependencies-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ parameters:
- name: updateDotnet
displayName: Update .NET?
type: boolean
# Updates are disabled until .NET 11 Alpha images are added.
# Re-enable when https://github.com/dotnet/dotnet-docker/issues/6824 is resolved.
default: false
default: true
- name: updateAspire
displayName: Update Aspire Dashboard?
type: boolean
Expand Down
6 changes: 2 additions & 4 deletions eng/pipelines/variables/core-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ variables:
- name: officialBranchPrefixes
value: internal/release/

# Temporarily disabled due to https://github.com/dotnet/docker-tools/issues/1905
# Uncomment when the issue is resolved.
# - name: publishEolAnnotations
# value: true
# Set publishEolAnnotations to true or false in the Azure Pipelines UI to
# control EOL annotation publishing. The default should be true.
Loading