From c43c641a2980f15ac3a8e4cba0a8988b150f1e2f Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 10:58:18 +0700 Subject: [PATCH 01/17] ci: build and test on Gitea Actions The CI workflow moves to .gitea/workflows. Windows runs in host mode on the maintainer's PC: the SDK goes into the runner tool cache, NuGet comes from the PC's cache instead of actions/cache, and the smoke test keeps its data in the job's temp folder. macOS is dropped (no macOS runner, migration decision D9). Test results upload through the Gitea artifact action; ci-ok stays the check branch protection requires. Co-Authored-By: Claude Opus 5.5 --- {.github => .gitea}/workflows/ci.yml | 45 ++++++++++++++++++---------- 1 file changed, 29 insertions(+), 16 deletions(-) rename {.github => .gitea}/workflows/ci.yml (63%) diff --git a/.github/workflows/ci.yml b/.gitea/workflows/ci.yml similarity index 63% rename from .github/workflows/ci.yml rename to .gitea/workflows/ci.yml index 4080aea..b949999 100644 --- a/.github/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,16 +1,29 @@ name: CI +# Build, tests, the Core coverage gate, the headless smoke test, formatting and translations, 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 (no isolation): setup-dotnet installs into the runner tool +# cache, NuGet packages come from the PC's own cache (no actions/cache), and every step that starts the app points +# HASHTOOL_DATA_DIR at the job's temp folder, never at the real %LOCALAPPDATA%\HashTool. The tests do the same +# (tests/HashTool.App.Tests/TestEnvironment.cs). +# - `ubuntu-latest` runs in Docker. There is no macOS runner on Gitea, so macOS is no longer built (migration D9). +# - Upstream actions/upload-artifact v4+ refuses non-GitHub servers: the Gitea fork uploads. +# - `ci-ok` is the check branch protection requires. + on: push: branches: [main] pull_request: + branches: [main] workflow_dispatch: -permissions: {} +permissions: + contents: read concurrency: group: ci-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + cancel-in-progress: ${{ github.event_name == 'pull_request' }} env: DOTNET_NOLOGO: true @@ -24,7 +37,7 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, macos-latest, ubuntu-latest] + os: [windows-latest, ubuntu-latest] runs-on: ${{ matrix.os }} timeout-minutes: 30 permissions: @@ -34,15 +47,16 @@ jobs: with: persist-credentials: false + - name: Keep .NET SDK installs in the runner tool cache (host mode) + if: runner.os == 'Windows' + 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: - dotnet-version: 10.0.4xx - - - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ~/.nuget/packages - key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'Directory.Packages.props', 'Directory.Build.props', 'global.json') }} - restore-keys: nuget-${{ runner.os }}- + global-json-file: global.json - name: Restore run: dotnet restore HashTool.slnx @@ -52,7 +66,7 @@ jobs: run: dotnet build HashTool.slnx -c Release --no-restore -warnaserror - name: Test - run: > + run: >- dotnet test --solution HashTool.slnx -c Release --no-build --results-directory TestResults --coverage --coverage-output-format cobertura @@ -63,14 +77,13 @@ jobs: # Starts the real app headless: every page, every language, hashing and verifying a file. - name: Smoke test - shell: bash env: HASHTOOL_DATA_DIR: ${{ runner.temp }}/smoke-data run: dotnet src/HashTool.App/bin/Release/net10.0/CheckHash.dll --smoke-test --smoke-out TestResults/smoke.json - name: Upload test results - if: always() - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + if: ${{ !cancelled() }} + uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4 with: name: test-results-${{ matrix.os }} path: TestResults @@ -90,7 +103,7 @@ jobs: - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: - dotnet-version: 10.0.4xx + global-json-file: global.json - name: Restore run: dotnet restore HashTool.slnx @@ -101,7 +114,7 @@ jobs: - name: Check translations run: python3 -I eng/loc.py check - # Single required status check for branch protection. + # The check branch protection requires. ci-ok: name: ci-ok if: always() -- 2.54.1 From e162e7e7ba5e145ab74487d101d87f101b225dbe Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 10:58:35 +0700 Subject: [PATCH 02/17] ci: drop CodeQL, dependency review and submission, Scorecard and SonarCloud None of them works on Gitea: no code-scanning UI, no dependency graph, no OIDC (migration decisions D1 and D7). The ops repo's security scan (Opengrep, gitleaks, osv-scanner, NuGetAudit) and Qodana take over. SonarScanner and dotnet-coverage leave the tool manifest; only the Sonar workflow used them. Co-Authored-By: Claude Opus 5.5 --- .config/dotnet-tools.json | 14 --- .github/workflows/codeql.yml | 50 -------- .github/workflows/dependency-review.yml | 24 ---- .github/workflows/dependency-submission.yml | 34 ------ .github/workflows/scorecard.yml | 36 ------ .github/workflows/sonarcloud.yml | 114 ------------------ .../HashTool.Benchmarks.csproj | 2 - qodana.yaml | 8 +- 8 files changed, 4 insertions(+), 278 deletions(-) delete mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/dependency-review.yml delete mode 100644 .github/workflows/dependency-submission.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 381aa9c..5d7a2ab 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -22,20 +22,6 @@ "dotnet-CycloneDX" ], "rollForward": false - }, - "dotnet-sonarscanner": { - "version": "12.1.0", - "commands": [ - "dotnet-sonarscanner" - ], - "rollForward": false - }, - "dotnet-coverage": { - "version": "18.12.0", - "commands": [ - "dotnet-coverage" - ], - "rollForward": false } } } diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index a66a834..0000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: CodeQL - -# Advanced setup in place of CodeQL default setup, which never analyses Dependabot pull requests: the required -# `Analyze (...)` checks never reported there, so they could not be merged. Same languages, build mode, default query -# suite and `/language:` categories as default setup, so existing alerts carry over. Default setup must stay disabled -# in the repository settings: while it is enabled, code scanning rejects this workflow's uploads. -on: - push: - branches: [main] - # Dependabot pull requests too: code scanning accepts uploads from pull_request runs despite their read-only token. - pull_request: - branches: [main] - schedule: - - cron: "17 3 * * 3" - workflow_dispatch: - -permissions: {} - -concurrency: - group: codeql-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -jobs: - analyze: - # Required checks of the main ruleset: keep the job names. - name: Analyze (${{ matrix.language }}) - runs-on: ubuntu-latest - timeout-minutes: 30 - permissions: - contents: read - security-events: write - actions: read - strategy: - fail-fast: false - matrix: - language: [actions, csharp, python] - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - # No build, for C# too: the extractor installs the SDK from global.json and restores the packages itself. - - uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 - with: - languages: ${{ matrix.language }} - build-mode: none - - - 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 6c248fd..0000000 --- a/.github/workflows/dependency-review.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Dependency Review - -on: - pull_request: - -permissions: {} - -jobs: - dependency-review: - name: dependency-review - runs-on: ubuntu-latest - timeout-minutes: 10 - permissions: - contents: read - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - # Licenses are checked by the Security workflow (nuget-license reads the exact NuGet metadata). - - uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0 - with: - fail-on-severity: moderate - license-check: false diff --git a/.github/workflows/dependency-submission.yml b/.github/workflows/dependency-submission.yml deleted file mode 100644 index 227012e..0000000 --- a/.github/workflows/dependency-submission.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Dependency Submission - -# Submits the resolved NuGet graph, including transitive packages, so Dependabot alerts cover packages that are only -# pulled in indirectly (central package management hides versions from GitHub's static parser). -on: - push: - branches: [main] - workflow_dispatch: - -permissions: {} - -jobs: - submit: - name: submit - runs-on: ubuntu-latest - timeout-minutes: 15 - permissions: - contents: write - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 - with: - dotnet-version: 10.0.4xx - - - name: Restore - run: dotnet restore HashTool.slnx - - - uses: advanced-security/component-detection-dependency-submission-action@a02aeda7a175ad4dd38a13c4d3ff2df9da8f2cf0 # v0.2.0 - with: - detectorsCategories: NuGet - directoryExclusionList: "**/tests/Compat/**" diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml deleted file mode 100644 index 8e84f75..0000000 --- a/.github/workflows/scorecard.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Scorecard - -on: - push: - branches: [main] - schedule: - - cron: "41 5 * * 2" - branch_protection_rule: - workflow_dispatch: - -permissions: {} - -jobs: - analysis: - name: analysis - runs-on: ubuntu-latest - timeout-minutes: 15 - permissions: - contents: read - actions: read - security-events: write - id-token: write - 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: 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 8c021d9..0000000 --- a/.github/workflows/sonarcloud.yml +++ /dev/null @@ -1,114 +0,0 @@ -name: SonarCloud - -# CI-based analysis (Automatic Analysis is turned off in SonarCloud): the C# is analysed during a real build, with -# coverage from the unit tests and the smoke test; scripts and workflows are analysed too. SonarCloud reports the -# quality gate on pull requests itself. -on: - push: - branches: [main] - pull_request: - branches: [main] - workflow_dispatch: - -permissions: {} - -concurrency: - group: sonarcloud-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -env: - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - AVALONIA_TELEMETRY_OPTOUT: 1 - -jobs: - # Pull requests from forks and from Dependabot get no repository secrets: skip the analysis instead of failing it. - token: - name: 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); analysis skipped." - fi - - sonarcloud: - name: sonarcloud - needs: token - # Manual runs analyse main only: other branches would create separate SonarCloud branch analyses. - if: needs.token.outputs.available == 'true' && (github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main') - runs-on: ubuntu-latest - timeout-minutes: 30 - permissions: - contents: read - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - # Full history: SonarCloud uses blame to tell new code from old. - fetch-depth: 0 - persist-credentials: false - - - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 - with: - dotnet-version: 10.0.4xx - - - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: ~/.nuget/packages - key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'Directory.Packages.props', 'Directory.Build.props', 'global.json') }} - restore-keys: nuget-${{ runner.os }}- - - - name: Install tools - run: dotnet tool restore - - # Coverage: the Cobertura reports of the unit tests and of the smoke test. eng/ holds the CI and release scripts - # (Python), for which no coverage is collected, so they stay out of the coverage figure. - # Third-party Roslyn analyzers (Meziantou, ReferenceTrimmer) already fail the CI build when they warn; their - # suggestions are not imported as SonarCloud issues. - - name: Begin analysis - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - version=$(sed -n 's:.*\(.*\).*:\1:p' Directory.Build.props) - dotnet sonarscanner begin /k:poli0981_HashTool /o:poli0981 /v:"$version" \ - /d:sonar.host.url=https://sonarcloud.io /d:sonar.token="$SONAR_TOKEN" \ - /d:sonar.cs.cobertura.reportsPaths="TestResults/**/*.cobertura.xml" \ - /d:sonar.coverage.exclusions="eng/**" \ - /d:sonar.cs.roslyn.ignoreIssues=true \ - /d:sonar.qualitygate.wait=true - - # No -warnaserror: CI enforces it, and here it would turn SonarCloud findings into build errors. - - name: Build - run: dotnet build HashTool.slnx -c Release - - - name: Test - run: > - dotnet test --solution HashTool.slnx -c Release --no-build - --results-directory TestResults - --coverage --coverage-output-format cobertura - - # The real app, headless: every page and language, hashing and verifying a file (see ci.yml). - - name: Smoke test with coverage - env: - HASHTOOL_DATA_DIR: ${{ runner.temp }}/smoke-data - run: > - dotnet coverage collect -f cobertura -o TestResults/smoke.cobertura.xml - "dotnet src/HashTool.App/bin/Release/net10.0/CheckHash.dll --smoke-test" - - # Fails when the quality gate fails. - - name: End analysis - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN" diff --git a/bench/HashTool.Benchmarks/HashTool.Benchmarks.csproj b/bench/HashTool.Benchmarks/HashTool.Benchmarks.csproj index 2e4accd..df67cf2 100644 --- a/bench/HashTool.Benchmarks/HashTool.Benchmarks.csproj +++ b/bench/HashTool.Benchmarks/HashTool.Benchmarks.csproj @@ -4,8 +4,6 @@ false true - - true diff --git a/qodana.yaml b/qodana.yaml index 5505d1b..8ba2ea8 100644 --- a/qodana.yaml +++ b/qodana.yaml @@ -1,4 +1,4 @@ -# Qodana for .NET (Ultimate licence), run by .github/workflows/qodana.yml. +# Qodana for .NET (Ultimate licence), run by .gitea/workflows/qodana.yml. version: "1.0" # Native mode: analyses with the .NET SDK installed on the runner instead of the one bundled in the Docker image. @@ -8,8 +8,8 @@ withinDocker: false dotnet: solution: HashTool.slnx -# The shipped code. Tests and benchmarks are checked by the compiler, the analyzers and SonarCloud; the legacy client is -# pinned to Velopack 0.0.1298 on purpose (the release upgrade gate runs it like a Hash Tool 1.1.x client). +# The shipped code. Tests and benchmarks are checked by the compiler and the analyzers; the legacy client is pinned to +# Velopack 0.0.1298 on purpose (it reads a feed like a Hash Tool 1.1.x client). exclude: - name: All paths: @@ -25,7 +25,7 @@ profile: - "category:C#/Roslyn Analyzers" inspections: # Roslyn analyzers (Meziantou, .NET, CommunityToolkit.Mvvm) already run in every build, where their warnings fail - # CI; their suggestions are not repeated here (SonarCloud ignores them too). + # CI; their suggestions are not repeated here. - group: RoslynAnalyzers enabled: false # Translations may equal the English text: en-GB/en-IN/en-SG, product and technical names. -- 2.54.1 From 16207acab322983b7a9f60e8330ada910cd9ed4b Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 10:59:19 +0700 Subject: [PATCH 03/17] =?UTF-8?q?ci:=20Security=20workflow=20=E2=80=94=20p?= =?UTF-8?q?ackages,=20licences,=20workflow=20lint=20and=20the=20ops=20scan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The local checks stay (vulnerable NuGet packages, licences of the shipped projects) and the workflow lint now covers .gitea/workflows: zizmor offline from a hash-locked requirements file, actionlint and shellcheck as pinned, SHA-256 checked binaries. The ops repo's security.yml replaces CodeQL and the gitleaks action: gitleaks over the full history, Opengrep for C# and Python, osv-scanner and a NuGetAudit restore. Weekly run moved to Monday 13:43 UTC, the slot the ops cron registry gives this repository. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/security.yml | 158 +++++++++++++++++++++++++++++++++ .github/actionlint.yaml | 10 +++ .github/requirements-ci.in | 2 + .github/requirements-ci.txt | 17 ++++ .github/workflows/security.yml | 119 ------------------------- .github/zizmor.yml | 10 ++- 6 files changed, 196 insertions(+), 120 deletions(-) create mode 100644 .gitea/workflows/security.yml create mode 100644 .github/actionlint.yaml create mode 100644 .github/requirements-ci.in create mode 100644 .github/requirements-ci.txt delete mode 100644 .github/workflows/security.yml diff --git a/.gitea/workflows/security.yml b/.gitea/workflows/security.yml new file mode 100644 index 0000000..b1c8bcd --- /dev/null +++ b/.gitea/workflows/security.yml @@ -0,0 +1,158 @@ +name: Security + +# Gitea has no CodeQL, no dependency review and no code-scanning UI (ops runbook §1, migration decision D7). This +# workflow covers instead: +# +# vulnerable-packages NuGet packages with known advisories, transitive ones included (fails on any severity) +# licenses licences of the shipped projects' packages against eng/allowed-licenses.json +# workflow-lint zizmor, actionlint and shellcheck on .gitea/workflows/*.yml +# scan the ops repo's security.yml: gitleaks over the full history, Opengrep (C# and Python rules; +# report only, SARIF as an artifact), osv-scanner (lockfiles; this repo has none) and a +# NuGetAudit restore that fails on high/critical advisories +# +# Weekly as well, so a new advisory against unchanged dependencies turns it red: Monday 13:43 UTC = 20:43 Vietnam +# (this repo's 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: "43 13 * * 1" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: security-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + AVALONIA_TELEMETRY_OPTOUT: 1 + +jobs: + # `dotnet package list --vulnerable` always exits 0, so the JSON report is checked explicitly. + vulnerable-packages: + name: vulnerable-packages + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 + with: + global-json-file: global.json + + - name: Restore + run: dotnet restore HashTool.slnx + + - name: List vulnerable packages + run: | + dotnet package list --project HashTool.slnx --vulnerable --include-transitive --format json > vulnerable.json + jq -r '.projects[]? | .path as $p | .frameworks[]? | (.topLevelPackages[]?, .transitivePackages[]?) + | select((.vulnerabilities // []) | length > 0) + | "\($p): \(.id) \(.resolvedVersion) - \([.vulnerabilities[].severity] | join(", ")) \([.vulnerabilities[].advisoryurl] | join(" "))"' vulnerable.json \ + | sort -u | tee vulnerable.txt + if [ -s vulnerable.txt ]; then + echo "::error::Vulnerable NuGet packages found (see above)." + exit 1 + fi + echo "No known vulnerable packages." + + # Only shipped projects are checked; test and benchmark tools are not redistributed. + licenses: + name: licenses + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 + with: + global-json-file: global.json + + - name: Restore + run: | + dotnet tool restore + dotnet restore HashTool.slnx + + - name: Check licenses + run: >- + dotnet nuget-license -ji eng/license-inputs.json -t + -a eng/allowed-licenses.json -o Markdown + + # The linters without Docker: actionlint and shellcheck as release binaries at pinned versions, SHA-256 verified (the + # pins of the ops repo's ops-lint.yml), zizmor from the hash-locked .github/requirements-ci.txt. Renovate does not + # update the binaries: bump version and checksum together, by hand. + workflow-lint: + name: 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 + + - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 + with: + python-version: "3.12" + + - name: Install zizmor + run: python -m pip install --quiet --require-hashes --only-binary :all: -r .github/requirements-ci.txt + + # The files by name: zizmor only looks for .github/workflows by itself. Offline: its online audits ask GitHub's + # API about the actions, with a token this runner does not have. Any finding at medium or above fails. + - name: zizmor (workflow security audit) + run: zizmor --offline --min-severity medium --config .github/zizmor.yml .gitea/workflows/*.yml + + - 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" + + # .github/actionlint.yaml ignores only the Gitea features actionlint does not know; everything else is 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-solution: HashTool.slnx + # eng/*.py: localisation, release notes, release and coverage checks. + python: true diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 0000000..40fbdd9 --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,10 @@ +# actionlint settings (.gitea/workflows/security.yml, job `workflow-lint`, and a local `actionlint` run from the +# repository root), as in the ops repo poli0981/.github. Only Gitea features that actionlint does not know are ignored; +# 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' diff --git a/.github/requirements-ci.in b/.github/requirements-ci.in new file mode 100644 index 0000000..a022e9c --- /dev/null +++ b/.github/requirements-ci.in @@ -0,0 +1,2 @@ +# Workflow security linter for .gitea/workflows/security.yml; requirements-ci.txt pins it with hashes. +zizmor==1.32.0 diff --git a/.github/requirements-ci.txt b/.github/requirements-ci.txt new file mode 100644 index 0000000..5e9c126 --- /dev/null +++ b/.github/requirements-ci.txt @@ -0,0 +1,17 @@ +# Hash-locked tools for .gitea/workflows/security.yml (job workflow-lint). zizmor ships one binary wheel per platform +# and has no dependencies. To update: change the pin in requirements-ci.in, then +# uv pip compile .github/requirements-ci.in --generate-hashes --python-platform x86_64-manylinux_2_28 --python-version 3.12 -o .github/requirements-ci.txt +zizmor==1.32.0 \ + --hash=sha256:0a999c98015becd9f69919ce01febadfb1c2be9b8ec2ce9ef7eb13ff23ba8eba \ + --hash=sha256:0cdd38fca6eb34ceb567548548d706332e3535ea66894b9168c048e03207b68c \ + --hash=sha256:3f404b26791ed06a5ea9eaa0bfd5b973fc5228bac7db8b3c5ec7f0c7ad2ed16d \ + --hash=sha256:84a6acb975accc13408786a2bd274b572537ca19c933ebbc13e78f3988562071 \ + --hash=sha256:913fd3943bc1358aa6e23b33fe01cc98bf67af23985258b8fbf24eaa2f8728ea \ + --hash=sha256:9cd1dd7734042f40ca0faa2a31fb4e9033dede620d996af2f903744b8f04fca9 \ + --hash=sha256:aa4b4e216321dd5cf202cd79fc83296468f0eed79d850cd65ac8187a6bbc5496 \ + --hash=sha256:bddcdb0e37d1aa53c9f831c55627a5829d0d552cb0afb4b80fbe16a3a3140366 \ + --hash=sha256:d34dcfa702875202b4163d90ebb9cc5222f3d1a7d4b72bf796d87b5a15b24194 \ + --hash=sha256:dd818f99d833b86cd432d5412d620d936b5df074b33404fff8b67acff55d3259 \ + --hash=sha256:eaedf57859f026a0a7da2a6b574517b1fe01e256c6875b3319a06ee1cee026a7 \ + --hash=sha256:f0b664d394576e08605fe8094e8e992056d74b808f30c0c9ca9ed227001dcf67 + # via -r .github/requirements-ci.in diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml deleted file mode 100644 index 1507a0f..0000000 --- a/.github/workflows/security.yml +++ /dev/null @@ -1,119 +0,0 @@ -name: Security - -on: - push: - branches: [main] - pull_request: - schedule: - - cron: "23 4 * * 1" - workflow_dispatch: - -permissions: {} - -concurrency: - group: security-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - AVALONIA_TELEMETRY_OPTOUT: 1 - -jobs: - # `dotnet package list --vulnerable` always exits 0, so the JSON report is checked explicitly. - vulnerable-packages: - name: vulnerable-packages - runs-on: ubuntu-latest - timeout-minutes: 15 - permissions: - contents: read - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 - with: - dotnet-version: 10.0.4xx - - - name: Restore - run: dotnet restore HashTool.slnx - - - name: List vulnerable packages - run: | - dotnet package list --project HashTool.slnx --vulnerable --include-transitive --format json > vulnerable.json - jq -r '.projects[]? | .path as $p | .frameworks[]? | (.topLevelPackages[]?, .transitivePackages[]?) - | select((.vulnerabilities // []) | length > 0) - | "\($p): \(.id) \(.resolvedVersion) - \([.vulnerabilities[].severity] | join(", ")) \([.vulnerabilities[].advisoryurl] | join(" "))"' vulnerable.json \ - | sort -u | tee vulnerable.txt - if [ -s vulnerable.txt ]; then - echo "::error::Vulnerable NuGet packages found (see above)." - exit 1 - fi - echo "No known vulnerable packages." - - # Only shipped projects are checked; test and benchmark tools are not redistributed. - licenses: - name: licenses - runs-on: ubuntu-latest - timeout-minutes: 15 - permissions: - contents: read - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 - with: - dotnet-version: 10.0.4xx - - - name: Restore - run: | - dotnet tool restore - dotnet restore HashTool.slnx - - - name: Check licenses - run: > - dotnet nuget-license -ji eng/license-inputs.json -t - -a eng/allowed-licenses.json -o Markdown - - secrets: - name: secrets - runs-on: ubuntu-latest - timeout-minutes: 15 - permissions: - contents: read - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - persist-credentials: false - - - uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0 - env: - GITHUB_TOKEN: ${{ github.token }} - GITLEAKS_ENABLE_COMMENTS: false - GITLEAKS_ENABLE_UPLOAD_ARTIFACT: false - - workflows: - name: workflows - runs-on: ubuntu-latest - timeout-minutes: 15 - permissions: - contents: read - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - # Built from source through the Go module proxy, which verifies it against the checksum database. - - name: actionlint - run: go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 -color - - - name: zizmor - uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1 - with: - version: 1.31.1 - config: .github/zizmor.yml - advanced-security: false diff --git a/.github/zizmor.yml b/.github/zizmor.yml index eac5e16..75e3369 100644 --- a/.github/zizmor.yml +++ b/.github/zizmor.yml @@ -1,7 +1,15 @@ +# zizmor (workflow security linter), run offline by .gitea/workflows/security.yml (job `workflow-lint`). rules: + unpinned-uses: + config: + policies: + # Every action and every call into the ops repo (poli0981/.github) is pinned to a full commit SHA. Renovate bumps + # the actions; the ops pins are bumped by hand when the ops repo is tagged (its runbook §3.2). + "*": hash-pin dangerous-triggers: ignore: # workflow_run is the only way to report other workflows' results. These jobs check out no code from the - # triggering run, only call the maintainer's pinned notifier, and are limited to this repository's own runs. + # triggering run, only call the maintainer's pinned notifier, and pass every untrusted field (branch, commit + # message, actor) to it through `env:`, never by interpolation. - notify-ci-failure.yml - notify-release-pipeline.yml -- 2.54.1 From 96a970d70251c12a7882c27762f08045516e9886 Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 11:00:00 +0700 Subject: [PATCH 04/17] ci(qodana): run the Qodana CLI through the ops reusable workflow JetBrains/qodana-action needs GitHub's APIs. The ops repo's reusable-qodana.yml runs the same linter (qodana-dotnet, native mode, settings in qodana.yaml) on windows-latest, the path verified with CommandForge, and keeps the report as an artifact and in Qodana Cloud. Weekly run on Thursday 13:53 UTC. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/qodana.yml | 44 ++++++++++++++++++ .github/workflows/qodana.yml | 86 ------------------------------------ 2 files changed, 44 insertions(+), 86 deletions(-) create mode 100644 .gitea/workflows/qodana.yml delete mode 100644 .github/workflows/qodana.yml diff --git a/.gitea/workflows/qodana.yml b/.gitea/workflows/qodana.yml new file mode 100644 index 0000000..2ea9041 --- /dev/null +++ b/.gitea/workflows/qodana.yml @@ -0,0 +1,44 @@ +name: Qodana + +# JetBrains Qodana for .NET (`qodana-dotnet`, Ultimate licence of the Qodana Cloud project) over the whole solution; +# every setting is in qodana.yaml (native mode, profile, gate: no critical or high 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). The pull request comment and the annotations of the GitHub days are gone. +# +# - Native mode on `windows-latest` (host mode on the maintainer's PC), the path the ops repo verified with +# CommandForge; the linter reads the projects with the SDK global.json names. +# - Advisory: not a required check, 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). +# - Weekly as well: Thursday 13:53 UTC = 20:53 Vietnam (this repo's slot in the ops cron registry). +# Requires the repository secret QODANA_TOKEN. + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: "53 13 * * 4" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: qodana-${{ 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 restore HashTool.slnx + 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 fc500a5..0000000 --- a/.github/workflows/qodana.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: Qodana - -# JetBrains Qodana for .NET (linter qodana-dotnet, Ultimate licence) in native mode: the solution is analysed with the -# .NET SDK installed by setup-dotnet, as CI builds it (configuration in qodana.yaml). Results go to Qodana Cloud (the -# token selects the project), to check annotations, to a pull request comment and to the qodana-report artifact. -# Pull requests analyse the files they change; pushes to main, the weekly run and manual runs analyse everything. -# Not a required check. -on: - push: - branches: [main] - pull_request: - branches: [main] - schedule: - - cron: "37 4 * * 4" - workflow_dispatch: - -permissions: {} - -concurrency: - group: qodana-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -env: - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - AVALONIA_TELEMETRY_OPTOUT: 1 - -jobs: - # Pull requests from forks and from Dependabot get no repository secrets: skip the analysis instead of failing it. - token: - name: 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); analysis skipped." - fi - - qodana: - name: qodana - needs: token - if: needs.token.outputs.available == 'true' - runs-on: ubuntu-latest - timeout-minutes: 45 - permissions: - contents: read - # Annotations on the changed lines and a comment with the results on pull requests. - checks: write - pull-requests: write - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - # Pull requests: the head commit rather than the merge commit, so findings point at the changed lines. The - # full history lets the pull request mode compare with the base branch. - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - persist-credentials: false - - # Native mode analyses with this SDK (global.json picks the version), installed where the linter looks for it. - - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 - with: - dotnet-version: 10.0.4xx - - - name: Restore - run: dotnet restore HashTool.slnx - - - name: Qodana scan - uses: JetBrains/qodana-action@3e8d76ff0e0241618abd808682f426afe84bab3f # v2026.2.2 - with: - upload-result: true - cache-default-branch-only: true - env: - QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} - QODANA_ENDPOINT: https://qodana.cloud -- 2.54.1 From 59afbbe27e8e62b0051f4a40e4134ebb41e74f60 Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 11:00:00 +0700 Subject: [PATCH 05/17] ci: Discord notifiers through the ops repo's Gitea workflows The three callers pin ops v2026.11.4 under .gitea/workflows and pass ops_ref, so the notifier script matches the workflow. CI failures cover CI, Security and Qodana; the GitHub-only Scorecard and SonarCloud are gone. The reusables do the filtering themselves (default branch only, release runs started by hand). Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/announce-release.yml | 35 +++++++++++++++++++ .gitea/workflows/notify-ci-failure.yml | 27 ++++++++++++++ .gitea/workflows/notify-release-pipeline.yml | 26 ++++++++++++++ .github/workflows/announce-release.yml | 26 -------------- .github/workflows/notify-ci-failure.yml | 22 ------------ .github/workflows/notify-release-pipeline.yml | 19 ---------- 6 files changed, 88 insertions(+), 67 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 delete mode 100644 .github/workflows/notify-release-pipeline.yml diff --git a/.gitea/workflows/announce-release.yml b/.gitea/workflows/announce-release.yml new file mode 100644 index 0000000..84dc642 --- /dev/null +++ b/.gitea/workflows/announce-release.yml @@ -0,0 +1,35 @@ +name: Announce Release to Discord + +# Posts a release to Discord through the ops repo's announce-release.yml, which reads the release from the Gitea API. +# +# Releases made by the Release workflow are announced from there: 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 +# published by hand in the UI, and re-announcements: Actions → Announce Release to Discord → Run workflow, with the tag. +# Secrets: DISCORD_RELEASES_WEBHOOK and DISCORD_REPO_WEBHOOK; optional DISCORD_PING_ROLE_ID. + +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: "Existing release tag to announce, without a v (e.g. 1.3.1)" + 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..9d1bf71 --- /dev/null +++ b/.gitea/workflows/notify-ci-failure.yml @@ -0,0 +1,27 @@ +name: Notify CI Failures + +# 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: [CI, Security, Qodana] + 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..25cb363 --- /dev/null +++ b/.gitea/workflows/notify-release-pipeline.yml @@ -0,0 +1,26 @@ +name: Notify Release Pipeline + +# Every finished run of release.yml started by hand (success, failure or cancelled; never a pull request dry run) 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 9df8569..0000000 --- a/.github/workflows/announce-release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Announce Release to Discord - -# Releases published by the Release workflow are announced from there (events created with GITHUB_TOKEN do not start -# other workflows). This covers releases published by hand and re-announcements. -on: - release: - types: [published] - workflow_dispatch: - inputs: - tag: - description: "Existing release tag to re-announce" - required: true - type: string - -permissions: {} - -jobs: - announce: - permissions: - contents: read - uses: poli0981/.github/.github/workflows/announce-release.yml@c3e118a01d40e95b36b2c3466dc206638c11eb5a - with: - tag_override: ${{ inputs.tag || '' }} - secrets: - DISCORD_RELEASES_WEBHOOK: ${{ secrets.DISCORD_RELEASES_WEBHOOK }} - DISCORD_REPO_WEBHOOK: ${{ secrets.DISCORD_REPO_WEBHOOK }} diff --git a/.github/workflows/notify-ci-failure.yml b/.github/workflows/notify-ci-failure.yml deleted file mode 100644 index 756d02f..0000000 --- a/.github/workflows/notify-ci-failure.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Notify CI Failures - -on: - workflow_run: - workflows: [CI, Security, Scorecard, SonarCloud] - types: [completed] - -permissions: {} - -jobs: - notify: - # Failures on this repository's own pushes and schedules only; fork pull requests cannot trigger a message. - if: > - github.event.workflow_run.conclusion == 'failure' && - github.event.workflow_run.head_repository.full_name == github.repository && - contains(fromJSON('["push", "schedule", "workflow_dispatch"]'), github.event.workflow_run.event) - permissions: - contents: read - actions: read - uses: poli0981/.github/.github/workflows/notify-ci-failure.yml@c3e118a01d40e95b36b2c3466dc206638c11eb5a - secrets: - DISCORD_CI_WEBHOOK: ${{ secrets.DISCORD_CI_WEBHOOK }} diff --git a/.github/workflows/notify-release-pipeline.yml b/.github/workflows/notify-release-pipeline.yml deleted file mode 100644 index 4d2f35c..0000000 --- a/.github/workflows/notify-release-pipeline.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Notify Release Pipeline - -on: - workflow_run: - workflows: [Release] - types: [completed] - -permissions: {} - -jobs: - notify: - # Only real releases (started by hand), never pull request dry runs. - if: github.event.workflow_run.event == 'workflow_dispatch' - permissions: - contents: read - actions: read - uses: poli0981/.github/.github/workflows/notify-release-pipeline.yml@c3e118a01d40e95b36b2c3466dc206638c11eb5a - secrets: - DISCORD_RELEASE_PIPELINE_WEBHOOK: ${{ secrets.DISCORD_RELEASE_PIPELINE_WEBHOOK }} -- 2.54.1 From cf839d8703838625d2d9ff0b6c8a06e4aa5a4d7c Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 11:04:26 +0700 Subject: [PATCH 06/17] ci(security): the zizmor install command as a block scalar ":all: -r" on a plain scalar is a YAML mapping, so actionlint and zizmor could not parse the workflow. Co-Authored-By: Claude Opus 5.5 --- {.github => .gitea}/workflows/release.yml | 0 .gitea/workflows/security.yml | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename {.github => .gitea}/workflows/release.yml (100%) diff --git a/.github/workflows/release.yml b/.gitea/workflows/release.yml similarity index 100% rename from .github/workflows/release.yml rename to .gitea/workflows/release.yml diff --git a/.gitea/workflows/security.yml b/.gitea/workflows/security.yml index b1c8bcd..b451027 100644 --- a/.gitea/workflows/security.yml +++ b/.gitea/workflows/security.yml @@ -117,7 +117,8 @@ jobs: python-version: "3.12" - name: Install zizmor - run: python -m pip install --quiet --require-hashes --only-binary :all: -r .github/requirements-ci.txt + run: | + python -m pip install --quiet --require-hashes --only-binary :all: -r .github/requirements-ci.txt # The files by name: zizmor only looks for .github/workflows by itself. Offline: its online audits ask GitHub's # API about the actions, with a token this runner does not have. Any finding at medium or above fails. -- 2.54.1 From d2cd505935ec5c5bbc18d1caec02080096d31867 Mon Sep 17 00:00:00 2001 From: poli0981 Date: Thu, 26 Nov 2026 11:04:27 +0700 Subject: [PATCH 07/17] ci(release): Velopack and the CLI to Cloudflare R2, Gitea release Releases are still started by hand (version, publish) and every pull request that touches the release machinery gets a dry run, but they now build on Gitea: win on the maintainer's PC (host mode, PowerShell, the app's data in the job's temp folder), linux and the Linux CLI in Docker. macOS is no longer built (no runner, migration decision D9). Publishing puts the CLI archives, two CycloneDX SBOMs and SHA256SUMS under releases.poli0981.dev/hashtool// with rclone (immutable, checksum verified, pinned like the ops publish-r2.yml, which only runs on tag refs), then `vpk upload s3` publishes each channel's packages and its feed last. The release job checks every public file and both feeds, then creates the Gitea release (notes and links, no binaries), which creates the tag, and the ops announcer posts it. SHA256SUMS lists only the files this version ships, not the feeds that every upload rewrites. The upgrade gate is gone: the 1.1.3 portables it needed lived on GitHub, and 1.x clients read GitHub's feed, so they never reach R2 anyway (HT2). tests/Compat/LegacyClient stays for a possible bridge release. Build provenance attestations go too (no OIDC on Gitea, D7). Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/release.yml | 642 ++++++++++++++++++++++------------- 1 file changed, 405 insertions(+), 237 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index f2d1eb6..66dc0f0 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -1,30 +1,57 @@ name: Release -# Builds, packages and tests every platform; publishes only when started by hand with publish=true. -# Pull requests that touch the release machinery get a full dry run (nothing is published). +# Builds, packages and tests every platform; publishes only when started by hand on main with publish=true +# (docs/RELEASING.md; ops runbook poli0981/.github docs/GITEA-MIGRATION.md §3.3 and §5.1). +# +# prepare version checks, release notes from CHANGELOG.md +# app self-contained single-file build, headless smoke test, `vpk pack` (channels win and linux) +# cli NativeAOT `hashtool` for win-x64 and linux-x64 +# check eng/assert-release.py: the Velopack identity 1.x clients rely on +# publish CycloneDX SBOMs and SHA256SUMS; rclone puts them and the CLI archives under hashtool// on +# Cloudflare R2, then `vpk upload s3` publishes the linux packages and feed +# publish-win `vpk upload s3` for the win channel, from Windows (the platform that packed it) +# release checks the public files, then a Gitea release with the notes and the links (no binaries: the forge's +# disk is not for them, runbook §1); the release creates the tag (the version, no `v`) +# announce Discord, through the ops repo: a release made with the job token fires no `release` event +# +# Everything is served from https://releases.poli0981.dev/hashtool, where 1.3.1 and later look for updates. Versioned +# files go up first and the feeds (releases..json) last, so a client never sees a feed whose files are missing. +# A file uploaded under a versioned name is never replaced (rclone --immutable): to ship a fix, bump the version. +# +# A dispatched run with publish unchecked, and every pull request that touches the release machinery, is a DRY RUN: it +# builds, packs, smoke-tests and checks everything and uploads nothing. Release credentials (user-level secrets +# R2_RELEASES_ACCESS_KEY_ID / R2_RELEASES_SECRET_ACCESS_KEY, variable R2_ACCOUNT_ID) appear only in the publish jobs, +# which run only for workflow_dispatch with publish=true (runbook §2 rule 10), and only as environment variables. +# +# Runners: `windows-latest` is HOST MODE on the maintainer's PC (PowerShell; the app runs with HASHTOOL_DATA_DIR in the +# job's temp folder; nothing is installed), `ubuntu-*` are Docker. There is no macOS runner: the osx and osx-x64 +# channels are no longer built (migration decision D9). No dependency caches: a poisoned cache could end up in a +# package. No build-provenance attestations (no OIDC on Gitea, D7). + on: workflow_dispatch: inputs: version: - description: "Version without a leading v, e.g. 1.2.0 (must match Directory.Build.props to publish)" + description: "Version without a leading v, e.g. 1.3.1 (must match Directory.Build.props to publish)" required: true type: string publish: - description: "Publish the GitHub release (unchecked = dry run)" + description: "Publish to releases.poli0981.dev and create the Gitea release (unchecked = dry run)" required: true type: boolean default: false pull_request: + branches: [main] paths: - - .github/workflows/release.yml + - .gitea/workflows/release.yml # vpk and CycloneDX versions. - .config/dotnet-tools.json - build/** - eng/assert-release.py - eng/release-notes.py - - tests/Compat/** -permissions: {} +permissions: + contents: read concurrency: group: release-${{ github.event.pull_request.number || github.ref }} @@ -33,10 +60,10 @@ concurrency: env: DOTNET_NOLOGO: true DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true AVALONIA_TELEMETRY_OPTOUT: 1 PACK_ID: HashTool - # The release 1.x clients update from in the upgrade gate. - LEGACY_VERSION: 1.1.3 + PUBLIC_BASE: https://releases.poli0981.dev/hashtool jobs: prepare: @@ -59,7 +86,9 @@ jobs: EVENT: ${{ github.event_name }} INPUT_VERSION: ${{ inputs.version }} INPUT_PUBLISH: ${{ inputs.publish }} - GH_TOKEN: ${{ github.token }} + GITEA_TOKEN: ${{ github.token }} + API_URL: ${{ github.api_url }} + R2_ACCOUNT_ID: ${{ vars.R2_ACCOUNT_ID }} run: | set -euo pipefail project=$(sed -n 's:.*\(.*\).*:\1:p' Directory.Build.props) @@ -67,7 +96,7 @@ jobs: version="$INPUT_VERSION" publish="$INPUT_PUBLISH" else - # Pull request dry run: a pre-release above the last release, so the upgrade gate still applies. + # Pull request dry run: a pre-release above the last release. version="$project-ci.$GITHUB_RUN_NUMBER" publish=false fi @@ -84,10 +113,19 @@ jobs: echo "::error::Releases are published from main only (got $GITHUB_REF)" exit 1 fi - if gh release view "$version" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then - echo "::error::Release $version already exists" + if ! [[ "$R2_ACCOUNT_ID" =~ ^[0-9a-f]{32}$ ]]; then + echo "::error::Actions variable R2_ACCOUNT_ID is missing or not a 32-hex Cloudflare account ID" exit 1 fi + # The release creates the tag: neither may exist yet. + for what in releases/tags tags; do + code=$(curl -sS -o /dev/null -w '%{http_code}' -H "Authorization: token $GITEA_TOKEN" \ + "$API_URL/repos/$GITHUB_REPOSITORY/$what/$version") + if [ "$code" != 404 ]; then + echo "::error::$what/$version answered HTTP $code: the release or the tag already exists (or the API failed)" + exit 1 + fi + done fi { echo "version=$version" @@ -107,7 +145,7 @@ jobs: python3 -I eng/release-notes.py "$NOTES_VERSION" "${flags[@]}" > release-notes.md cat release-notes.md - - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + - uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4 with: name: notes path: release-notes.md @@ -120,9 +158,7 @@ jobs: fail-fast: false matrix: include: - - { os: windows-2025, rid: win-x64, channel: win, exe: CheckHash.exe } - - { os: macos-15, rid: osx-arm64, channel: osx, exe: CheckHash } - - { os: macos-15-intel, rid: osx-x64, channel: osx-x64, exe: CheckHash } + - { os: windows-latest, rid: win-x64, channel: win, exe: CheckHash.exe } - { os: ubuntu-24.04, rid: linux-x64, channel: linux, exe: CheckHash } runs-on: ${{ matrix.os }} timeout-minutes: 45 @@ -133,167 +169,87 @@ jobs: RID: ${{ matrix.rid }} CHANNEL: ${{ matrix.channel }} MAIN_EXE: ${{ matrix.exe }} - defaults: - run: - shell: bash steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + - name: Keep .NET SDK installs in the runner tool cache (host mode) + if: runner.os == 'Windows' + 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: - dotnet-version: 10.0.4xx + global-json-file: global.json - - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + - uses: christopherhx/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4 with: name: notes - - name: Install tools - run: | - dotnet tool restore - if [ "$RUNNER_OS" = Linux ]; then sudo apt-get update -q && sudo apt-get install -y -q squashfs-tools; fi + - name: Restore pinned tools (vpk) + run: dotnet tool restore # Same shape as every 1.x release: self-contained single file, CheckHash(.exe) as the main executable. - - name: Publish - run: > - dotnet publish src/HashTool.App/HashTool.App.csproj -c Release -r "$RID" --self-contained - -p:PublishSingleFile=true -p:Version="$VERSION" -o "publish/$RID" + - name: Publish (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: >- + dotnet publish src/HashTool.App/HashTool.App.csproj -c Release -r $env:RID --self-contained + -p:PublishSingleFile=true -p:Version=$env:VERSION -o publish - - name: Smoke test + - name: Publish (Linux) + if: runner.os == 'Linux' + run: >- + dotnet publish src/HashTool.App/HashTool.App.csproj -c Release -r "$RID" --self-contained + -p:PublishSingleFile=true -p:Version="$VERSION" -o publish + + # CheckHash.exe is a GUI-subsystem program: PowerShell only waits for it through Start-Process -Wait. + - name: Smoke test (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + $data = Join-Path $env:RUNNER_TEMP 'smoke-data' + $out = Join-Path $env:RUNNER_TEMP 'smoke.json' + $env:HASHTOOL_DATA_DIR = $data + $p = Start-Process -FilePath (Resolve-Path "publish/$env:MAIN_EXE") -Wait -PassThru -NoNewWindow ` + -ArgumentList '--smoke-test', '--smoke-out', "`"$out`"", '--expect-version', $env:VERSION + if (Test-Path -LiteralPath $out) { Get-Content -LiteralPath $out } + if ($p.ExitCode -ne 0) { Write-Host "::error::Smoke test failed with exit code $($p.ExitCode)"; exit $p.ExitCode } + + - name: Smoke test (Linux) + if: runner.os == 'Linux' env: - HASHTOOL_DATA_DIR: ${{ runner.temp }}/smoke - run: '"publish/$RID/$MAIN_EXE" --smoke-test --expect-version "$VERSION"' + HASHTOOL_DATA_DIR: ${{ runner.temp }}/smoke-data + run: '"publish/$MAIN_EXE" --smoke-test --expect-version "$VERSION"' - name: Pack (Windows) if: runner.os == 'Windows' - run: > - dotnet vpk pack -u "$PACK_ID" -v "$VERSION" -p "publish/$RID" -e "$MAIN_EXE" -c "$CHANNEL" -r "$RID" + shell: pwsh + run: >- + dotnet vpk pack -u $env:PACK_ID -v $env:VERSION -p publish -e $env:MAIN_EXE -c $env:CHANNEL -r $env:RID --icon src/HashTool.App/Assets/icon/favicon.ico --delta None --releaseNotes release-notes.md -o Releases - # The custom Info.plist keeps the 1.x bundle identity and adds "Open With" document types. - - name: Pack (macOS) - if: runner.os == 'macOS' - run: | - sed "s/@VERSION@/$VERSION/g" build/macos/Info.plist > "$RUNNER_TEMP/Info.plist" - plutil -lint "$RUNNER_TEMP/Info.plist" - dotnet vpk pack -u "$PACK_ID" -v "$VERSION" -p "publish/$RID" -e "$MAIN_EXE" -c "$CHANNEL" -r "$RID" \ - --packTitle "Hash Tool" --plist "$RUNNER_TEMP/Info.plist" \ - --icon src/HashTool.App/Assets/icon/icons.icns --delta None --releaseNotes release-notes.md -o Releases - - name: Pack (Linux) if: runner.os == 'Linux' - run: > - dotnet vpk pack -u "$PACK_ID" -v "$VERSION" -p "publish/$RID" -e "$MAIN_EXE" -c "$CHANNEL" -r "$RID" - --packTitle "Hash Tool" --icon build/linux/hashtool.png --categories Utility - --delta None --releaseNotes release-notes.md -o Releases - - - name: Check packages run: | - bundle_id=() - if [ "$RUNNER_OS" = macOS ]; then bundle_id=(com.HashTool.HashTool); fi - python3 -I eng/assert-release.py Releases "$CHANNEL" "$VERSION" "$MAIN_EXE" "${bundle_id[@]}" + set -euo pipefail + # mksquashfs builds the AppImage. The job container runs as root; sudo only where the image has it. + if command -v sudo > /dev/null; then sudo apt-get update -q && sudo apt-get install -y -q squashfs-tools + else apt-get update -q && apt-get install -y -q squashfs-tools; fi + dotnet vpk pack -u "$PACK_ID" -v "$VERSION" -p publish -e "$MAIN_EXE" -c "$CHANNEL" -r "$RID" \ + --packTitle "Hash Tool" --icon build/linux/hashtool.png --categories Utility \ + --delta None --releaseNotes release-notes.md -o Releases - - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + - uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4 with: name: release-${{ matrix.channel }} path: Releases/* if-no-files-found: error retention-days: 7 - # Updates a real Hash Tool 1.1.3 with its own Velopack 0.0.1298 library and updater, then starts the result. - upgrade-gate: - name: upgrade-gate (${{ matrix.channel }}) - needs: [prepare, app] - strategy: - fail-fast: false - matrix: - include: - - { os: windows-2025, channel: win } - - { os: macos-15, channel: osx } - runs-on: ${{ matrix.os }} - timeout-minutes: 30 - permissions: - contents: read - env: - VERSION: ${{ needs.prepare.outputs.version }} - CHANNEL: ${{ matrix.channel }} - GH_TOKEN: ${{ github.token }} - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 - with: - dotnet-version: 10.0.4xx - - - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - name: release-${{ matrix.channel }} - path: Releases - - - name: Install Hash Tool ${{ env.LEGACY_VERSION }} (portable) - run: | - set -euo pipefail - gh release download "$LEGACY_VERSION" --repo "$GITHUB_REPOSITORY" -p "HashTool-$CHANNEL-Portable.zip" -D "$RUNNER_TEMP" - mkdir -p "$RUNNER_TEMP/legacy" - if [ "$RUNNER_OS" = macOS ]; then - ditto -x -k "$RUNNER_TEMP/HashTool-$CHANNEL-Portable.zip" "$RUNNER_TEMP/legacy" - root="$RUNNER_TEMP/legacy/Hash Tool.app" - app="$root/Contents/MacOS" - update="$app/UpdateMac" - exe="$app/CheckHash" - else - unzip -q "$RUNNER_TEMP/HashTool-$CHANNEL-Portable.zip" -d "$RUNNER_TEMP/legacy" - root="$RUNNER_TEMP/legacy" - app="$root/current" - update="$root/Update.exe" - exe="$app/CheckHash.exe" - fi - ls -la "$app" - test -x "$update" -o -f "$update" - { - echo "LEGACY_ROOT=$root" - echo "LEGACY_APP=$app" - echo "LEGACY_UPDATE=$update" - echo "LEGACY_EXE=$exe" - } >> "$GITHUB_ENV" - - - name: Find and download the update with Velopack 0.0.1298 - run: | - set -euo pipefail - package=$(dotnet run --project tests/Compat/LegacyClient -c Release -- \ - "$PWD/Releases" "$CHANNEL" "$LEGACY_VERSION" "$VERSION" "$LEGACY_ROOT" "$LEGACY_APP" "$LEGACY_UPDATE" "$RUNNER_TEMP/packages") - echo "UPDATE_PACKAGE=$package" >> "$GITHUB_ENV" - - - name: Apply with the ${{ env.LEGACY_VERSION }} updater - run: | - "$LEGACY_UPDATE" --silent --verbose --log "$RUNNER_TEMP/update.log" apply --package "$UPDATE_PACKAGE" --norestart - # The updater may finish its work in a child process; wait for the new version to appear. - for _ in $(seq 1 60); do - if grep -q "applied successfully" "$RUNNER_TEMP/update.log" 2> /dev/null; then break; fi - sleep 2 - done - tail -n 40 "$RUNNER_TEMP/update.log" - - - name: Start the updated app - env: - HASHTOOL_DATA_DIR: ${{ runner.temp }}/smoke - run: '"$LEGACY_EXE" --smoke-test --expect-version "$VERSION"' - - - name: Upload updater log - if: failure() - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: upgrade-gate-log-${{ matrix.channel }} - path: ${{ runner.temp }}/update.log - if-no-files-found: ignore - retention-days: 7 - cli: name: cli (${{ matrix.rid }}) needs: prepare @@ -301,11 +257,10 @@ jobs: fail-fast: false matrix: include: - - { os: windows-2025, rid: win-x64, exe: hashtool.exe } - - { os: macos-15, rid: osx-arm64, exe: hashtool } - - { os: macos-15-intel, rid: osx-x64, exe: hashtool } + # NativeAOT links with the MSVC Build Tools installed on the PC. + - { os: windows-latest, rid: win-x64 } # Built on the oldest supported Ubuntu so the native binary runs on older glibc. - - { os: ubuntu-22.04, rid: linux-x64, exe: hashtool } + - { os: ubuntu-22.04, rid: linux-x64 } runs-on: ${{ matrix.os }} timeout-minutes: 30 permissions: @@ -313,73 +268,136 @@ jobs: env: VERSION: ${{ needs.prepare.outputs.version }} RID: ${{ matrix.rid }} - EXE: ${{ matrix.exe }} - defaults: - run: - shell: bash + CLI_NAME: hashtool-${{ needs.prepare.outputs.version }}-${{ matrix.rid }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + - name: Keep .NET SDK installs in the runner tool cache (host mode) + if: runner.os == 'Windows' + 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: - dotnet-version: 10.0.4xx + global-json-file: global.json - name: Install native toolchain (Linux) if: runner.os == 'Linux' - run: sudo apt-get update -q && sudo apt-get install -y -q clang zlib1g-dev + run: | + if command -v sudo > /dev/null; then sudo apt-get update -q && sudo apt-get install -y -q clang zlib1g-dev + else apt-get update -q && apt-get install -y -q clang zlib1g-dev; fi - - name: Publish (NativeAOT) + - name: Publish (NativeAOT, Windows) + if: runner.os == 'Windows' + shell: pwsh + run: dotnet publish src/HashTool.Cli/HashTool.Cli.csproj -c Release -r $env:RID -p:Version=$env:VERSION -o cli + + - name: Publish (NativeAOT, Linux) + if: runner.os == 'Linux' + run: dotnet publish src/HashTool.Cli/HashTool.Cli.csproj -c Release -r "$RID" -p:Version="$VERSION" -o cli + + - name: Test and archive (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + function Fail([string]$msg) { Write-Host "::error::$msg"; exit 1 } + Remove-Item cli/*.pdb -ErrorAction SilentlyContinue + Copy-Item LICENSE cli/ + $bin = Resolve-Path cli/hashtool.exe + $v = & $bin --version + if ($LASTEXITCODE -ne 0 -or $v -ne $env:VERSION) { Fail "hashtool --version printed '$v', expected $($env:VERSION)" } + $file = Join-Path $env:RUNNER_TEMP 'check.txt' + [IO.File]::WriteAllText($file, '123456789') + $crc = & $bin hash -a crc32 $file + if ($LASTEXITCODE -ne 0 -or "$crc" -notmatch '^cbf43926 ') { Fail "hashtool hash -a crc32 printed '$crc'" } + & $bin check $file -e 15e2b0d3c33891ebb0f1ef609ec419420c20e320ce94c65fbc8c3312448eb225 + if ($LASTEXITCODE -ne 0) { Fail 'hashtool check failed' } + New-Item -ItemType Directory -Force dist, "staging/$env:CLI_NAME" | Out-Null + Copy-Item cli/* "staging/$env:CLI_NAME/" + Compress-Archive -Path "staging/$env:CLI_NAME" -DestinationPath "dist/$env:CLI_NAME.zip" + Get-ChildItem dist, "staging/$env:CLI_NAME" + + - name: Test and archive (Linux) + if: runner.os == 'Linux' run: | set -euo pipefail - name="hashtool-$VERSION-$RID" - dotnet publish src/HashTool.Cli/HashTool.Cli.csproj -c Release -r "$RID" -p:Version="$VERSION" -o "cli/$name" - rm -rf "cli/$name"/*.pdb "cli/$name"/*.dbg "cli/$name"/*.dSYM - cp LICENSE "cli/$name/" - ls -la "cli/$name" - echo "CLI_NAME=$name" >> "$GITHUB_ENV" - - - name: Test the binary - run: | - set -euo pipefail - bin="cli/$CLI_NAME/$EXE" + rm -rf cli/*.pdb cli/*.dbg + cp LICENSE cli/ + bin=cli/hashtool test "$("$bin" --version)" = "$VERSION" printf '123456789' > "$RUNNER_TEMP/check.txt" "$bin" hash -a crc32 "$RUNNER_TEMP/check.txt" | grep -q '^cbf43926 ' "$bin" check "$RUNNER_TEMP/check.txt" -e 15e2b0d3c33891ebb0f1ef609ec419420c20e320ce94c65fbc8c3312448eb225 + mkdir -p dist staging + cp -r cli "staging/$CLI_NAME" + tar -czf "dist/$CLI_NAME.tar.gz" -C staging "$CLI_NAME" + ls -la dist "staging/$CLI_NAME" - - name: Archive - run: | - set -euo pipefail - mkdir -p dist - if [ "$RUNNER_OS" = Windows ]; then - pwsh -NoProfile -Command "Compress-Archive -Path 'cli/$CLI_NAME' -DestinationPath 'dist/$CLI_NAME.zip'" - else - tar -czf "dist/$CLI_NAME.tar.gz" -C cli "$CLI_NAME" - fi - ls -la dist - - - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + - uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4 with: name: cli-${{ matrix.rid }} path: dist/* if-no-files-found: error retention-days: 7 + # The identity Velopack clients rely on: pack id, channel, version, main executable, feed and package agree. + check: + name: check + needs: [prepare, app] + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + env: + VERSION: ${{ needs.prepare.outputs.version }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: christopherhx/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4 + with: + name: release-win + path: Releases/win + + - uses: christopherhx/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4 + with: + name: release-linux + path: Releases/linux + + - name: Check packages + run: | + set -euo pipefail + python3 -I eng/assert-release.py Releases/win win "$VERSION" CheckHash.exe + python3 -I eng/assert-release.py Releases/linux linux "$VERSION" CheckHash + publish: - name: publish - needs: [prepare, app, upgrade-gate, cli] - if: needs.prepare.outputs.publish == 'true' + name: publish (versioned files, linux) + needs: [prepare, app, cli, check] + if: github.event_name == 'workflow_dispatch' && needs.prepare.outputs.publish == 'true' runs-on: ubuntu-latest timeout-minutes: 30 permissions: - contents: write - id-token: write - attestations: write + contents: read env: VERSION: ${{ needs.prepare.outputs.version }} - GH_TOKEN: ${{ github.token }} + R2_ACCOUNT_ID: ${{ vars.R2_ACCOUNT_ID }} + # Never name a variable RCLONE_* unless rclone should read it as a flag (ops publish-r2.yml, v2026.11.4). + PINNED_RCLONE_VERSION: v1.76.0 + PINNED_RCLONE_SHA256: b00f00b3266c3764413afe599d3ec316f6f43b3e0ea8a0bc1d186d2133e46df7 # rclone-v1.76.0-linux-amd64.zip + RCLONE_CONFIG_R2_TYPE: s3 + RCLONE_CONFIG_R2_PROVIDER: Cloudflare + RCLONE_CONFIG_R2_ENDPOINT: https://${{ vars.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com + RCLONE_CONFIG_R2_REGION: auto + RCLONE_CONFIG_R2_NO_CHECK_BUCKET: "true" + # Velopack's S3 options (vpk reads VPK_