From 392a1b408271c58726c71a1c15a60c6f0f00202a Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Wed, 18 Dec 2024 17:40:17 -0500 Subject: [PATCH 1/2] Updated to the latest nuke packages --- .build/Build.CI.cs | 55 +++++++++------ .build/Build.cs | 2 +- .config/dotnet-tools.json | 5 ++ .github/workflows/ci.yml | 7 -- .github/workflows/close-milestone.yml | 98 ++++++++++++++++++++++++-- .github/workflows/draft-release.yml | 95 +++++++++++++++++++++++-- .github/workflows/publish-nuget.yml | 65 +++++++++++++++++ .github/workflows/update-milestone.yml | 77 ++++++++++++++++++-- Directory.Packages.props | 2 +- LaunchPad.sln | 1 + 10 files changed, 361 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/publish-nuget.yml diff --git a/.build/Build.CI.cs b/.build/Build.CI.cs index 1c749f97b..dd5afa3d3 100644 --- a/.build/Build.CI.cs +++ b/.build/Build.CI.cs @@ -2,6 +2,7 @@ using Nuke.Common.CI.GitHubActions.Configuration; using Rocket.Surgery.Nuke.ContinuousIntegration; using Rocket.Surgery.Nuke.GithubActions; +using Rocket.Surgery.Nuke.Jobs; #pragma warning disable CA1050 @@ -9,46 +10,59 @@ "ci-ignore", GitHubActionsImage.UbuntuLatest, AutoGenerate = false, - On = new[] { RocketSurgeonGitHubActionsTrigger.Push }, - OnPushTags = new[] { "v*" }, - OnPushBranches = new[] { "master", "main", "next" }, - OnPullRequestBranches = new[] { "master", "main", "next" }, - Enhancements = new[] { nameof(CiIgnoreMiddleware) } + On = [RocketSurgeonGitHubActionsTrigger.Push], + OnPushTags = ["v*"], + OnPushBranches = ["master", "main", "next"], + OnPullRequestBranches = ["master", "main", "next"], + Enhancements = [nameof(CiIgnoreMiddleware)] )] [GitHubActionsSteps( "ci", GitHubActionsImage.UbuntuLatest, AutoGenerate = false, - On = new[] { RocketSurgeonGitHubActionsTrigger.Push }, - OnPushTags = new[] { "v*" }, - OnPushBranches = new[] { "master", "main", "next" }, - OnPullRequestBranches = new[] { "master", "main", "next" }, - InvokedTargets = new[] { nameof(Default) }, - Enhancements = new[] { nameof(CiMiddleware) } + On = [RocketSurgeonGitHubActionsTrigger.Push], + OnPushTags = ["v*"], + OnPushBranches = ["master", "main", "next"], + OnPullRequestBranches = ["master", "main", "next"], + InvokedTargets = [nameof(Default)], + Enhancements = [nameof(CiMiddleware)] )] [GitHubActionsLint( "lint", GitHubActionsImage.UbuntuLatest, AutoGenerate = false, - OnPullRequestTargetBranches = new[] { "master", "main", "next" }, - Enhancements = new[] { nameof(LintStagedMiddleware) } + OnPullRequestTargetBranches = ["master", "main", "next"], + Enhancements = [nameof(LintStagedMiddleware)] )] -[PrintBuildVersion] +[CloseMilestoneJob] +[DraftReleaseJob] +[UpdateMilestoneJob] +[PublishNugetPackagesJob("RSG_NUGET_API_KEY", "ci")] [PrintCIEnvironment] [UploadLogs] [TitleEvents] [ContinuousIntegrationConventions] -public partial class Pipeline +[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] +internal partial class Pipeline { - public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(RocketSurgeonGitHubActionsConfiguration configuration) + [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] + private string DebuggerDisplay { - ((RocketSurgeonsGithubActionsJob)configuration.Jobs[0]).Steps = new List + get { + return ToString(); + } + } + + public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(RocketSurgeonGitHubActionsConfiguration configuration) + { + ( (RocketSurgeonsGithubActionsJob)configuration.Jobs[0] ).Steps = + [ new RunStep("N/A") { Run = "echo \"No build required\"" } - }; + ]; return configuration.IncludeRepositoryConfigurationFiles(); } @@ -57,10 +71,9 @@ public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(RocketSurgeon { var job = configuration .ExcludeRepositoryConfigurationFiles() - .AddNugetPublish() .Jobs.OfType() .First(z => z.Name.Equals("build", StringComparison.OrdinalIgnoreCase)); - job + _ = job .UseDotNetSdks("8.0", "9.0") .ConfigureStep(step => step.FetchDepth = 0) .PublishLogs(); @@ -70,7 +83,7 @@ public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(RocketSurgeon public static RocketSurgeonGitHubActionsConfiguration LintStagedMiddleware(RocketSurgeonGitHubActionsConfiguration configuration) { - configuration + _ = configuration .Jobs.OfType() .First(z => z.Name.Equals("Build", StringComparison.OrdinalIgnoreCase)) .UseDotNetSdks("8.0", "9.0"); diff --git a/.build/Build.cs b/.build/Build.cs index 9ba3ce717..ca6d64295 100644 --- a/.build/Build.cs +++ b/.build/Build.cs @@ -17,7 +17,7 @@ [NuGetVerbosityMapping] [ShutdownDotNetAfterServerBuild] [LocalBuildConventions] -public partial class Pipeline : NukeBuild, +internal partial class Pipeline : NukeBuild, ICanRestoreWithDotNetCore, ICanBuildWithDotNetCore, ICanTestWithDotNetCore, diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 262c9663e..c172a16c7 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -66,6 +66,11 @@ "version": "0.7.2", "commands": ["husky"], "rollForward": false + }, + "gitreleasemanager.tool": { + "version": "0.18.0", + "commands": ["dotnet-gitreleasemanager"], + "rollForward": false } } } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92250cd9a..d8e8cbf81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -184,10 +184,3 @@ jobs: with: name: 'nuget' path: 'artifacts/nuget/' - Publish: - needs: - - Build - uses: RocketSurgeonsGuild/actions/.github/workflows/publish-nuget.yml@v0.3.15 - secrets: - RSG_NUGET_API_KEY: '${{ secrets.RSG_NUGET_API_KEY }}' - RSG_AZURE_DEVOPS: '${{ secrets.RSG_AZURE_DEVOPS }}' diff --git a/.github/workflows/close-milestone.yml b/.github/workflows/close-milestone.yml index 376e70cbb..71da262c8 100644 --- a/.github/workflows/close-milestone.yml +++ b/.github/workflows/close-milestone.yml @@ -1,10 +1,98 @@ +# ------------------------------------------------------------------------------ +# +# +# This code was generated. +# +# - To turn off auto-generation set: +# +# [CloseMilestoneJob (AutoGenerate = false)] +# +# - To trigger manual generation invoke: +# +# nuke --generate-configuration GitHubActions_close-milestone --host GitHubActions +# +# +# ------------------------------------------------------------------------------ + name: Close Milestone + on: + workflow_call: + secrets: + RSG_BOT_TOKEN: + required: true release: - types: - - released +permissions: + actions: read + checks: read + contents: read + deployments: read + id-token: none + issues: write + discussions: none + packages: none + pages: none + pull-requests: write + repository-projects: none + security-events: none + statuses: write + jobs: close_milestone: - uses: RocketSurgeonsGuild/actions/.github/workflows/close-milestone6.yml@v0.3.15 - secrets: - RSG_BOT_TOKEN: ${{ secrets.RSG_BOT_TOKEN }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + clean: 'false' + fetch-depth: '0' + - name: Fetch all history for all tags and branches + run: | + git fetch --prune + - name: 📲 Install DotNet + uses: actions/setup-dotnet@v4 + - name: ⚒️ dotnet tool restore + run: | + dotnet tool restore + - name: 🔨 Use GitVersion + id: gitversion + shell: pwsh + run: | + $data = dotnet gitversion | ConvertFrom-Json + foreach ($item in $data.PSObject.Properties) { + $key = $item.Name + $value = $item.Value + echo "$($key.Substring(0,1).ToLower() + $key.Substring(1))=$value" >> $env:GITHUB_OUTPUT + } + - name: Create Milestone + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + uses: WyriHaximus/github-action-create-milestone@v1 + with: + title: 'v${{ steps.gitversion.outputs.majorMinorPatch }}' + - name: sync milestones + uses: RocketSurgeonsGuild/actions/sync-milestone@v0.3.15 + with: + default-label: ':sparkles: mysterious' + github-token: '${{ secrets.GITHUB_TOKEN }}' + - name: 📲 Install GitReleaseManager + uses: gittools/actions/gitreleasemanager/setup@v3.1.1 + with: + versionSpec: '0.18.0' + - name: Get Repo and Owner + id: repository + if: ${{ !github.event.release.prerelease && steps.gitversion.outputs.preReleaseTag == '' }} + shell: pwsh + run: | + $parts = $ENV:GITHUB_REPOSITORY.Split('/') + echo "::set-output name=owner::$($parts[0])" + echo "::set-output name=repository::$($parts[1])" + - name: Close Milestone + if: ${{ !github.event.release.prerelease && steps.gitversion.outputs.preReleaseTag == '' }} + shell: pwsh + run: | + dotnet gitreleasemanager close ` + -o "${{ steps.repository.outputs.owner }}" ` + -r "${{ steps.repository.outputs.repository }}" ` + --token "${{ secrets.GITHUB_TOKEN }}" ` + -m "v${{ steps.gitversion.outputs.majorMinorPatch }}" diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index c1c233229..3afc0d3ea 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -1,14 +1,97 @@ -name: Create Milestone and Draft Release +# ------------------------------------------------------------------------------ +# +# +# This code was generated. +# +# - To turn off auto-generation set: +# +# [DraftReleaseJob (AutoGenerate = false)] +# +# - To trigger manual generation invoke: +# +# nuke --generate-configuration GitHubActions_draft-release --host GitHubActions +# +# +# ------------------------------------------------------------------------------ + +name: Draft Release and Create Milestone + on: + workflow_call: + secrets: + RSG_BOT_TOKEN: + required: true push: branches: - - master + - 'master' paths-ignore: - '**/*.md' schedule: - cron: '0 0 * * 4' +permissions: + actions: read + checks: read + contents: read + deployments: read + id-token: none + issues: write + discussions: none + packages: none + pages: none + pull-requests: write + repository-projects: none + security-events: none + statuses: write + jobs: - create_milestone_and_draft_release: - uses: RocketSurgeonsGuild/actions/.github/workflows/draft-release6.yml@v0.3.15 - secrets: - RSG_BOT_TOKEN: ${{ secrets.RSG_BOT_TOKEN }} + draft_release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + clean: 'false' + fetch-depth: '0' + - name: Fetch all history for all tags and branches + run: | + git fetch --prune + - name: 📲 Install DotNet + uses: actions/setup-dotnet@v4 + - name: ⚒️ dotnet tool restore + run: | + dotnet tool restore + - name: 🔨 Use GitVersion + id: gitversion + shell: pwsh + run: | + $data = dotnet gitversion | ConvertFrom-Json + foreach ($item in $data.PSObject.Properties) { + $key = $item.Name + $value = $item.Value + echo "$($key.Substring(0,1).ToLower() + $key.Substring(1))=$value" >> $env:GITHUB_OUTPUT + } + - name: Create Milestone + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + uses: WyriHaximus/github-action-create-milestone@v1 + with: + title: 'v${{ steps.gitversion.outputs.majorMinorPatch }}' + - name: sync milestones + uses: RocketSurgeonsGuild/actions/sync-milestone@v0.3.15 + with: + default-label: ':sparkles: mysterious' + github-token: '${{ secrets.GITHUB_TOKEN }}' + - name: Create Release + uses: ncipollo/release-action@v1 + with: + allowUpdates: 'true' + generateReleaseNotes: 'true' + updateOnlyUnreleased: 'true' + draft: 'true' + omitBodyDuringUpdate: 'true' + omitNameDuringUpdate: 'true' + omitDraftDuringUpdate: 'true' + name: 'v${{ steps.gitversion.outputs.majorMinorPatch }}' + tag: 'v${{ steps.gitversion.outputs.majorMinorPatch }}' + token: '${{ secrets.RSG_BOT_TOKEN }}' + commit: '${{ github.base_ref }}' diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml new file mode 100644 index 000000000..0db9560a8 --- /dev/null +++ b/.github/workflows/publish-nuget.yml @@ -0,0 +1,65 @@ +# ------------------------------------------------------------------------------ +# +# +# This code was generated. +# +# - To turn off auto-generation set: +# +# [PublishNugetPackagesJob (AutoGenerate = false)] +# +# - To trigger manual generation invoke: +# +# nuke --generate-configuration GitHubActions_publish-nuget --host GitHubActions +# +# +# ------------------------------------------------------------------------------ + +name: Publish Nuget Packages + +on: + workflow_run: + workflows: + - 'ci' + types: + - 'completed' +permissions: + actions: read + checks: read + contents: read + deployments: read + id-token: none + issues: write + discussions: none + packages: none + pages: none + pull-requests: write + repository-projects: none + security-events: none + statuses: write + +jobs: + publish_nuget: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: '${{ toJson(github) }}' + shell: pwsh + run: | + echo "$GITHUB_CONTEXT" + - name: 🚀 NuGet + uses: actions/download-artifact@v4 + with: + name: 'nuget' + github-token: '${{ secrets.GITHUB_TOKEN }}' + run-id: '${{ github.event.workflow_run.id }}' + - name: nuget.org + env: + ApiKey: '${{ secrets.RSG_NUGET_API_KEY }}' + if: startsWith(github.event.workflow_run.head_branch, 'v') && contains(github.event.workflow_run.head_branch, '.') && !contains(github.event.workflow_run.head_branch, '/') + shell: pwsh + run: | + dotnet nuget push **/*.nupkg --skip-duplicate -s nuget.org --api-key $ENV:ApiKey + dotnet nuget push **/*.snupkg --skip-duplicate -s nuget.org --api-key $ENV:ApiKey + diff --git a/.github/workflows/update-milestone.yml b/.github/workflows/update-milestone.yml index 1327fe74b..763cbb576 100644 --- a/.github/workflows/update-milestone.yml +++ b/.github/workflows/update-milestone.yml @@ -1,12 +1,79 @@ +# ------------------------------------------------------------------------------ +# +# +# This code was generated. +# +# - To turn off auto-generation set: +# +# [UpdateMilestoneJob (AutoGenerate = false)] +# +# - To trigger manual generation invoke: +# +# nuke --generate-configuration GitHubActions_update-milestone --host GitHubActions +# +# +# ------------------------------------------------------------------------------ + name: Update Milestone + on: + push: pull_request_target: types: - - closed - - opened - - reopened - - synchronize + - 'closed' + - 'opened' + - 'reopened' + - 'synchronize' +permissions: + actions: read + checks: read + contents: read + deployments: read + id-token: none + issues: write + discussions: none + packages: none + pages: none + pull-requests: write + repository-projects: none + security-events: none + statuses: write jobs: update_milestone: - uses: RocketSurgeonsGuild/actions/.github/workflows/update-milestone6.yml@v0.3.15 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + clean: 'false' + fetch-depth: '0' + - name: Fetch all history for all tags and branches + run: | + git fetch --prune + - name: 📲 Install DotNet + uses: actions/setup-dotnet@v4 + - name: ⚒️ dotnet tool restore + run: | + dotnet tool restore + - name: 🔨 Use GitVersion + id: gitversion + shell: pwsh + run: | + $data = dotnet gitversion | ConvertFrom-Json + foreach ($item in $data.PSObject.Properties) { + $key = $item.Name + $value = $item.Value + echo "$($key.Substring(0,1).ToLower() + $key.Substring(1))=$value" >> $env:GITHUB_OUTPUT + } + - name: Create Milestone + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + uses: WyriHaximus/github-action-create-milestone@v1 + with: + title: 'v${{ steps.gitversion.outputs.majorMinorPatch }}' + - name: sync milestones + uses: RocketSurgeonsGuild/actions/sync-milestone@v0.3.15 + with: + default-label: ':sparkles: mysterious' + github-token: '${{ secrets.GITHUB_TOKEN }}' diff --git a/Directory.Packages.props b/Directory.Packages.props index d081b0616..1725a8d38 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -47,7 +47,7 @@ - + diff --git a/LaunchPad.sln b/LaunchPad.sln index 798a9cf76..3967222b0 100644 --- a/LaunchPad.sln +++ b/LaunchPad.sln @@ -165,6 +165,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ publish-docs.yml = .github\workflows\publish-docs.yml sync-labels.yml = .github\workflows\sync-labels.yml update-milestone.yml = .github\workflows\update-milestone.yml + publish-nuget.yml = .github\workflows\publish-nuget.yml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".husky", ".husky", "{3F3EA1F9-1174-40B6-95DB-4C85FA611BBB}" From 7830e05caa56c2be7592670d9af8d702bb753002 Mon Sep 17 00:00:00 2001 From: Rocket Understudy <33589210+rsg-bot@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:51:25 -0500 Subject: [PATCH 2/2] Automatically linting code --- .build/Build.CI.cs | 9 +-------- .github/workflows/publish-nuget.yml | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.build/Build.CI.cs b/.build/Build.CI.cs index dd5afa3d3..4cab168a8 100644 --- a/.build/Build.CI.cs +++ b/.build/Build.CI.cs @@ -1,5 +1,4 @@ using Nuke.Common.CI.GitHubActions; -using Nuke.Common.CI.GitHubActions.Configuration; using Rocket.Surgery.Nuke.ContinuousIntegration; using Rocket.Surgery.Nuke.GithubActions; using Rocket.Surgery.Nuke.Jobs; @@ -46,13 +45,7 @@ internal partial class Pipeline { [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } + private string DebuggerDisplay => ToString(); public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(RocketSurgeonGitHubActionsConfiguration configuration) { diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 0db9560a8..e0beecc3d 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -62,4 +62,3 @@ jobs: run: | dotnet nuget push **/*.nupkg --skip-duplicate -s nuget.org --api-key $ENV:ApiKey dotnet nuget push **/*.snupkg --skip-duplicate -s nuget.org --api-key $ENV:ApiKey -