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

Added support for github actions upload v4 #1093

Merged
merged 1 commit into from
Feb 3, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 20 additions & 20 deletions .build/Build.CI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@
)]
[GitHubActionsSteps(
"ci",
GitHubActionsImage.UbuntuLatest,
GitHubActionsImage.MacOsLatest,
GitHubActionsImage.WindowsLatest,
GitHubActionsImage.UbuntuLatest,
AutoGenerate = false,
On = new[]
{
RocketSurgeonGitHubActionsTrigger.WorkflowCall,
RocketSurgeonGitHubActionsTrigger.WorkflowDispatch,
},
{
RocketSurgeonGitHubActionsTrigger.WorkflowCall,
RocketSurgeonGitHubActionsTrigger.WorkflowDispatch,
},
OnPushTags = new[] { "v*", },
OnPushBranches = new[] { "master", "main", "next", },
OnPullRequestBranches = new[] { "master", "main", "next", },
InvokedTargets = new[] { nameof(Default), },
NonEntryTargets = new[]
{
nameof(ICIEnvironment.CIEnvironment),
nameof(ITriggerCodeCoverageReports.TriggerCodeCoverageReports),
nameof(ITriggerCodeCoverageReports.GenerateCodeCoverageReportCobertura),
nameof(IGenerateCodeCoverageBadges.GenerateCodeCoverageBadges),
nameof(IGenerateCodeCoverageReport.GenerateCodeCoverageReport),
nameof(IGenerateCodeCoverageSummary.GenerateCodeCoverageSummary),
nameof(Default),
},
{
nameof(ICIEnvironment.CIEnvironment),
nameof(ITriggerCodeCoverageReports.TriggerCodeCoverageReports),
nameof(ITriggerCodeCoverageReports.GenerateCodeCoverageReportCobertura),
nameof(IGenerateCodeCoverageBadges.GenerateCodeCoverageBadges),
nameof(IGenerateCodeCoverageReport.GenerateCodeCoverageReport),
nameof(IGenerateCodeCoverageSummary.GenerateCodeCoverageSummary),
nameof(Default),
},
ExcludedTargets = new[] { nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore), },
Enhancements = new[] { nameof(CiMiddleware), }
)]
Expand Down Expand Up @@ -82,12 +82,12 @@ public partial class Pipeline
public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(RocketSurgeonGitHubActionsConfiguration configuration)
{
( (RocketSurgeonsGithubActionsJob)configuration.Jobs[0] ).Steps = new()
{
new RunStep("N/A")
{
Run = "echo \"No build required\"",
},
};
{
new RunStep("N/A")
{
Run = "echo \"No build required\"",
},
};

return configuration.IncludeRepositoryConfigurationFiles();
}
Expand Down
54 changes: 39 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
NUGET_PACKAGES: '${{ github.workspace }}/.nuget/packages'
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand Down Expand Up @@ -139,39 +139,63 @@ jobs:
id: pack
run: |
dotnet nuke Pack --skip --thisisaothervariable '${{ vars.THIS_IS_A_VARIABLE }}' --thisisanothervariable '${{ vars.THIS_IS_ANOTHER_VARIABLE }}' --this_is_a_variable '${{ vars.THIS_IS_A_VARIABLE }}' --thisisaenv '${{ env.THIS_IS_A_ENV || 'test' }}' --thisisasecret '${{ secrets.THIS_IS_A_SECRET }}' --githubtoken '${{ secrets.GITHUB_TOKEN }}'
- name: 🏺 coverage (${{ matrix.os }})
if: matrix.os != 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: '${{ matrix.os }}-coverage'
path: 'coverage/'
- name: 🏺 Publish coverage data
if: always()
uses: actions/upload-artifact@v3.1.3
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: 'coverage'
name: '${{ matrix.os }}-coverage'
path: 'coverage/'
- name: 🐿 Publish Coverage
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]')
uses: codecov/codecov-action@v3.1.6
uses: codecov/codecov-action@v3
with:
name: 'actions-${{ matrix.os }}'
- name: 🏺 logs (${{ matrix.os }})
if: matrix.os != 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: '${{ matrix.os }}-logs'
path: 'artifacts/logs/'
- name: 🏺 Publish logs
if: always()
uses: actions/upload-artifact@v3.1.3
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: 'logs'
name: '${{ matrix.os }}-logs'
path: 'artifacts/logs/'
- name: 🏺 test data (${{ matrix.os }})
if: matrix.os != 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: '${{ matrix.os }}-test data'
path: 'artifacts/test/'
- name: 🏺 Publish test data
if: always()
uses: actions/upload-artifact@v3.1.3
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: 'test data'
name: '${{ matrix.os }}-test data'
path: 'artifacts/test/'
- name: 🏺 nuget (${{ matrix.os }})
if: matrix.os != 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: '${{ matrix.os }}-nuget'
path: 'artifacts/nuget/'
- name: 🏺 Publish NuGet Packages
if: always()
uses: actions/upload-artifact@v3.1.3
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: 'nuget'
name: '${{ matrix.os }}-nuget'
path: 'artifacts/nuget/'
Publish:
needs:
- Build
uses: RocketSurgeonsGuild/actions/.github/workflows/publish-nuget.yml@v0.3.5
uses: RocketSurgeonsGuild/actions/.github/workflows/publish-nuget.yml@v0.3.0
secrets:
RSG_NUGET_API_KEY: '${{ secrets.RSG_NUGET_API_KEY }}'
RSG_AZURE_DEVOPS: '${{ secrets.RSG_AZURE_DEVOPS }}'
28 changes: 16 additions & 12 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<ItemGroup>
<PackageReference
<ItemGroup>
<PackageReference
Include="Microsoft.NETFramework.ReferenceAssemblies"
IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive"
PrivateAssets="All"
/>
<PackageReference Include="Microsoft.SourceLink.GitHub" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Rocket.Surgery.MSBuild.CI" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Rocket.Surgery.MSBuild.GitVersion" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference
<PackageReference Include="Microsoft.SourceLink.GitHub" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Rocket.Surgery.MSBuild.CI" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Rocket.Surgery.MSBuild.GitVersion" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference
Include="Rocket.Surgery.MSBuild.JetBrains.Annotations"
IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive"
PrivateAssets="All"
Condition="'$(MSBuildProjectName)'!='.build'"
/>
<!-- <PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" /> -->
<PackageReference Include="Rocket.Surgery.MSBuild.SourceLink" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Roslynator.Analyzers" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Roslynator.Formatting.Analyzers" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
</ItemGroup>
<PackageReference Include="Rocket.Surgery.MSBuild.SourceLink" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Polyfill" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<!--
<PackageReference Include="Roslynator.Analyzers" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Roslynator.Formatting.Analyzers" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Roslynator.CodeFixes" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
<PackageReference Include="Roslynator.Refactorings" IncludeAssets="analyzers;build;buildMultitargeting;buildTransitive" PrivateAssets="All" />
-->
</ItemGroup>
</Project>
15 changes: 7 additions & 8 deletions src/Nuke/EnsurePackageSourceHasCredentialsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,19 @@
/// <inheritdoc />
public void OnBuildCreated(IReadOnlyCollection<ExecutableTarget> executableTargets)
{
var settings = Settings.LoadDefaultSettings(NukeBuild.RootDirectory);
var settings = NuGet.Configuration.Settings.LoadDefaultSettings(NukeBuild.RootDirectory);

Check warning on line 35 in src/Nuke/EnsurePackageSourceHasCredentialsAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/EnsurePackageSourceHasCredentialsAttribute.cs#L35

Added line #L35 was not covered by tests
var packageSourceProvider = new PackageSourceProvider(settings);

var source = packageSourceProvider.LoadPackageSources()
.FirstOrDefault(
x => x.Name.Equals(SourceName, StringComparison.OrdinalIgnoreCase)
);
var source = packageSourceProvider
.LoadPackageSources()
.FirstOrDefault(x => x.Name.Equals(SourceName, StringComparison.OrdinalIgnoreCase));

Check warning on line 40 in src/Nuke/EnsurePackageSourceHasCredentialsAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/EnsurePackageSourceHasCredentialsAttribute.cs#L38-L40

Added lines #L38 - L40 were not covered by tests
if (source == null)
{
Log.Error(
"NuGet Package Source {SourceName} could not be found. This is required for the build to complete",
SourceName
);
throw new Exception();
throw new();

Check warning on line 47 in src/Nuke/EnsurePackageSourceHasCredentialsAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/EnsurePackageSourceHasCredentialsAttribute.cs#L47

Added line #L47 was not covered by tests
}

if (source.Credentials?.IsValid() != true)
Expand All @@ -54,7 +53,7 @@
"NuGet Package Source {SourceName} does not have any credentials defined. Please configure the credentials for the source to build",
SourceName
);
throw new Exception();
throw new();

Check warning on line 56 in src/Nuke/EnsurePackageSourceHasCredentialsAttribute.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/EnsurePackageSourceHasCredentialsAttribute.cs#L56

Added line #L56 was not covered by tests
}
}
}
}
34 changes: 32 additions & 2 deletions src/Nuke/GithubActions/DownloadArtifactSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Rocket.Surgery.Nuke.GithubActions;
/// <summary>
/// Download a given artifact
/// </summary>
[PublicAPI]
public class DownloadArtifactSet : UsingStep
{
/// <summary>
Expand All @@ -15,15 +16,44 @@ public DownloadArtifactSet(string name) : base(name)
}

/// <summary>
/// The artifact name to download
/// Gets or sets the name of the artifact to download. If unspecified, all artifacts for the run are downloaded.
/// </summary>
public string? Name { get; set; }

/// <summary>
/// The path of the artifact to download
/// Gets or sets the destination path. Supports basic tilde expansion. Optional. Default is $GITHUB_WORKSPACE.
/// </summary>
public string? Path { get; set; }

/// <summary>
/// Gets or sets a glob pattern to the artifacts that should be downloaded. Ignored if name is specified.
/// </summary>
public string? Pattern { get; set; }

/// <summary>
/// Gets or sets a value indicating whether multiple artifacts are merged. If true, the downloaded artifacts will be in the same directory specified by path.
/// If false, the downloaded artifacts will be extracted into individual named directories within the specified path. Optional. Default is 'false'.
/// </summary>
public bool? MergeMultiple { get; set; }

/// <summary>
/// Gets or sets the GitHub token used to authenticate with the GitHub API. This is required when downloading artifacts from a different repository or from a
/// different workflow run.
/// </summary>
public string? GithubToken { get; set; }

/// <summary>
/// Gets or sets the repository owner and the repository name joined together by "/". If github-token is specified, this is the repository that artifacts will
/// be downloaded from.
/// </summary>
public string? Repository { get; set; }

/// <summary>
/// Gets or sets the id of the workflow run where the desired download artifact was uploaded from. If github-token is specified, this is the run that artifacts
/// will be downloaded from.
/// </summary>
public string? RunId { get; set; }

/// <inheritdoc />
public override void Write(CustomFileWriter writer)
{
Expand Down