diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a98d72c..3b0bb5a 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,10 +9,10 @@ ], "rollForward": false }, - "dotnet-sonarscanner": { - "version": "12.1.0", + "cyclonedx": { + "version": "6.3.2", "commands": [ - "dotnet-sonarscanner" + "dotnet-CycloneDX" ], "rollForward": false } 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/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/.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 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/.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/.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_