From 83286ed1c35ab55bae2a74e7fd632ac26d669d1b Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 09:06:37 +0700 Subject: [PATCH 01/12] ci: build and test on Gitea Actions Move build.yml to .gitea/workflows. The Windows jobs run in host mode on the maintainer's PC, so setup-dotnet installs into the runner tool cache, the NuGet cache is the PC's own (no actions/cache), and artifacts go through the Gitea fork of upload-artifact (upstream v4+ refuses non-GitHub servers). Co-Authored-By: Claude Opus 5.5 --- {.github => .gitea}/workflows/build.yml | 51 ++++++++++++++++--------- 1 file changed, 32 insertions(+), 19 deletions(-) rename {.github => .gitea}/workflows/build.yml (55%) diff --git a/.github/workflows/build.yml b/.gitea/workflows/build.yml similarity index 55% rename from .github/workflows/build.yml rename to .gitea/workflows/build.yml index 573476d..e634f35 100644 --- a/.github/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,5 +1,15 @@ name: Build +# Build, format check, tests and a packaging smoke test on every push to main and every pull +# request (Gitea Actions, ops runbook poli0981/.github docs/GITEA-MIGRATION.md). +# +# - `windows-latest` is HOST MODE on the maintainer's PC (PowerShell, no isolation): setup-dotnet +# installs into the runner tool cache (DOTNET_INSTALL_DIR), never into C:\Program Files. NuGet +# packages come from the PC's per-user cache, which outlives the job, so there is no actions/cache. +# - Upstream actions/upload-artifact v4+ refuses non-GitHub servers: the Gitea fork uploads. +# - Outsiders cannot open pull requests on Gitea (registration is off), so no run here comes from +# a stranger's fork. + on: push: branches: [main] @@ -17,29 +27,29 @@ concurrency: env: DOTNET_NOLOGO: true DOTNET_CLI_TELEMETRY_OPTOUT: true - NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages jobs: build: # WPF (net10.0-windows) only builds on Windows. runs-on: windows-latest - timeout-minutes: 20 + timeout-minutes: 30 + permissions: + contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + - name: Keep .NET SDK installs in the runner tool cache (host mode) + shell: pwsh + run: | + $base = if ($env:RUNNER_TOOL_CACHE) { $env:RUNNER_TOOL_CACHE } else { Join-Path $env:LOCALAPPDATA 'gitea-runner\toolcache' } + "DOTNET_INSTALL_DIR=$(Join-Path $base 'dotnet')" >> $env:GITHUB_ENV + - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: global-json-file: global.json - - name: Cache NuGet packages - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ${{ env.NUGET_PACKAGES }} - key: nuget-${{ runner.os }}-${{ hashFiles('global.json', 'Directory.Build.props', '**/*.csproj') }} - restore-keys: nuget-${{ runner.os }}- - - name: Restore (NuGet audit fails on moderate+ advisories) run: dotnet restore CommandForge.slnx @@ -58,40 +68,43 @@ jobs: - name: Upload test results if: ${{ !cancelled() }} - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4 with: name: test-results path: TestResults + if-no-files-found: ignore retention-days: 14 package: # Publishes and packs exactly like release.yml, so a packaging regression (e.g. the Elevator - # missing from the publish folder) fails the PR instead of the tagged release. + # missing from the publish folder) fails the pull request instead of the tagged release. runs-on: windows-latest timeout-minutes: 30 + permissions: + contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + - name: Keep .NET SDK installs in the runner tool cache (host mode) + shell: pwsh + run: | + $base = if ($env:RUNNER_TOOL_CACHE) { $env:RUNNER_TOOL_CACHE } else { Join-Path $env:LOCALAPPDATA 'gitea-runner\toolcache' } + "DOTNET_INSTALL_DIR=$(Join-Path $base 'dotnet')" >> $env:GITHUB_ENV + - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: global-json-file: global.json - - name: Cache NuGet packages - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ${{ env.NUGET_PACKAGES }} - key: nuget-package-${{ runner.os }}-${{ hashFiles('global.json', 'Directory.Build.props', '**/*.csproj', '.config/dotnet-tools.json') }} - restore-keys: nuget-package-${{ runner.os }}- - - name: Publish + pack (Velopack smoke test) shell: pwsh run: ./scripts/pack.ps1 -Version 0.0.1 - name: Upload installer preview - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4 with: name: installer-preview path: Releases/*-Setup.exe + if-no-files-found: error retention-days: 7 -- 2.54.1 From 48efda1071ffb6c80e16e39f163eb68bfaf11736 Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 09:06:45 +0700 Subject: [PATCH 02/12] ci: drop CodeQL, dependency review, Scorecard and SonarCloud None of them runs on Gitea: CodeQL and Scorecard upload to GitHub code scanning (and Scorecard needs OIDC), dependency review reads GitHub's dependency graph, and SonarQube Cloud is dropped in every repository (ops migration decisions D1 and D7). The dotnet-sonarscanner tool goes with it. Opengrep, gitleaks, osv-scanner and NuGetAudit (the Security workflow) and Qodana take over. Co-Authored-By: Claude Opus 5.5 --- .config/dotnet-tools.json | 9 +- .github/workflows/codeql.yml | 67 ------------- .github/workflows/dependency-review.yml | 32 ------ .github/workflows/scorecard.yml | 45 --------- .github/workflows/sonarcloud.yml | 126 ------------------------ 5 files changed, 1 insertion(+), 278 deletions(-) delete mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/dependency-review.yml delete mode 100644 .github/workflows/scorecard.yml delete mode 100644 .github/workflows/sonarcloud.yml diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a98d72c..cf7e089 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -8,13 +8,6 @@ "vpk" ], "rollForward": false - }, - "dotnet-sonarscanner": { - "version": "12.1.0", - "commands": [ - "dotnet-sonarscanner" - ], - "rollForward": false } } -} \ No newline at end of file +} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index f3a8afe..0000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: CodeQL - -# Project-specific CodeQL (not the shared reusable workflow): the C# code is a WPF -# (net10.0-windows) app that only builds on Windows from a .slnx solution. The workflows -# themselves are analysed too (`actions` language). - -on: - push: - branches: [main] - pull_request: - branches: [main] - schedule: - - cron: '37 14 * * 1' # Mondays 14:37 UTC - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -jobs: - analyze: - name: Analyze (${{ matrix.language }}) - runs-on: ${{ matrix.os }} - timeout-minutes: 30 - permissions: - actions: read - contents: read - security-events: write - strategy: - fail-fast: false - matrix: - include: - - language: csharp - os: windows-latest - build-mode: manual - - language: actions - os: ubuntu-latest - build-mode: none - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - if: matrix.language == 'csharp' - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 - with: - global-json-file: global.json - - - name: Initialize CodeQL - uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 - with: - languages: ${{ matrix.language }} - build-mode: ${{ matrix.build-mode }} - queries: security-extended - - - if: matrix.build-mode == 'manual' - name: Build - # Roslyn analyzers add nothing to CodeQL's extraction and slow the traced build down. - run: dotnet build CommandForge.slnx -c Release -p:RunAnalyzers=false - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 - with: - category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml deleted file mode 100644 index ca0f982..0000000 --- a/.github/workflows/dependency-review.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Dependency Review - -# Blocks pull requests that add dependencies with known vulnerabilities (moderate or worse) or -# with licenses that are not compatible with GPLv3. - -on: - pull_request: - branches: [main] - -permissions: - contents: read - -jobs: - dependency-review: - runs-on: ubuntu-latest - timeout-minutes: 10 - permissions: - contents: read - pull-requests: write # summary comment on failure - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0 - with: - fail-on-severity: moderate - comment-summary-in-pr: on-failure - allow-licenses: >- - MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, 0BSD, Zlib, BSL-1.0, - Unlicense, CC0-1.0, MPL-2.0, OFL-1.1, LGPL-2.1-or-later, LGPL-3.0-only, - LGPL-3.0-or-later, GPL-3.0-only, GPL-3.0-or-later diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml deleted file mode 100644 index 037604a..0000000 --- a/.github/workflows/scorecard.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Scorecard - -# OpenSSF Scorecard supply-chain checks; results land in Security → Code scanning. - -on: - branch_protection_rule: - schedule: - - cron: '25 6 * * 1' # Mondays 06:25 UTC - push: - branches: [main] - workflow_dispatch: - -permissions: - contents: read - -jobs: - analysis: - name: Scorecard analysis - runs-on: ubuntu-latest - timeout-minutes: 15 - permissions: - actions: read - contents: read - security-events: write # upload SARIF - id-token: write # publish results to the OpenSSF API / badge - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0 - with: - results_file: results.sarif - results_format: sarif - publish_results: true - - - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: scorecard-sarif - path: results.sarif - retention-days: 5 - - - uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 - with: - sarif_file: results.sarif diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml deleted file mode 100644 index f8b9ccb..0000000 --- a/.github/workflows/sonarcloud.yml +++ /dev/null @@ -1,126 +0,0 @@ -name: SonarCloud - -# CI-based SonarCloud analysis (it replaced Automatic Analysis, which can't import coverage): the -# solution is built between the scanner's begin and end steps, the tests run with OpenCover -# coverage, and the SonarCloud GitHub App reports the quality gate on pull requests. The scanner -# turns TreatWarningsAsErrors off for its build, so build.yml stays the warnings-as-errors check. -# Requires the repository secret SONAR_TOKEN. - -on: - push: - branches: [main] - pull_request: - branches: [main] - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -env: - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - -jobs: - token: - # Pull requests from forks and from Dependabot get no repository secrets. Checking for the token - # skips those runs without trusting actor or repository names from the event. - name: Check for SONAR_TOKEN - runs-on: ubuntu-latest - timeout-minutes: 5 - permissions: {} - outputs: - available: ${{ steps.check.outputs.available }} - steps: - - name: Check for SONAR_TOKEN - id: check - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - if [ -n "$SONAR_TOKEN" ]; then - echo "available=true" >> "$GITHUB_OUTPUT" - else - echo "available=false" >> "$GITHUB_OUTPUT" - echo "::notice::SONAR_TOKEN is not available to this run (fork or Dependabot pull request); skipping the analysis." - fi - - analysis: - name: SonarCloud - needs: token - if: needs.token.outputs.available == 'true' - # WPF (net10.0-windows) only builds on Windows. - runs-on: windows-latest - timeout-minutes: 30 - permissions: - contents: read - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 # full history: SonarCloud uses blame to tell new code from old - persist-credentials: false - - - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 - with: - global-json-file: global.json - - # Both caches stay outside the workspace: the scanner also analyzes every .json, .yml and .ps1 - # file under the repository root. - - name: Cache NuGet packages - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ~/.nuget/packages - key: nuget-sonar-${{ runner.os }}-${{ hashFiles('global.json', 'Directory.Build.props', '**/*.csproj', '.config/dotnet-tools.json') }} - restore-keys: nuget-sonar-${{ runner.os }}- - - - name: Cache SonarCloud analyzers and JRE - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ~/.sonar/cache - key: sonar-${{ runner.os }}-${{ hashFiles('.config/dotnet-tools.json') }} - restore-keys: sonar-${{ runner.os }}- - - - name: Restore pinned tools (dotnet-sonarscanner) - run: dotnet tool restore - - # The project version drives SonarCloud's "previous version" new-code period. - # Roslyn rules already fail the build in build.yml, so their Info-level suggestions aren't - # imported as external issues. Coverage skips XAML code-behind and the two entry points (the - # app and the Elevator); the catalog JSON and the .resx files repeat structure by design. - - name: Begin analysis - shell: pwsh - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - $version = "$(dotnet msbuild src/CommandForge.Domain/CommandForge.Domain.csproj -getProperty:Version | Select-Object -Last 1)".Trim() - if ($LASTEXITCODE -ne 0 -or $version -notmatch '^\d+\.\d+\.\d+$') { throw "Unexpected project version '$version'." } - $scannerArgs = @( - 'begin', '/k:poli0981_CommandForge', '/o:poli0981', "/v:$version", - '/d:sonar.host.url=https://sonarcloud.io', "/d:sonar.token=$env:SONAR_TOKEN", - '/d:sonar.cs.opencover.reportsPaths=TestResults/**/coverage.opencover.xml', - '/d:sonar.cs.vstest.reportsPaths=TestResults/*.trx', - '/d:sonar.cs.roslyn.ignoreIssues=true', - '/d:sonar.exclusions=**/bin/**,**/obj/**,**/TestResults/**', - '/d:sonar.coverage.exclusions=**/*.xaml.cs,**/Program.cs', - '/d:sonar.cpd.exclusions=**/Catalog/*.json,**/*.resx' - ) - dotnet sonarscanner @scannerArgs - if ($LASTEXITCODE -ne 0) { throw "SonarScanner begin failed with exit code $LASTEXITCODE." } - - - name: Build - # Real source paths in the PDBs (not the /_/ deterministic ones), so coverage maps to files. - run: dotnet build CommandForge.slnx -c Release --no-incremental -p:ContinuousIntegrationBuild=false - - - name: Test with coverage - run: >- - dotnet test CommandForge.slnx -c Release --no-build - --collect "XPlat Code Coverage;Format=opencover" - --logger "trx;LogFileName=test-results.trx" - --results-directory TestResults - - - name: End analysis - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: dotnet sonarscanner end "/d:sonar.token=$env:SONAR_TOKEN" -- 2.54.1 From 3776562fb69aab3e19cbed217416d35ab3c42e66 Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 09:07:09 +0700 Subject: [PATCH 03/12] =?UTF-8?q?ci:=20Security=20workflow=20=E2=80=94=20w?= =?UTF-8?q?orkflow=20lint=20and=20the=20ops=20security=20scan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit actionlint and shellcheck (pinned, SHA-256 verified) lint .gitea/workflows, and the ops repo's security.yml runs gitleaks over the full history, Opengrep, osv-scanner and a NuGetAudit restore on the Windows runner. Push to main, pull requests, and weekly on Friday 14:11 UTC (inside the runner's 13:00-16:00 UTC window, a free slot in the ops cron registry). This replaces CodeQL for both the C# and the workflow analysis. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/security.yml | 82 +++++++++++++++++++++++++++++++++++ .github/actionlint.yaml | 10 +++++ 2 files changed, 92 insertions(+) create mode 100644 .gitea/workflows/security.yml create mode 100644 .github/actionlint.yaml diff --git a/.gitea/workflows/security.yml b/.gitea/workflows/security.yml new file mode 100644 index 0000000..e7f183f --- /dev/null +++ b/.gitea/workflows/security.yml @@ -0,0 +1,82 @@ +name: Security + +# Gitea has no CodeQL, no dependency review and no code-scanning UI (ops runbook §1, migration +# decision D7). This workflow covers instead: +# +# workflow-lint actionlint + shellcheck on .gitea/workflows/*.yml (CodeQL's `actions` analysis +# is gone; Opengrep's GitHub Actions rules below also check for injection) +# scan the ops repo's security.yml: gitleaks (full history), Opengrep (SAST, report +# only), osv-scanner (lockfiles; this repo has none, so it has nothing to scan) +# and a `dotnet restore` with NuGetAudit that fails on high/critical advisories +# (NU1903/NU1904). build.yml's restore already fails on moderate ones. +# +# Weekly as well, so a new advisory against unchanged dependencies turns it red: Friday 14:11 UTC +# = 21:11 Vietnam (a free slot in the ops repo's cron registry; the runner is the maintainer's PC +# and only runs 13:00–16:00 UTC). + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: '11 14 * * 5' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + # Both linters as release binaries at pinned versions, SHA-256 verified (the pins of the ops + # repo's ops-lint.yml). Renovate does not update them: bump version and checksum together. + workflow-lint: + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + env: + ACTIONLINT_VERSION: 1.7.12 + ACTIONLINT_SHA256: 8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8 # actionlint_1.7.12_linux_amd64.tar.gz + SHELLCHECK_VERSION: v0.11.0 + SHELLCHECK_SHA256: 8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198 # shellcheck-v0.11.0.linux.x86_64.tar.xz + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install actionlint ${{ env.ACTIONLINT_VERSION }} + shellcheck ${{ env.SHELLCHECK_VERSION }} + run: | + set -euo pipefail + tmp="${RUNNER_TEMP:-/tmp}" + bin="$tmp/lint-bin" + mkdir -p "$bin" + curl -fsSL --retry 3 -o "$tmp/actionlint.tar.gz" \ + "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" + echo "${ACTIONLINT_SHA256} $tmp/actionlint.tar.gz" | sha256sum -c - + tar -xzf "$tmp/actionlint.tar.gz" -C "$bin" actionlint + curl -fsSL --retry 3 -o "$tmp/shellcheck.tar.xz" \ + "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" + echo "${SHELLCHECK_SHA256} $tmp/shellcheck.tar.xz" | sha256sum -c - + tar -xJf "$tmp/shellcheck.tar.xz" -C "$bin" --strip-components=1 "shellcheck-${SHELLCHECK_VERSION}/shellcheck" + echo "$bin" >> "$GITHUB_PATH" + + # The files by name: actionlint only finds .github/workflows by itself. .github/actionlint.yaml + # ignores only the Gitea features actionlint does not know; everything else stays an error. + - name: actionlint (workflow syntax and expressions) + run: | + actionlint -version + actionlint -color -config-file .github/actionlint.yaml \ + -shellcheck "$(command -v shellcheck)" .gitea/workflows/*.yml + + scan: + permissions: + contents: read + uses: poli0981/.github/.gitea/workflows/security.yml@c133a00dc7a0bd7bd68253d415758b408d615fa4 # ops v2026.11.4 + with: + dotnet: true + dotnet-runs-on: windows-latest # WPF (net10.0-windows) restores only on Windows + dotnet-solution: CommandForge.slnx diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 0000000..22739b3 --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,10 @@ +# actionlint settings (security.yml, job `workflow-lint`, and a local `actionlint` run from the +# repository root), as in the ops repository poli0981/.github. Only Gitea features that actionlint +# does not know are ignored here; everything else stays an error. +paths: + .gitea/workflows/*.yml: + ignore: + # Gitea's own token scope for releases (ops runbook §3.2 item 5) + - 'unknown permission scope "releases"' + # Gitea resolves full-URL actions; a bare owner/repo goes to github.com (ops runbook §1) + - 'specifying action "https://gitea\.com/[^"]+" in invalid format' -- 2.54.1 From 43606c5b9f8075dc20161d863e80b67b647dcf14 Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 09:07:39 +0700 Subject: [PATCH 04/12] ci(qodana): run the Qodana CLI through the ops reusable workflow JetBrains/qodana-action needs GitHub's APIs (annotations, the PR comment, the cache). The ops repo's reusable-qodana.yml runs the pinned, checksum-verified Qodana CLI natively on the Windows runner instead, builds the solution first and keeps the report as an artifact; the results still go to Qodana Cloud. The token check job goes: Gitea has no fork pull requests, and runs started by renovate-bot skip the scan in the reusable itself. Co-Authored-By: Claude Opus 5.5 --- .editorconfig | 2 +- .gitea/workflows/qodana.yml | 46 ++++++++++++++ .github/workflows/qodana.yml | 112 ----------------------------------- qodana.yaml | 7 +-- 4 files changed, 50 insertions(+), 117 deletions(-) create mode 100644 .gitea/workflows/qodana.yml delete mode 100644 .github/workflows/qodana.yml diff --git a/.editorconfig b/.editorconfig index 4c2c47a..2fe275c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -33,7 +33,7 @@ indent_size = 2 [*.{g,g.i,Designer}.cs] generated_code = true -# --- ReSharper inspections: what Qodana reads (qodana.yaml, .github/workflows/qodana.yml) --- +# --- ReSharper inspections: what Qodana reads (qodana.yaml, .gitea/workflows/qodana.yml) --- # Qodana for .NET runs ReSharper's engine, and the engine reads these keys; so does Rider or ReSharper in the editor, # which is why they are here and not in qodana.yaml: the same list everywhere. An inspection is off only where it # argues with a choice this project made; each line says which. Everything else it reports is fixed. (What is NOT diff --git a/.gitea/workflows/qodana.yml b/.gitea/workflows/qodana.yml new file mode 100644 index 0000000..ed3c156 --- /dev/null +++ b/.gitea/workflows/qodana.yml @@ -0,0 +1,46 @@ +name: Qodana + +# JetBrains Qodana for .NET (`qodana-dotnet`, Rider's engine, on the Ultimate licence of the Qodana +# Cloud project): ReSharper's C#, XAML and .resx inspections, the IntelliJ platform's Markdown and +# XML inspections and JetBrains' security rules, over the whole solution. Every setting is in +# qodana.yaml; the gate there is zero problems. +# +# Runs the Qodana CLI through the ops repo's reusable-qodana.yml (JetBrains/qodana-action needs +# GitHub's APIs). Gitea has no code-scanning UI: the results go to Qodana Cloud and to the run's +# `qodana-report` artifact (SARIF and the linter's logs, for a reader without a Qodana Cloud account). +# +# - Native mode on `windows-latest` (host mode on the maintainer's PC): WPF (net10.0-windows) only +# loads on Windows, and the linter reads the projects with the SDK global.json names. +# - The solution is built first (prepare-command), so a build that fails is one red step with the +# compiler's own message rather than a report of unresolved symbols. +# - Advisory: not a required check of `main`, so a finding, a Qodana Cloud outage or a lapsed licence +# is a red job beside a green build, never a blocked merge. Runs started by renovate-bot skip it +# (the reusable's rule: a same-repo pull request gets the repository's secrets). +# Requires the repository secret QODANA_TOKEN. + +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + qodana: + permissions: + contents: read + uses: poli0981/.github/.gitea/workflows/reusable-qodana.yml@c133a00dc7a0bd7bd68253d415758b408d615fa4 # ops v2026.11.4 + with: + runs-on: windows-latest + dotnet-global-json-file: global.json + prepare-command: dotnet build CommandForge.slnx -c Release + artifact-name: qodana-report + secrets: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml deleted file mode 100644 index b9a728d..0000000 --- a/.github/workflows/qodana.yml +++ /dev/null @@ -1,112 +0,0 @@ -name: Qodana - -# JetBrains Qodana for .NET (`qodana-dotnet`, Rider's engine, on the Ultimate licence of the Qodana -# Cloud project): ReSharper's C#, XAML and .resx inspections, the IntelliJ platform's Markdown and XML -# inspections and JetBrains' security rules, over the whole solution. Results go to Qodana Cloud, to -# annotations and a summary comment on the pull request, and to the run's `qodana-report` artifact -# (SARIF and the linter's logs, for a reader without a Qodana Cloud account). -# -# - Native mode on a Windows runner (qodana.yaml: `withinDocker: false`): WPF (net10.0-windows) only -# loads on Windows, and the linter reads the projects with the SDK this job installs from -# global.json. Every setting is in qodana.yaml; nothing is an action argument. -# - The solution is built first, so a build that fails is one red step with the compiler's own -# message rather than a report of unresolved symbols. -# - `pr-mode: false`: the whole solution every time, so a pull request and `main` are judged by the -# same list. The gate (qodana.yaml) is zero problems. -# - Advisory: not a required check of the `main` ruleset, so a finding, a Qodana Cloud outage or a -# lapsed licence is a red job beside a green build, never a blocked merge. -# - No `contents: write`: the job never pushes quick-fixes. -# Requires the repository secret QODANA_TOKEN. - -on: - push: - branches: [main] - pull_request: - branches: [main] - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -env: - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - -jobs: - token: - # Pull requests from forks and from Dependabot get no repository secrets. Checking for the token - # skips those runs without trusting actor or repository names from the event. - name: Check for QODANA_TOKEN - runs-on: ubuntu-latest - timeout-minutes: 5 - permissions: {} - outputs: - available: ${{ steps.check.outputs.available }} - steps: - - name: Check for QODANA_TOKEN - id: check - env: - QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} - run: | - if [ -n "$QODANA_TOKEN" ]; then - echo "available=true" >> "$GITHUB_OUTPUT" - else - echo "available=false" >> "$GITHUB_OUTPUT" - echo "::notice::QODANA_TOKEN is not available to this run (fork or Dependabot pull request); skipping the analysis." - fi - - qodana: - name: Qodana - needs: token - if: needs.token.outputs.available == 'true' - # WPF (net10.0-windows) only builds on Windows, and the linter runs natively beside the SDK. - runs-on: windows-latest - timeout-minutes: 60 - permissions: - contents: read - checks: write # the annotations - pull-requests: write # the summary comment - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - # The pull request's own commit, not its merge commit (empty on a push or a dispatch, which - # then check out the commit that started them). - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 # full history: Qodana's reports are VCS-aware - persist-credentials: false - - - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 - with: - global-json-file: global.json - - # Outside the workspace: the linter reads every file under the repository root. - - name: Cache NuGet packages - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ~/.nuget/packages - key: nuget-qodana-${{ runner.os }}-${{ hashFiles('global.json', 'Directory.Build.props', '**/*.csproj') }} - restore-keys: nuget-qodana-${{ runner.os }}- - - - name: Restore - run: dotnet restore CommandForge.slnx - - - name: Build what the linter loads - run: dotnet build CommandForge.slnx -c Release --no-restore - - # Caches are saved from `main` only (a pull request reads them), under keys of this job's own. - - name: Qodana Scan - uses: JetBrains/qodana-action@3e8d76ff0e0241618abd808682f426afe84bab3f # v2026.2.2 - with: - pr-mode: false - upload-result: true - artifact-name: qodana-report - cache-default-branch-only: true - primary-cache-key: qodana-${{ github.ref_name }}-${{ github.sha }} - additional-cache-key: qodana-main - env: - QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} - QODANA_ENDPOINT: https://qodana.cloud diff --git a/qodana.yaml b/qodana.yaml index fcf6f23..0d6d2b6 100644 --- a/qodana.yaml +++ b/qodana.yaml @@ -1,13 +1,13 @@ -# Qodana's settings for .github/workflows/qodana.yml. +# Qodana's settings for .gitea/workflows/qodana.yml (the ops repo's reusable-qodana.yml, Qodana CLI). # # The linter is Qodana for .NET (`qodana-dotnet`: Rider's engine) in NATIVE mode, on the job's own # Windows runner with the .NET SDK that global.json names: the WPF projects (net10.0-windows) load # only on Windows. It needs the Ultimate licence of the Qodana Cloud project; the token is the # QODANA_TOKEN repository secret. # -# Everything a run needs is here and nothing is an action argument, so `qodana scan` in the +# Everything a run needs is here and nothing is a workflow argument, so `qodana scan` in the # repository root of a developer's PC (with QODANA_TOKEN set) reads the same settings. The linter's -# version is the action's: the workflow pins the action, the action its CLI, the CLI its linter. +# version is the CLI's: the ops workflow pins the CLI (SHA-256 verified), the CLI its linter. version: "1.0" linter: qodana-dotnet withinDocker: false @@ -50,7 +50,6 @@ exclude: - publish - TestResults - .nuget - - .sonarqube - docs - .claude - .idea -- 2.54.1 From aae42f7e2fb84a89dceee3366d44e31170e38287 Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 09:07:59 +0700 Subject: [PATCH 05/12] ci: Discord notifiers through the ops repo's Gitea workflows announce-release and notify-ci-failure call the ops repo's .gitea reusables at ops v2026.11.4 (c133a00), with ops_ref at the same commit so the notifier script matches, and pass only the secrets each one declares instead of inheriting all of them. notify-ci-failure watches Build, Qodana and Security (SonarCloud is gone). New: notify-release-pipeline reports every Release run to DISCORD_RELEASE_PIPELINE_WEBHOOK. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/announce-release.yml | 37 ++++++++++++++++++++ .gitea/workflows/notify-ci-failure.yml | 28 +++++++++++++++ .gitea/workflows/notify-release-pipeline.yml | 26 ++++++++++++++ .github/workflows/announce-release.yml | 27 -------------- .github/workflows/notify-ci-failure.yml | 26 -------------- 5 files changed, 91 insertions(+), 53 deletions(-) create mode 100644 .gitea/workflows/announce-release.yml create mode 100644 .gitea/workflows/notify-ci-failure.yml create mode 100644 .gitea/workflows/notify-release-pipeline.yml delete mode 100644 .github/workflows/announce-release.yml delete mode 100644 .github/workflows/notify-ci-failure.yml diff --git a/.gitea/workflows/announce-release.yml b/.gitea/workflows/announce-release.yml new file mode 100644 index 0000000..e5ddbe8 --- /dev/null +++ b/.gitea/workflows/announce-release.yml @@ -0,0 +1,37 @@ +name: Announce Release + +# Posts a release to Discord through the ops repo's announce-release.yml (which reads the release +# from the Gitea API). +# +# Tag releases are announced by release.yml itself: a release created with the job token fires no +# `release` event (Gitea credits it to its Actions user, whose events start nothing). This workflow +# covers a release a person publishes in the UI, and re-runs: Actions → Announce Release → Run +# workflow, with the tag. +# Secrets: DISCORD_RELEASES_WEBHOOK (or DISCORD_REPO_WEBHOOK); optional DISCORD_PING_ROLE_ID. + +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: Release tag to announce (e.g. v2.3.0) + required: true + type: string + +permissions: + contents: read + +jobs: + announce: + permissions: + contents: read + uses: poli0981/.github/.gitea/workflows/announce-release.yml@c133a00dc7a0bd7bd68253d415758b408d615fa4 # ops v2026.11.4 + with: + tag_override: ${{ inputs.tag || '' }} + ops_ref: c133a00dc7a0bd7bd68253d415758b408d615fa4 + # Only what the shared workflow declares, not `inherit`. + secrets: + DISCORD_RELEASES_WEBHOOK: ${{ secrets.DISCORD_RELEASES_WEBHOOK }} + DISCORD_REPO_WEBHOOK: ${{ secrets.DISCORD_REPO_WEBHOOK }} + DISCORD_PING_ROLE_ID: ${{ secrets.DISCORD_PING_ROLE_ID }} diff --git a/.gitea/workflows/notify-ci-failure.yml b/.gitea/workflows/notify-ci-failure.yml new file mode 100644 index 0000000..c781f5e --- /dev/null +++ b/.gitea/workflows/notify-ci-failure.yml @@ -0,0 +1,28 @@ +name: Notify CI Failure + +# A failed run of the workflows below on main posts to Discord through the ops repo's +# notify-ci-failure.yml (its script is loaded at `ops_ref`, the same commit as `uses:`). Neither file +# checks out the triggering run's code: they read run metadata only, and the shared workflow passes +# every untrusted field to the notifier through `env:`. Pull-request runs are skipped there (it only +# reports the default branch). Requires the repository secret DISCORD_CI_WEBHOOK. + +on: + workflow_run: + workflows: ["Build", "Qodana", "Security"] + types: [completed] + +permissions: + contents: read + actions: read + +jobs: + notify: + permissions: + contents: read + actions: read + uses: poli0981/.github/.gitea/workflows/notify-ci-failure.yml@c133a00dc7a0bd7bd68253d415758b408d615fa4 # ops v2026.11.4 + with: + default_branch: main + ops_ref: c133a00dc7a0bd7bd68253d415758b408d615fa4 + secrets: + DISCORD_CI_WEBHOOK: ${{ secrets.DISCORD_CI_WEBHOOK }} diff --git a/.gitea/workflows/notify-release-pipeline.yml b/.gitea/workflows/notify-release-pipeline.yml new file mode 100644 index 0000000..3358a79 --- /dev/null +++ b/.gitea/workflows/notify-release-pipeline.yml @@ -0,0 +1,26 @@ +name: Notify Release Pipeline + +# Every finished run of release.yml (success, failure or cancelled) is reported to Discord through +# the ops repo's notify-release-pipeline.yml. It matches the producer by its exact `name:`, so +# renaming release.yml's `name: Release` silently breaks this filter. +# Requires the repository secret DISCORD_RELEASE_PIPELINE_WEBHOOK. + +on: + workflow_run: + workflows: ["Release"] + types: [completed] + +permissions: + contents: read + actions: read + +jobs: + notify: + permissions: + contents: read + actions: read + uses: poli0981/.github/.gitea/workflows/notify-release-pipeline.yml@c133a00dc7a0bd7bd68253d415758b408d615fa4 # ops v2026.11.4 + with: + ops_ref: c133a00dc7a0bd7bd68253d415758b408d615fa4 + secrets: + DISCORD_RELEASE_PIPELINE_WEBHOOK: ${{ secrets.DISCORD_RELEASE_PIPELINE_WEBHOOK }} diff --git a/.github/workflows/announce-release.yml b/.github/workflows/announce-release.yml deleted file mode 100644 index 3b400bb..0000000 --- a/.github/workflows/announce-release.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Announce Release - -# Posts a release announcement to Discord (reuses the shared workflow in poli0981/.github). -# Tag releases are announced by release.yml itself (a release published with GITHUB_TOKEN does -# not fire the `release` event); this workflow covers releases published by hand and re-runs. -# Requires repo secret DISCORD_RELEASES_WEBHOOK (or DISCORD_REPO_WEBHOOK); optional -# DISCORD_PING_ROLE_ID. - -on: - release: - types: [published] - workflow_dispatch: - inputs: - tag: - description: Release tag to announce (e.g. v2.0.0) - required: true - type: string - -permissions: - contents: read - -jobs: - announce: - uses: poli0981/.github/.github/workflows/announce-release.yml@c3e118a01d40e95b36b2c3466dc206638c11eb5a # main, 2026-07-06 - with: - tag_override: ${{ github.event.inputs.tag || '' }} - secrets: inherit diff --git a/.github/workflows/notify-ci-failure.yml b/.github/workflows/notify-ci-failure.yml deleted file mode 100644 index 761cb0c..0000000 --- a/.github/workflows/notify-ci-failure.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Notify CI Failure - -# Posts a Discord alert when the Build, SonarCloud or Qodana workflow fails on main (reuses the -# shared workflow in poli0981/.github). Requires repo secret DISCORD_CI_WEBHOOK. - -on: - workflow_run: - workflows: ["Build", "SonarCloud", "Qodana"] - types: [completed] - -# The reusable workflow requests actions: read; without granting it here every run was a -# startup_failure (the repository default token is read-only for contents only). -permissions: - actions: read - contents: read - -jobs: - notify: - # The three workflows only run on `push` for main, so this limits alerts to main without trusting - # forgeable values (branch names, actor logins) — and skips pull-request runs (including - # Dependabot's), which have no access to the webhook secret anyway. - if: >- - github.event.workflow_run.conclusion == 'failure' && - github.event.workflow_run.event == 'push' - uses: poli0981/.github/.github/workflows/notify-ci-failure.yml@c3e118a01d40e95b36b2c3466dc206638c11eb5a # main, 2026-07-06 - secrets: inherit -- 2.54.1 From d39f188ea693c5907fc87e8b3f798a9a06793ccb Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 09:13:13 +0700 Subject: [PATCH 06/12] ci(release): Velopack to Cloudflare R2, CycloneDX SBOM, SHA256SUMS, Gitea release GitHub Releases is gone. A v* tag now builds and packs on the Windows runner as before (scripts/pack.ps1), then `vpk upload s3` puts the packages and the feed on R2 (releases.poli0981.dev/commandforge, feed last), the ops publish-r2.yml adds /SHA256SUMS and the SBOM, a Gitea release gets the notes and the links (no binaries), and the ops announcer posts to Discord. R2 credentials stay in VPK_* environment variables of this tag/dispatch-only workflow. scripts/release-assets.ps1 (also runs locally) writes the CycloneDX SBOM (CycloneDX tool 6.3.2, replacing GitHub's dependency-graph SBOM, decision D7), SHA256SUMS of the files this version ships, and the notes from CHANGELOG.md. The feed files are no longer hashed: vpk rewrites them on upload, which is what made checksums.txt wrong for RELEASES and releases.win.json in 2.1.0 and 2.2.0. A manual run on a branch is a dry run: it builds, packs, reads the previous release from R2 and keeps the files as an artifact, but uploads nothing. Attestations go (no OIDC on Gitea). VirusTotal stays optional. Co-Authored-By: Claude Opus 5.5 --- .config/dotnet-tools.json | 9 +- .gitea/workflows/release.yml | 235 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 191 --------------------------- .gitignore | 2 + scripts/pack.ps1 | 4 +- scripts/release-assets.ps1 | 129 +++++++++++++++++++ 6 files changed, 377 insertions(+), 193 deletions(-) create mode 100644 .gitea/workflows/release.yml delete mode 100644 .github/workflows/release.yml create mode 100644 scripts/release-assets.ps1 diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index cf7e089..3b0bb5a 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -8,6 +8,13 @@ "vpk" ], "rollForward": false + }, + "cyclonedx": { + "version": "6.3.2", + "commands": [ + "dotnet-CycloneDX" + ], + "rollForward": false } } -} +} \ No newline at end of file diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..051b735 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,235 @@ +name: Release + +# A signed `vX.Y.Z` tag on main releases CommandForge (RELEASING.md; ops runbook §3.3 and §5.1): +# +# build publish + Velopack pack (scripts/pack.ps1) on the maintainer's PC (host mode), the +# CycloneDX SBOM, SHA256SUMS and the release notes (scripts/release-assets.ps1), an +# optional VirusTotal scan, then `vpk upload s3` to Cloudflare R2: packages first, the +# feed (releases.win.json) last, so a client never sees a feed whose files are missing. +# Installed copies (2.3.0 and later) update from https://releases.poli0981.dev/commandforge. +# publish the ops repo's publish-r2.yml puts SHA256SUMS and the SBOM under /. +# release a Gitea release with the notes and the links (no binaries: the forge's disk is not for +# them, runbook §1). +# announce Discord, through the ops repo's announce-release.yml: a release made with the job +# token fires no `release` event, so announce-release.yml would never run by itself. +# +# Manual run (Actions → Release → Run workflow) on a branch is a DRY RUN: it builds, packs, writes +# the SBOM/checksums/notes from in Directory.Build.props, and reads the previous release +# from R2 (a check of the R2 credentials), but uploads nothing; the files stay as the `r2-release` +# artifact. Uploads, the release and the announcement happen only for a `v*` tag. A file uploaded +# under a versioned name is never replaced: to ship a fix, bump the version. +# +# Release credentials (user-level secrets R2_RELEASES_ACCESS_KEY_ID / _SECRET_ACCESS_KEY, variable +# R2_ACCOUNT_ID) exist only in steps of this tag/dispatch-only workflow (runbook §2 rule 10), as VPK_* +# environment variables, never on a command line. Optional repository secret VT_API_KEY turns on +# the VirusTotal scan. No dependency caches: a poisoned cache could end up inside the installer. +# No code signing yet (SECURITY.md), no build-provenance attestations (no OIDC on Gitea, D7). + +on: + push: + tags: ['v*'] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: release + cancel-in-progress: false + +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + +jobs: + build: + name: Build, pack and upload to R2 + runs-on: windows-latest # host mode on the maintainer's PC (PowerShell) + timeout-minutes: 60 + permissions: + contents: read + outputs: + version: ${{ steps.ver.outputs.version }} + env: + IS_TAG: ${{ startsWith(github.ref, 'refs/tags/v') }} + # Velopack's S3 options (vpk reads VPK_