From 32d8c0773fc6a7326f503a7aa3e3ddbc3bbf1739 Mon Sep 17 00:00:00 2001 From: maximstorms Date: Tue, 3 Dec 2024 10:28:47 +0100 Subject: [PATCH 1/2] Update nuget packages --- NuGet.config | 4 -- azure-pipelines.Dependabot.yml | 23 ----------- azure-pipelines.PR.yml | 41 ------------------- azure-pipelines.Publish.yml | 39 ------------------ build/_build.csproj | 2 +- build/_build.csproj.DotSettings | 5 ++- ...RMDY.Components.MvvmCross.UnitTests.csproj | 12 +++--- .../dotRMDY.Components.MvvmCross.csproj | 4 +- .../dotRMDY.Components.UnitTests.csproj | 12 +++--- .../dotRMDY.Components.csproj | 2 +- 10 files changed, 18 insertions(+), 126 deletions(-) delete mode 100644 azure-pipelines.Dependabot.yml delete mode 100644 azure-pipelines.PR.yml delete mode 100644 azure-pipelines.Publish.yml diff --git a/NuGet.config b/NuGet.config index 924efc7..5f5b4be 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,15 +3,11 @@ - - - - \ No newline at end of file diff --git a/azure-pipelines.Dependabot.yml b/azure-pipelines.Dependabot.yml deleted file mode 100644 index c3d381c..0000000 --- a/azure-pipelines.Dependabot.yml +++ /dev/null @@ -1,23 +0,0 @@ -trigger: none # Disable CI trigger - -schedules: - - cron: '0 2 * * *' # daily at 2am UTC - always: true # run even when there are no code changes - branches: - include: - - main - batch: true - displayName: Daily - -pool: - vmImage: 'ubuntu-latest' # requires macos or ubuntu (windows is not supported) - -steps: - - task: dependabot@1 - inputs: - useConfigFile: true - azureDevOpsAccessToken: '$(System.AccessToken)' - gitHubConnection: 'GitHub Service Connection' - dockerImageTag: '1.24' - env: - RMDY_AZURE_ARTIFACTS_TOKEN: $(System.AccessToken) \ No newline at end of file diff --git a/azure-pipelines.PR.yml b/azure-pipelines.PR.yml deleted file mode 100644 index f377c8a..0000000 --- a/azure-pipelines.PR.yml +++ /dev/null @@ -1,41 +0,0 @@ -# ------------------------------------------------------------------------------ -# -# -# This code was generated. -# -# - To turn off auto-generation set: -# -# [AzurePipelines (AutoGenerate = false)] -# -# - To trigger manual generation invoke: -# -# nuke --generate-configuration AzurePipelines_PR --host AzurePipelines -# -# -# ------------------------------------------------------------------------------ - -trigger: - none - -stages: - - stage: ubuntu_latest - displayName: 'ubuntu-latest' - dependsOn: [ ] - pool: - vmImage: 'ubuntu-latest' - jobs: - - job: Pack - displayName: 'Pack' - steps: - - task: NuGetAuthenticate@1 - - checkout: self - fetchDepth: 0 - - task: CmdLine@2 - displayName: 'Run: Pack' - inputs: - script: './build.cmd Pack' - - task: PublishBuildArtifacts@1 - displayName: 'Publish: artifacts' - inputs: - artifactName: artifacts - pathToPublish: 'artifacts' \ No newline at end of file diff --git a/azure-pipelines.Publish.yml b/azure-pipelines.Publish.yml deleted file mode 100644 index f073a92..0000000 --- a/azure-pipelines.Publish.yml +++ /dev/null @@ -1,39 +0,0 @@ -# ------------------------------------------------------------------------------ -# -# -# This code was generated. -# -# - To turn off auto-generation set: -# -# [AzurePipelines (AutoGenerate = false)] -# -# - To trigger manual generation invoke: -# -# nuke --generate-configuration AzurePipelines_Publish --host AzurePipelines -# -# -# ------------------------------------------------------------------------------ - -trigger: - batch: true - tags: - include: - - '*.*.*' - -stages: - - stage: ubuntu_latest - displayName: 'ubuntu-latest' - dependsOn: [ ] - pool: - vmImage: 'ubuntu-latest' - jobs: - - job: Publish - displayName: 'Publish' - steps: - - task: NuGetAuthenticate@1 - - checkout: self - fetchDepth: 0 - - task: CmdLine@2 - displayName: 'Run: Publish' - inputs: - script: './build.cmd Publish' \ No newline at end of file diff --git a/build/_build.csproj b/build/_build.csproj index 476e0fc..06df722 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -11,7 +11,7 @@ - + diff --git a/build/_build.csproj.DotSettings b/build/_build.csproj.DotSettings index eb3f4c2..88a8824 100644 --- a/build/_build.csproj.DotSettings +++ b/build/_build.csproj.DotSettings @@ -17,6 +17,8 @@ False <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /></Policy> True True True @@ -25,4 +27,5 @@ True True True - True + True + True diff --git a/source/dotRMDY.Components.MvvmCross.UnitTests/dotRMDY.Components.MvvmCross.UnitTests.csproj b/source/dotRMDY.Components.MvvmCross.UnitTests/dotRMDY.Components.MvvmCross.UnitTests.csproj index 8116658..7648080 100644 --- a/source/dotRMDY.Components.MvvmCross.UnitTests/dotRMDY.Components.MvvmCross.UnitTests.csproj +++ b/source/dotRMDY.Components.MvvmCross.UnitTests/dotRMDY.Components.MvvmCross.UnitTests.csproj @@ -9,13 +9,11 @@ - - - - - - - + + + + + diff --git a/source/dotRMDY.Components.MvvmCross/dotRMDY.Components.MvvmCross.csproj b/source/dotRMDY.Components.MvvmCross/dotRMDY.Components.MvvmCross.csproj index a83d977..75702e9 100644 --- a/source/dotRMDY.Components.MvvmCross/dotRMDY.Components.MvvmCross.csproj +++ b/source/dotRMDY.Components.MvvmCross/dotRMDY.Components.MvvmCross.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/source/dotRMDY.Components.UnitTests/dotRMDY.Components.UnitTests.csproj b/source/dotRMDY.Components.UnitTests/dotRMDY.Components.UnitTests.csproj index 1d21f83..2e12cc5 100644 --- a/source/dotRMDY.Components.UnitTests/dotRMDY.Components.UnitTests.csproj +++ b/source/dotRMDY.Components.UnitTests/dotRMDY.Components.UnitTests.csproj @@ -9,13 +9,11 @@ - - - - - - - + + + + + diff --git a/source/dotRMDY.Components/dotRMDY.Components.csproj b/source/dotRMDY.Components/dotRMDY.Components.csproj index 47cf4e0..8e264ae 100644 --- a/source/dotRMDY.Components/dotRMDY.Components.csproj +++ b/source/dotRMDY.Components/dotRMDY.Components.csproj @@ -11,7 +11,7 @@ - + \ No newline at end of file From c0db6a664de4fffd01ca906b020625b12b4c1ca0 Mon Sep 17 00:00:00 2001 From: maximstorms Date: Tue, 3 Dec 2024 10:53:09 +0100 Subject: [PATCH 2/2] Update nuke build script to work with GitHub Actions --- .github/workflows/pr.yml | 35 ++++++++++++++++ .github/workflows/publish.yml | 40 ++++++++++++++++++ build/Build.CI.AzurePipelines.cs | 49 ---------------------- build/Build.CI.GithubActions.cs | 20 +++++++++ build/Build.Feeds.DotRmdyAzureArtifacts.cs | 37 ---------------- build/Build.Feeds.NugetDotOrg.cs | 38 +++++++++++++++++ build/Build.cs | 7 +--- build/_build.csproj | 2 +- 8 files changed, 135 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/pr.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 build/Build.CI.AzurePipelines.cs create mode 100644 build/Build.CI.GithubActions.cs delete mode 100644 build/Build.Feeds.DotRmdyAzureArtifacts.cs create mode 100644 build/Build.Feeds.NugetDotOrg.cs diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..e4fe219 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,35 @@ +# ------------------------------------------------------------------------------ +# +# +# This code was generated. +# +# - To turn off auto-generation set: +# +# [GitHubActions (AutoGenerate = false)] +# +# - To trigger manual generation invoke: +# +# nuke --generate-configuration GitHubActions_pr --host GitHubActions +# +# +# ------------------------------------------------------------------------------ + +name: pr + +on: [pull_request] + +jobs: + ubuntu-latest: + name: ubuntu-latest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: 'Run: Pack' + run: ./build.cmd Pack + - name: 'Publish: artifacts' + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: artifacts diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ab4b8cc --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,40 @@ +# ------------------------------------------------------------------------------ +# +# +# This code was generated. +# +# - To turn off auto-generation set: +# +# [GitHubActions (AutoGenerate = false)] +# +# - To trigger manual generation invoke: +# +# nuke --generate-configuration GitHubActions_publish --host GitHubActions +# +# +# ------------------------------------------------------------------------------ + +name: publish + +on: + push: + tags: + - '*.*.*' + +jobs: + ubuntu-latest: + name: ubuntu-latest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: 'Run: Publish' + run: ./build.cmd Publish + env: + NugetApiKey: ${{ secrets.NUGET_API_KEY }} + - name: 'Publish: artifacts' + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: artifacts diff --git a/build/Build.CI.AzurePipelines.cs b/build/Build.CI.AzurePipelines.cs deleted file mode 100644 index d764afb..0000000 --- a/build/Build.CI.AzurePipelines.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Linq; -using Nuke.Common; -using Nuke.Common.CI; -using Nuke.Common.CI.AzurePipelines; -using Nuke.Common.IO; - -[AzurePipelines( - suffix: "PR", - AzurePipelinesImage.UbuntuLatest, - AutoGenerate = false, - FetchDepth = 0, - TriggerDisabled = true, - InvokedTargets = new[] { nameof(Pack) }, - CacheKeyFiles = new string[0], - CachePaths = new string[0])] -[AzurePipelines( - suffix: "Publish", - AzurePipelinesImage.UbuntuLatest, - AutoGenerate = false, - FetchDepth = 0, - TriggerBatch = true, - TriggerTagsInclude = new[] { "'*.*.*'" }, - InvokedTargets = new[] { nameof(Publish) }, - CacheKeyFiles = new string[0], - CachePaths = new string[0])] -partial class Build -{ - [CI] readonly AzurePipelines AzurePipelines; - - Target PublishTestAndCoverageResultsToAzurePipelines => _ => _ - .TriggeredBy(RunTests) - .OnlyWhenStatic(() => Host is AzurePipelines) - .Executes(() => - { - AzurePipelines?.PublishTestResults( - "Unit test results", - AzurePipelinesTestResultsType.VSTest, - Solution - .GetAllProjects("*.UnitTests") - .SelectMany(x => Globbing.GlobFiles(x.Directory.ToString(), "**/*.trx")), - true, - configuration: Configuration); - - AzurePipelines?.PublishCodeCoverage( - AzurePipelinesCodeCoverageToolType.Cobertura, - CoverageResultsReportDirectory / "Cobertura.xml", - CoverageResultsReportDirectory); - }); -} \ No newline at end of file diff --git a/build/Build.CI.GithubActions.cs b/build/Build.CI.GithubActions.cs new file mode 100644 index 0000000..974d4c4 --- /dev/null +++ b/build/Build.CI.GithubActions.cs @@ -0,0 +1,20 @@ +using Nuke.Common.CI.GitHubActions; + +[GitHubActions( + "pr", + GitHubActionsImage.UbuntuLatest, + On = [GitHubActionsTrigger.PullRequest], + InvokedTargets = [nameof(Pack)], + AutoGenerate = false, + FetchDepth = 0, + CacheKeyFiles = [])] +[GitHubActions( + "publish", + GitHubActionsImage.UbuntuLatest, + InvokedTargets = [nameof(Publish)], + AutoGenerate = false, + FetchDepth = 0, + CacheKeyFiles = [], + OnPushTags = ["'*.*.*'"], + ImportSecrets = [nameof(NugetApiKey)])] +partial class Build; \ No newline at end of file diff --git a/build/Build.Feeds.DotRmdyAzureArtifacts.cs b/build/Build.Feeds.DotRmdyAzureArtifacts.cs deleted file mode 100644 index 68169a2..0000000 --- a/build/Build.Feeds.DotRmdyAzureArtifacts.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections.Generic; -using Nuke.Common; -using Nuke.Common.IO; -using Nuke.Common.Tooling; -using Nuke.Common.Tools.DotNet; -using static Nuke.Common.Tools.DotNet.DotNetTasks; - -partial class Build -{ - const string RMDY_AZURE_ARTIFACTS_FEED_NAME = "RMDY-AzureArtifacts"; - - [Secret, Parameter] - readonly string DotRmdyAzureArtifactsToken; - - Target UpdateDotRmdyAzureArtifactsFeedCredentials => _ => _ - .OnlyWhenStatic(() => IsServerBuild && Host is not Nuke.Common.CI.AzurePipelines.AzurePipelines) - .Requires(() => !string.IsNullOrEmpty(DotRmdyAzureArtifactsToken)) - .Executes(() => - { - DotNet($"nuget update source {RMDY_AZURE_ARTIFACTS_FEED_NAME} --username az --password {DotRmdyAzureArtifactsToken} --store-password-in-clear-text"); - }); - - Target PublishToDotRmdyAzureArtifacts => _ => _ - .DependsOn(Pack) - .Executes(() => - { - IEnumerable artifactPackages = ArtifactsDirectory.GlobFiles("*.nupkg"); - - DotNetNuGetPush(s => s - .SetSource(RMDY_AZURE_ARTIFACTS_FEED_NAME) - // ReSharper disable once UnencryptedSecretHighlighting - .SetApiKey("az") // API key is ignored due to the usage of a PAT, but still has to be filled in. - .EnableSkipDuplicate() - .CombineWith(artifactPackages, (_, v) => _ - .SetTargetPath(v))); - }); -} \ No newline at end of file diff --git a/build/Build.Feeds.NugetDotOrg.cs b/build/Build.Feeds.NugetDotOrg.cs new file mode 100644 index 0000000..9583512 --- /dev/null +++ b/build/Build.Feeds.NugetDotOrg.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using Nuke.Common; +using Nuke.Common.CI.AzurePipelines; +using Nuke.Common.IO; +using Nuke.Common.Tooling; +using Nuke.Common.Tools.DotNet; +using Nuke.Common.Utilities.Collections; +using Serilog; +using static Nuke.Common.Tools.DotNet.DotNetTasks; + +partial class Build +{ + [Secret, Parameter] string NugetApiKey; + [Parameter] string NugetSource = "https://api.nuget.org/v3/index.json"; + + Target PublishToNugetOrg => _ => _ + .DependsOn(Pack) + .Requires(() => NugetSource) + .Requires(() => NugetApiKey) + .Executes(() => + { + IEnumerable artifactPackages = ArtifactsDirectory.GlobFiles("*.nupkg"); + if (artifactPackages.IsNullOrEmpty()) + { + Log.Warning("No packages found to push to NuGet.org"); + return; + } + + artifactPackages.ForEach(x => + { + Log.Information("Pushing {Path} to NuGet.org", x); + DotNetNuGetPush(s => s + .SetSource(NugetSource) + .SetApiKey(NugetApiKey) + .SetTargetPath(x)); + }); + }); +} \ No newline at end of file diff --git a/build/Build.cs b/build/Build.cs index 618bff5..1d31f50 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -50,7 +50,6 @@ partial class Build : NukeBuild }); Target Restore => _ => _ - .DependsOn(UpdateFeedCredentials) .Executes(() => { DotNetRestore(s => s @@ -59,10 +58,6 @@ partial class Build : NukeBuild .EnableContinuousIntegrationBuild()); }); - Target UpdateFeedCredentials => _ => _ - .Unlisted() - .DependsOn(UpdateDotRmdyAzureArtifactsFeedCredentials); - Target Compile => _ => _ .DependsOn(Restore) .Executes(() => @@ -118,5 +113,5 @@ partial class Build : NukeBuild }); Target Publish => _ => _ - .DependsOn(PublishToDotRmdyAzureArtifacts); + .DependsOn(PublishToNugetOrg); } \ No newline at end of file diff --git a/build/_build.csproj b/build/_build.csproj index 06df722..e51ce42 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 CS0649;CS0169 ..