From 23df7c0387880531ba0cb6d4dacd8dec1230465d Mon Sep 17 00:00:00 2001 From: Amin Javan Date: Tue, 27 Oct 2026 18:42:33 +0100 Subject: [PATCH] ci: validate SignalRGB release version and main ancestry Assisted-by: OpenAI Codex --- .github/workflows/release.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f5cef6f..03988e7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,6 +22,27 @@ jobs: PACKAGE_SUFFIX: ${{ github.event_name == 'push' && github.ref_name || format('dry-run-{0}', github.run_number) }} steps: - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - name: Validate release tag + if: github.event_name == 'push' + shell: pwsh + env: + RELEASE_REF: ${{ github.ref_name }} + run: | + if ($env:RELEASE_REF -notmatch '^v([0-9]+\.[0-9]+\.[0-9]+)$') { + throw "Release tags must use vMAJOR.MINOR.PATCH." + } + $tagVersion = $Matches[1] + $manifest = Get-Content src/FocusRgb.Plugin.SignalRgb/focusrgb-plugin.json -Raw | ConvertFrom-Json + if ($manifest.version -ne $tagVersion) { + throw "Plugin manifest version must equal tag version $tagVersion." + } + git fetch origin --no-tags "+refs/heads/main:refs/remotes/origin/main" + if ($LASTEXITCODE -ne 0) { throw "Could not refresh main history." } + git merge-base --is-ancestor $env:GITHUB_SHA origin/main + if ($LASTEXITCODE -ne 0) { throw "Release commits must belong to main history." } + exit 0 - uses: actions/setup-dotnet@v6 with: global-json-file: global.json