From dfa7ca759db5962d707896e2002051736a8a81e0 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 19 Nov 2026 11:39:50 +1100 Subject: [PATCH] ci: derive component routing from the plugin registry Keep tag/main validation, shared release concurrency and immutable artifact promotion intact while removing copied allowlists and release callers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 14 +++++-- .github/workflows/release.yml | 67 ++------------------------------ CONTRIBUTING.md | 5 +++ RELEASES.md | 6 +++ eng/Build-Plugin.ps1 | 1 - eng/PluginRelease.psm1 | 7 +++- eng/Publish-GitHubPackage.ps1 | 1 - eng/Publish-NuGetPackage.ps1 | 1 - eng/Publish-Release.ps1 | 1 - eng/Test-NuGetPackage.ps1 | 2 +- eng/Test-ReleaseDestinations.ps1 | 15 ++++--- eng/Test-ReleaseSelection.ps1 | 30 ++++++++++++++ eng/Validate-Plugin.ps1 | 7 ++-- 13 files changed, 74 insertions(+), 83 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8134002..967afe4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,8 @@ permissions: jobs: repository: runs-on: ubuntu-latest + outputs: + plugins: ${{ steps.registry.outputs.plugins }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 @@ -24,15 +26,21 @@ jobs: ./eng/Test-ReleaseDestinations.ps1 ./eng/Test-NuGetPublication.ps1 ./eng/Test-GitHubPackages.ps1 - - name: Validate Quake core safety tests - run: dotnet test plugins/Server.Quake3/LANCommander.Community.Server.Quake3.Tests/LANCommander.Community.Server.Quake3.Tests.csproj -c Release --nologo + - name: Select registered components + id: registry + shell: pwsh + run: | + Import-Module ./eng/PluginRelease.psm1 -Force + $plugins = ConvertTo-Json -InputObject @(Get-PluginRegistry | ForEach-Object key) -Compress + "plugins=$plugins" >> $env:GITHUB_OUTPUT validate: + needs: repository runs-on: ubuntu-latest strategy: fail-fast: false matrix: - plugin: [Server.Mcp, Server.RecompCatalog, Launcher.MQTT, Server.Quake3] + plugin: ${{ fromJSON(needs.repository.outputs.plugins) }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b05bb6f..41472db 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,7 @@ name: Component release on: push: tags: - - server-mcp-v* - - server-recompcatalog-v* - - launcher-mqtt-v* - - server-quake3-v* + - '*-v*' workflow_dispatch: inputs: tag: @@ -92,66 +89,8 @@ jobs: "artifact_run_id=$env:ARTIFACT_RUN_ID" >> $env:GITHUB_OUTPUT "artifact_run_attempt=$env:ARTIFACT_RUN_ATTEMPT" >> $env:GITHUB_OUTPUT - server-mcp: + component-release: needs: plan - if: needs.plan.outputs.plugin == 'Server.Mcp' - concurrency: - group: release-server-mcp - cancel-in-progress: false - permissions: - actions: read - contents: write - packages: write - uses: ./.github/workflows/release-plugin.yml - with: - plugin: Server.Mcp - tag: ${{ needs.plan.outputs.tag }} - artifact_run_id: ${{ needs.plan.outputs.artifact_run_id }} - artifact_run_attempt: ${{ needs.plan.outputs.artifact_run_attempt }} - secrets: - nuget_api_key: ${{ secrets.NUGET_API_KEY }} - - server-quake3: - needs: plan - if: needs.plan.outputs.plugin == 'Server.Quake3' - permissions: - actions: read - contents: write - packages: write - uses: ./.github/workflows/release-plugin.yml - with: - plugin: Server.Quake3 - tag: ${{ needs.plan.outputs.tag }} - artifact_run_id: ${{ needs.plan.outputs.artifact_run_id }} - artifact_run_attempt: ${{ needs.plan.outputs.artifact_run_attempt }} - secrets: - nuget_api_key: ${{ secrets.NUGET_API_KEY }} - - server-recompcatalog: - needs: plan - if: needs.plan.outputs.plugin == 'Server.RecompCatalog' - concurrency: - group: release-server-recompcatalog - cancel-in-progress: false - permissions: - actions: read - contents: write - packages: write - uses: ./.github/workflows/release-plugin.yml - with: - plugin: Server.RecompCatalog - tag: ${{ needs.plan.outputs.tag }} - artifact_run_id: ${{ needs.plan.outputs.artifact_run_id }} - artifact_run_attempt: ${{ needs.plan.outputs.artifact_run_attempt }} - secrets: - nuget_api_key: ${{ secrets.NUGET_API_KEY }} - - launcher-mqtt: - needs: plan - if: needs.plan.outputs.plugin == 'Launcher.MQTT' - concurrency: - group: release-launcher-mqtt - cancel-in-progress: false permissions: actions: read contents: write @@ -159,7 +98,7 @@ jobs: packages: write uses: ./.github/workflows/release-plugin.yml with: - plugin: Launcher.MQTT + plugin: ${{ needs.plan.outputs.plugin }} tag: ${{ needs.plan.outputs.tag }} artifact_run_id: ${{ needs.plan.outputs.artifact_run_id }} artifact_run_attempt: ${{ needs.plan.outputs.artifact_run_attempt }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6a055ab..6ca3a38 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,11 @@ independent. Component-level props should contain only exceptions and import the shared plugin props. Do not copy shared defaults into individual projects; keep component-specific packaging and host runtime exclusions in their projects. +`eng/plugins.json` is the component allowlist used by build/validation scripts, +the CI matrix, and release selection. New components do not need a copied CI +matrix entry or release job. The generic component tag trigger still fails closed +on unknown prefixes, mismatched versions, and commits not reachable from `main`. + Before submitting changes, run the repository checks and the validation command(s) for affected components from the root [README](README.md#build-and-validate). See [Plugin releases](RELEASES.md) for versioning, packaging, and release diff --git a/RELEASES.md b/RELEASES.md index 52fd89d..89d94d7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -15,6 +15,12 @@ project and test paths, package identities, artifact formats, feed eligibility, and host compatibility metadata. Keep it consistent with project/package metadata when changing a component. +The tag workflow uses a generic `*-v*` trigger and resolves the exact component +through this registry before invoking one shared release job. Unknown tag +prefixes fail planning; they cannot publish. Per-component concurrency is +enforced by the reusable workflow. Release promotion, feed verification and +original-artifact recovery still use the same checked bytes without rebuilding. + | Component key | Version file | Changelog | Tag format | GitHub Release asset | NuGet feeds | | --- | --- | --- | --- | --- | --- | | `Server.Mcp` | `plugins/Server.Mcp/version.txt` | `plugins/Server.Mcp/CHANGELOG.md` | `server-mcp-v` | `LANCommander.Community.Server.Mcp..nupkg` | GitHub Packages; NuGet.org if `NUGET_API_KEY` is set | diff --git a/eng/Build-Plugin.ps1 b/eng/Build-Plugin.ps1 index 6f5c6a3..168756a 100644 --- a/eng/Build-Plugin.ps1 +++ b/eng/Build-Plugin.ps1 @@ -1,7 +1,6 @@ [CmdletBinding()] param( [Parameter(Mandatory)] - [ValidateSet('Server.Mcp', 'Server.RecompCatalog', 'Launcher.MQTT', 'Server.Quake3')] [string] $Plugin, [switch] $Package, [string] $OutputDirectory diff --git a/eng/PluginRelease.psm1 b/eng/PluginRelease.psm1 index 155633d..b37e733 100644 --- a/eng/PluginRelease.psm1 +++ b/eng/PluginRelease.psm1 @@ -14,7 +14,7 @@ function Assert-PluginComponentIdentity { function Get-PluginRegistry { $path = Join-Path (Split-Path $PSScriptRoot -Parent) 'eng\plugins.json' $registry = Get-Content -LiteralPath $path -Raw | ConvertFrom-Json - if ($registry.schemaVersion -ne 1 -or @($registry.plugins).Count -ne 4) { + if ($registry.schemaVersion -ne 1 -or @($registry.plugins).Count -eq 0) { throw "Unsupported or incomplete plugin registry: $path" } @@ -22,6 +22,11 @@ function Get-PluginRegistry { if (@($keys | Select-Object -Unique).Count -ne $keys.Count) { throw 'Plugin registry contains duplicate keys.' } + $prefixes = @($registry.plugins | ForEach-Object tagPrefix) + if (@($prefixes | Select-Object -Unique).Count -ne $prefixes.Count -or + @($prefixes | Where-Object { $_ -cnotmatch '^[a-z0-9]+(?:-[a-z0-9]+)*$' }).Count -gt 0) { + throw 'Plugin registry tag prefixes must be unique lowercase tag components.' + } foreach ($plugin in $registry.plugins) { Assert-PluginComponentIdentity $plugin } diff --git a/eng/Publish-GitHubPackage.ps1 b/eng/Publish-GitHubPackage.ps1 index 9c90bc6..d1565c8 100644 --- a/eng/Publish-GitHubPackage.ps1 +++ b/eng/Publish-GitHubPackage.ps1 @@ -1,7 +1,6 @@ [CmdletBinding()] param( [Parameter(Mandatory)] - [ValidateSet('Server.Mcp', 'Server.RecompCatalog', 'Server.Quake3', 'Launcher.MQTT')] [string] $Plugin, [Parameter(Mandatory)][string] $Tag, [Parameter(Mandatory)][string] $ArtifactDirectory, diff --git a/eng/Publish-NuGetPackage.ps1 b/eng/Publish-NuGetPackage.ps1 index b2f14e3..dce7780 100644 --- a/eng/Publish-NuGetPackage.ps1 +++ b/eng/Publish-NuGetPackage.ps1 @@ -1,7 +1,6 @@ [CmdletBinding()] param( [Parameter(Mandatory)] - [ValidateSet('Server.Mcp', 'Server.RecompCatalog', 'Server.Quake3', 'Launcher.MQTT')] [string] $Plugin, [Parameter(Mandatory)][string] $Tag, [Parameter(Mandatory)][string] $ArtifactDirectory, diff --git a/eng/Publish-Release.ps1 b/eng/Publish-Release.ps1 index eed06d3..3ce381b 100644 --- a/eng/Publish-Release.ps1 +++ b/eng/Publish-Release.ps1 @@ -1,7 +1,6 @@ [CmdletBinding()] param( [Parameter(Mandatory)] - [ValidateSet('Server.Mcp', 'Server.RecompCatalog', 'Launcher.MQTT', 'Server.Quake3')] [string] $Plugin, [Parameter(Mandatory)][string] $Tag, [Parameter(Mandatory)][string] $ArtifactDirectory, diff --git a/eng/Test-NuGetPackage.ps1 b/eng/Test-NuGetPackage.ps1 index a50f068..8a0a11c 100644 --- a/eng/Test-NuGetPackage.ps1 +++ b/eng/Test-NuGetPackage.ps1 @@ -1,7 +1,6 @@ [CmdletBinding()] param( [Parameter(Mandatory)] - [ValidateSet('Server.Mcp', 'Server.RecompCatalog', 'Server.Quake3', 'Launcher.MQTT')] [string] $Plugin, [Parameter(Mandatory)][string] $PackagePath, [Parameter(Mandatory)][string] $ExpectedVersion, @@ -11,6 +10,7 @@ param( $ErrorActionPreference = 'Stop' Import-Module (Join-Path $PSScriptRoot 'PluginRelease.psm1') -Force $component = @(Get-PluginRegistry | Where-Object key -CEQ $Plugin)[0] +if (-not $component) { throw "Unknown plugin '$Plugin'. Select only keys in eng/plugins.json." } if ($component.artifactFormat -cne 'nupkg') { throw "$Plugin does not produce a NuGet package." } diff --git a/eng/Test-ReleaseDestinations.ps1 b/eng/Test-ReleaseDestinations.ps1 index c7a07aa..0a3d1f1 100644 --- a/eng/Test-ReleaseDestinations.ps1 +++ b/eng/Test-ReleaseDestinations.ps1 @@ -15,11 +15,15 @@ function Assert-Fails { $releaseWorkflow = Get-Content -LiteralPath (Join-Path $repositoryRoot '.github/workflows/release-plugin.yml') -Raw $callerWorkflow = Get-Content -LiteralPath (Join-Path $repositoryRoot '.github/workflows/release.yml') -Raw -$launcherJob = [regex]::Match($callerWorkflow, '(?ms)^ launcher-mqtt:\r?\n(?.*?)(?=^ [A-Za-z0-9_-]+:|\z)').Groups['body'].Value -if ($launcherJob -notmatch 'packages:\s+write' -or - $launcherJob -notmatch 'nuget_api_key:\s+\$\{\{\s*secrets\.NUGET_API_KEY\s*\}\}' -or - $launcherJob -notmatch 'uses:\s+\./\.github/workflows/release-plugin\.yml') { - throw 'Launcher releases must use the shared workflow with package permissions and optional NuGet.org key forwarding.' +$componentJob = [regex]::Match($callerWorkflow, '(?ms)^ component-release:\r?\n(?.*?)(?=^ [A-Za-z0-9_-]+:|\z)').Groups['body'].Value +if ($componentJob -notmatch 'needs:\s+plan' -or + $componentJob -notmatch 'plugin:\s+\$\{\{\s*needs\.plan\.outputs\.plugin\s*\}\}' -or + $componentJob -notmatch 'packages:\s+write' -or + $componentJob -notmatch 'nuget_api_key:\s+\$\{\{\s*secrets\.NUGET_API_KEY\s*\}\}' -or + $componentJob -notmatch 'uses:\s+\./\.github/workflows/release-plugin\.yml' -or + ([regex]::Matches($callerWorkflow, 'uses:\s+\./\.github/workflows/release-plugin\.yml')).Count -ne 1 -or + $releaseWorkflow -notmatch 'group:\s+plugin-release-\$\{\{\s*inputs\.plugin\s*\}\}') { + throw 'All registered releases must use one plan-selected workflow with per-plugin concurrency, package permissions and optional NuGet.org key forwarding.' } $nugetKeyJob = [regex]::Match($releaseWorkflow, '(?ms)^ nuget-key:\r?\n(?.*?)(?=^ [A-Za-z0-9_-]+:|\z)').Groups['body'].Value $buildJob = [regex]::Match($releaseWorkflow, '(?ms)^ build:\r?\n(?.*?)(?=^ [A-Za-z0-9_-]+:|\z)').Groups['body'].Value @@ -53,7 +57,6 @@ if ($nugetJob -notmatch 'NUGET_API_KEY:\s+\$\{\{\s*secrets\.nuget_api_key\s*\}\} throw 'NuGet.org must use the optional API key only in its package publishing job without an extra environment gate.' } if ($callerWorkflow -notmatch 'nuget_api_key:\s+\$\{\{\s*secrets\.NUGET_API_KEY\s*\}\}' -or - $callerWorkflow -notmatch 'server-quake3:' -or $releaseWorkflow -match '(?s)publish-nuget-org:.*?NUGET_API_KEY.*?publish-github-packages:') { throw 'The tag caller must pass the optional key to the reusable workflow without coupling the feeds.' } diff --git a/eng/Test-ReleaseSelection.ps1 b/eng/Test-ReleaseSelection.ps1 index e828fe2..5943dd5 100644 --- a/eng/Test-ReleaseSelection.ps1 +++ b/eng/Test-ReleaseSelection.ps1 @@ -88,4 +88,34 @@ Assert-Fails { Resolve-PluginSelection -Tag 'server-mcp-v0.2.1-beta.01' } 'Malfo Assert-Fails { Resolve-PluginSelection -Plugins @('Server.RecompCatalog') -Tag 'server-mcp-v0.2.1' } 'Conflicting tag and selection' Assert-Fails { Resolve-PluginSelection } 'Missing selection' +$fixtureRoot = Join-Path ([IO.Path]::GetTempPath()) "plugin-registry-$([Guid]::NewGuid().ToString('N'))" +New-Item -ItemType Directory -Path (Join-Path $fixtureRoot 'eng') | Out-Null +try { + $modulePath = Join-Path $fixtureRoot 'eng/RegistryFixture.psm1' + Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'PluginRelease.psm1') -Destination $modulePath + Import-Module $modulePath -Prefix Fixture -Force + $registry = Get-Content -LiteralPath (Join-Path $PSScriptRoot 'plugins.json') -Raw | ConvertFrom-Json + $extra = $registry.plugins[0] | ConvertTo-Json -Depth 5 | ConvertFrom-Json + $extra.key = 'Server.Example' + $extra.tagPrefix = 'server-example' + $extra.project = 'plugins/Server.Example/LANCommander.Community.Server.Example/LANCommander.Community.Server.Example.csproj' + $extra.packageId = $extra.assemblyName = $extra.rootNamespace = 'LANCommander.Community.Server.Example' + $registry.plugins += $extra + $registry | ConvertTo-Json -Depth 5 | Set-Content (Join-Path $fixtureRoot 'eng/plugins.json') + Assert-Equal 5 @(Get-FixturePluginRegistry).Count 'Registry accepts a new canonical component without editing an allowlist' + $extra.tagPrefix = $registry.plugins[0].tagPrefix + $registry | ConvertTo-Json -Depth 5 | Set-Content (Join-Path $fixtureRoot 'eng/plugins.json') + Assert-Fails { Get-FixturePluginRegistry } 'Registry rejects ambiguous tag prefixes' +} +finally { + Remove-Module RegistryFixture -ErrorAction SilentlyContinue + Remove-Item -LiteralPath $fixtureRoot -Recurse -Force +} + +Assert-Fails { & (Join-Path $PSScriptRoot 'Build-Plugin.ps1') -Plugin Server.Unknown } 'Build rejects unknown registry key' +Assert-Fails { & (Join-Path $PSScriptRoot 'Validate-Plugin.ps1') -Plugin Server.Unknown } 'Validation rejects unknown registry key' +Assert-Fails { + & (Join-Path $PSScriptRoot 'Test-NuGetPackage.ps1') -Plugin Server.Unknown -PackagePath missing.nupkg -ExpectedVersion 1.0.0 +} 'Package validation rejects unknown registry key' + Write-Output 'Release selection tests passed.' diff --git a/eng/Validate-Plugin.ps1 b/eng/Validate-Plugin.ps1 index c8a7e19..498612a 100644 --- a/eng/Validate-Plugin.ps1 +++ b/eng/Validate-Plugin.ps1 @@ -1,16 +1,15 @@ [CmdletBinding()] param( [Parameter(Mandatory)] - [ValidateSet('Server.Mcp', 'Server.RecompCatalog', 'Launcher.MQTT', 'Server.Quake3')] [string] $Plugin, [string] $OutputDirectory ) $ErrorActionPreference = 'Stop' $repositoryRoot = Split-Path $PSScriptRoot -Parent -$component = @(Get-Content -LiteralPath (Join-Path $PSScriptRoot 'plugins.json') -Raw | - ConvertFrom-Json | Select-Object -ExpandProperty plugins | Where-Object key -CEQ $Plugin)[0] -if (-not $component) { throw "Plugin '$Plugin' is missing from the release registry." } +Import-Module (Join-Path $PSScriptRoot 'PluginRelease.psm1') -Force +$null = Resolve-PluginSelection -Plugins @($Plugin) +$component = @(Get-PluginRegistry | Where-Object key -CEQ $Plugin)[0] $testProjects = @($component.tests | ForEach-Object { Join-Path $repositoryRoot $_ }) $packageOutput = if ($OutputDirectory) { $OutputDirectory } else { Join-Path $repositoryRoot "artifacts/validation-$($component.tagPrefix)"