Skip to content

Commit

Permalink
Updated the default versions for the github actions to the latest (#1022
Browse files Browse the repository at this point in the history
)
  • Loading branch information
david-driscoll authored Nov 30, 2023
1 parent b755bba commit f14d81a
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 115 deletions.
8 changes: 4 additions & 4 deletions src/Nuke/GithubActions/CheckoutStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CheckoutStep : UsingStep
/// <param name="name"></param>
public CheckoutStep(string name) : base(name)
{
Uses = "actions/checkout@v2";
Uses = "actions/checkout@v4";
}

/// <summary>
Expand Down Expand Up @@ -121,9 +121,9 @@ public CheckoutStep(string name) : base(name)
/// <inheritdoc />
public override void Write(CustomFileWriter writer)
{
#pragma warning disable CA1308
#pragma warning disable CA1308
WithProperties(x => x.Underscore().Hyphenate().ToLowerInvariant());
#pragma warning restore CA1308
#pragma warning restore CA1308
base.Write(writer);
}
}
}
8 changes: 4 additions & 4 deletions src/Nuke/GithubActions/DownloadArtifactSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class DownloadArtifactSet : UsingStep
/// <param name="name"></param>
public DownloadArtifactSet(string name) : base(name)
{
Uses = "actions/download-artifact@v1";
Uses = "actions/download-artifact@v3";
}

/// <summary>
Expand All @@ -27,9 +27,9 @@ public DownloadArtifactSet(string name) : base(name)
/// <inheritdoc />
public override void Write(CustomFileWriter writer)
{
#pragma warning disable CA1308
#pragma warning disable CA1308
WithProperties(x => x.Underscore().Camelize().ToLowerInvariant());
#pragma warning restore CA1308
#pragma warning restore CA1308
base.Write(writer);
}

Expand All @@ -38,4 +38,4 @@ protected override string ComputeStepName(string name)
{
return $"🚀 {name}";
}
}
}
143 changes: 73 additions & 70 deletions src/Nuke/GithubActions/GithubActionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,58 +20,39 @@ public static class GithubActionsExtensions
/// <returns></returns>
public static RocketSurgeonGitHubActionsConfiguration AddNugetPublish(this RocketSurgeonGitHubActionsConfiguration configuration)
{
configuration.DetailedTriggers.OfType<RocketSurgeonGitHubActionsWorkflowTrigger>().ForEach(
trigger =>
{
trigger.Secrets.Add(new GitHubActionsSecret("RSG_NUGET_API_KEY"));
trigger.Secrets.Add(new GitHubActionsSecret("RSG_AZURE_DEVOPS"));
}
);
configuration
.DetailedTriggers.OfType<RocketSurgeonGitHubActionsWorkflowTrigger>()
.ForEach(
trigger =>
{
trigger.Secrets.Add(new("RSG_NUGET_API_KEY"));
trigger.Secrets.Add(new("RSG_AZURE_DEVOPS"));
}
);
configuration.Jobs.Add(
new RocketSurgeonsGithubWorkflowJob("Publish")
{
Needs = { "Build" },
Needs = { "Build", },
Uses = "RocketSurgeonsGuild/actions/.github/workflows/publish-nuget.yml@v0.3.0",
Secrets = new Dictionary<string, string>
{
["RSG_NUGET_API_KEY"] = "${{ secrets.RSG_NUGET_API_KEY }}",
["RSG_AZURE_DEVOPS"] = "${{ secrets.RSG_AZURE_DEVOPS }}",
}
Secrets = new()
{
["RSG_NUGET_API_KEY"] = "${{ secrets.RSG_NUGET_API_KEY }}",
["RSG_AZURE_DEVOPS"] = "${{ secrets.RSG_AZURE_DEVOPS }}",
},
}
);
return configuration;
}

private static readonly string[] _pathsIgnore =
{
".codecov.yml",
".editorconfig",
".gitattributes",
".gitignore",
".gitmodules",
".lintstagedrc.js",
".prettierignore",
".prettierrc",
"LICENSE",
"nukeeper.settings.json",
"omnisharp.json",
"package-lock.json",
"package.json",
"Readme.md",
".github/dependabot.yml",
".github/labels.yml",
".github/release.yml",
".github/renovate.json",
};

/// <summary>
/// Adds a new step to the current configuration
/// </summary>
/// <param name="configuration"></param>
/// <param name="job"></param>
/// <returns></returns>
public static RocketSurgeonGitHubActionsConfiguration AddJob(
this RocketSurgeonGitHubActionsConfiguration configuration, RocketSurgeonsGithubActionsJobBase job
this RocketSurgeonGitHubActionsConfiguration configuration,
RocketSurgeonsGithubActionsJobBase job
)
{
configuration.Jobs.Add(job);
Expand Down Expand Up @@ -171,15 +152,15 @@ public static RocketSurgeonsGithubActionsJob AddNuGetCache(this RocketSurgeonsGi
job.InsertAfterCheckOut(
new UsingStep("NuGet Cache")
{
Uses = "actions/cache@v2",
Uses = "actions/cache@v3",
With =
{
["path"] = "${{ github.workspace }}/.nuget/packages",
// keep in mind using central package versioning here
["key"] = "${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}",
["restore-keys"] = @"|
${{ runner.os }}-nuget-"
}
${{ runner.os }}-nuget-",
},
}
);
return job;
Expand All @@ -192,7 +173,7 @@ public static RocketSurgeonsGithubActionsJob AddNuGetCache(this RocketSurgeonsGi
/// <returns></returns>
public static RocketSurgeonsGithubActionsJob ConfigureForGitVersion(this RocketSurgeonsGithubActionsJob job)
{
job.InsertAfterCheckOut(new RunStep("Fetch all history for all tags and branches") { Run = "git fetch --prune" });
job.InsertAfterCheckOut(new RunStep("Fetch all history for all tags and branches") { Run = "git fetch --prune", });
return job;
}

Expand All @@ -213,7 +194,7 @@ public static RocketSurgeonsGithubActionsJob PublishArtifacts<T>(this RocketSurg
{
Name = "nuget",
Path = "artifacts/nuget/",
If = "always()"
If = "always()",
}
);
job.InternalData[typeof(IHaveNuGetPackages)] = true;
Expand Down Expand Up @@ -251,7 +232,7 @@ public static RocketSurgeonsGithubActionsJob PublishLogs<T>(this RocketSurgeonsG
{
Name = "coverage",
Path = "coverage/",
If = "always()"
If = "always()",
}
);

Expand All @@ -261,10 +242,10 @@ public static RocketSurgeonsGithubActionsJob PublishLogs<T>(this RocketSurgeonsG
job,
new UsingStep("Publish Coverage")
{
Uses = "codecov/codecov-action@v1",
Uses = "codecov/codecov-action@v3",
If =
"(github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || ((github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.user.login != 'renovate[bot]' && github.event.pull_request.user.login != 'dependabot[bot]')",
With = new() { ["name"] = "actions-${{ matrix.os }}" }
With = new() { ["name"] = "actions-${{ matrix.os }}", },
}
);
}
Expand All @@ -278,7 +259,7 @@ public static RocketSurgeonsGithubActionsJob PublishLogs<T>(this RocketSurgeonsG
{
Name = "logs",
Path = "artifacts/logs/",
If = "always()"
If = "always()",
}
);
}
Expand All @@ -291,7 +272,7 @@ public static RocketSurgeonsGithubActionsJob PublishLogs<T>(this RocketSurgeonsG
{
Name = "test data",
Path = "artifacts/test/",
If = "always()"
If = "always()",
}
);
}
Expand Down Expand Up @@ -345,31 +326,10 @@ public static RocketSurgeonsGithubActionsJob UseDotNetSdks(this RocketSurgeonsGi
public static RocketSurgeonsGithubActionsJob UseDotNetSdk(this RocketSurgeonsGithubActionsJob job, string version, string? exactVersion = null)
{
exactVersion ??= version + ".x";
job.InsertAfterCheckOut(new SetupDotNetStep($"Use .NET Core {version} SDK") { DotNetVersion = exactVersion });
job.InsertAfterCheckOut(new SetupDotNetStep($"Use .NET Core {version} SDK") { DotNetVersion = exactVersion, });
return job;
}

private static readonly ConcurrentDictionary<ITargetDefinition, List<GitHubActionsOutput>> outputPaths = new();

// ReSharper disable once NullableWarningSuppressionIsUsed
private static readonly PropertyInfo DefinitionProperty =
typeof(ExecutableTarget).GetProperty("Definition", BindingFlags.Instance | BindingFlags.NonPublic)!;


internal static List<GitHubActionsOutput> GetGithubActionsOutput(ExecutableTarget target)
{
// ReSharper disable once NullableWarningSuppressionIsUsed
var def = (ITargetDefinition)DefinitionProperty.GetValue(target)!;
if (outputPaths.TryGetValue(def, out var paths))
{
return paths;
}

paths = new();
outputPaths[def] = paths;
return paths;
}

/// <summary>
/// Set an output for github actions
/// </summary>
Expand Down Expand Up @@ -399,7 +359,50 @@ public static ITargetDefinition ProducesGithubActionsOutput(this ITargetDefiniti
outputPaths[target] = paths;
}

paths.Add(new GitHubActionsOutput(outputName, description));
paths.Add(new(outputName, description));
return target;
}
}


internal static List<GitHubActionsOutput> GetGithubActionsOutput(ExecutableTarget target)
{
// ReSharper disable once NullableWarningSuppressionIsUsed
var def = (ITargetDefinition)DefinitionProperty.GetValue(target)!;
if (outputPaths.TryGetValue(def, out var paths))
{
return paths;
}

paths = new();
outputPaths[def] = paths;
return paths;
}

private static readonly string[] _pathsIgnore =
{
".codecov.yml",
".editorconfig",
".gitattributes",
".gitignore",
".gitmodules",
".lintstagedrc.js",
".prettierignore",
".prettierrc",
"LICENSE",
"nukeeper.settings.json",
"omnisharp.json",
"package-lock.json",
"package.json",
"Readme.md",
".github/dependabot.yml",
".github/labels.yml",
".github/release.yml",
".github/renovate.json",
};

private static readonly ConcurrentDictionary<ITargetDefinition, List<GitHubActionsOutput>> outputPaths = new();

// ReSharper disable once NullableWarningSuppressionIsUsed
private static readonly PropertyInfo DefinitionProperty =
typeof(ExecutableTarget).GetProperty("Definition", BindingFlags.Instance | BindingFlags.NonPublic)!;
}
4 changes: 2 additions & 2 deletions src/Nuke/GithubActions/SetupDotNetStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class SetupDotNetStep : UsingStep
public SetupDotNetStep(string name) : base(name)
{
// temporary to deal with sxs issue roll back once https://github.com/actions/setup-dotnet/pull/71 is merged
Uses = "actions/setup-dotnet@v1";
Uses = "actions/setup-dotnet@v3";
}

/// <summary>SDK version to use. Example: 2.2.104</summary>
Expand Down Expand Up @@ -76,4 +76,4 @@ public override void Write(CustomFileWriter writer)

base.Write(writer);
}
}
}
8 changes: 4 additions & 4 deletions src/Nuke/GithubActions/UploadArtifactStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class UploadArtifactStep : UsingStep
/// <param name="name"></param>
public UploadArtifactStep(string name) : base(name)
{
Uses = "actions/upload-artifact@v2";
Uses = "actions/upload-artifact@v3";
}

/// <summary>
Expand All @@ -27,9 +27,9 @@ public UploadArtifactStep(string name) : base(name)
/// <inheritdoc />
public override void Write(CustomFileWriter writer)
{
#pragma warning disable CA1308
#pragma warning disable CA1308
WithProperties(x => x.Underscore().Camelize().ToLowerInvariant());
#pragma warning restore CA1308
#pragma warning restore CA1308
base.Write(writer);
}

Expand All @@ -38,4 +38,4 @@ protected override string ComputeStepName(string name)
{
return $"🏺 {name}";
}
}
}
59 changes: 28 additions & 31 deletions src/Nuke/ICanRegenerateBuildConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,32 @@ public interface ICanRegenerateBuildConfiguration : ICanLint
/// <summary>
/// Regenerate the build configurations
/// </summary>
public Target RegenerateBuildConfigurations => t =>
t
.TryDependentFor<ICanLintStagedFiles>(static z => z.LintStaged)
.TryTriggeredBy<ICanLint>(static z => z.Lint)
// We run during LintStaged, no need to run again during the lint that lint-staged kicks off.
.OnlyWhenDynamic(() => !EnvironmentInfo.HasVariable("RSG_NUKE_LINT_STAGED"))
.Unlisted()
.Executes(
() =>
{
var allHosts = GetType()
.GetCustomAttributes<ConfigurationAttributeBase>()
.OfType<IConfigurationGenerator>();
public Target RegenerateBuildConfigurations =>
t => t
.TryDependentFor<ICanLintStagedFiles>(static z => z.LintStaged)
.TryTriggeredBy<ICanLint>(static z => z.Lint)
// We run during LintStaged, no need to run again during the lint that lint-staged kicks off.
.OnlyWhenDynamic(() => !EnvironmentInfo.HasVariable("RSG_NUKE_LINT_STAGED"))
.Unlisted()
.Executes(
() =>
{
var allHosts = GetType()
.GetCustomAttributes<ConfigurationAttributeBase>()
.OfType<IConfigurationGenerator>();

allHosts
// ReSharper disable once NullableWarningSuppressionIsUsed
.Select(
z =>
$"""{Assembly.GetEntryAssembly()!.Location} --{BuildServerConfigurationGeneration.ConfigurationParameterName} {z.Id} --host {z.HostName}"""
)
.ForEach(
command => DotNetTasks.DotNet(
command,
environmentVariables: EnvironmentInfo.Variables.AddIfMissing(
"NUKE_INTERNAL_INTERCEPTOR",
"1"
)
)
);
}
);
}
allHosts
.Select(
z =>
// ReSharper disable once NullableWarningSuppressionIsUsed
$"""{Assembly.GetEntryAssembly()!.Location} --{BuildServerConfigurationGeneration.ConfigurationParameterName} {z.Id} --host {z.HostName}"""
)
.ForEach(
command => DotNetTasks.DotNet(
command,
environmentVariables: EnvironmentInfo.Variables.AddIfMissing("NUKE_INTERNAL_INTERCEPTOR", "1")
)
);
}
);
}

0 comments on commit f14d81a

Please sign in to comment.