diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 381aa9c..e10e1e4 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -10,32 +10,18 @@ "rollForward": false }, "nuget-license": { - "version": "4.0.18", + "version": "4.0.19", "commands": [ "nuget-license" ], "rollForward": false }, "cyclonedx": { - "version": "6.3.1", + "version": "6.3.2", "commands": [ "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/CODEOWNERS b/.gitea/CODEOWNERS similarity index 100% rename from .github/CODEOWNERS rename to .gitea/CODEOWNERS 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/.github/workflows/ci.yml b/.gitea/workflows/ci.yml similarity index 54% rename from .github/workflows/ci.yml rename to .gitea/workflows/ci.yml index 4080aea..ad9e1c9 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,24 @@ 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 + global-json-file: global.json - - 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 }}- + # The runner's Ubuntu image has no ICU, without which .NET stops at start-up; the tests and the smoke test need real + # cultures (67 languages), so invariant mode is no way out here. The job container runs as root. + - name: Install ICU (Linux) + if: runner.os == 'Linux' + run: | + if command -v sudo > /dev/null; then sudo apt-get update -q && sudo apt-get install -y -q --no-install-recommends libicu-dev + else apt-get update -q && apt-get install -y -q --no-install-recommends libicu-dev; fi - name: Restore run: dotnet restore HashTool.slnx @@ -52,10 +74,10 @@ 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 + --coverage --coverage-output-format cobertura --coverage-settings eng/coverage.config - name: Coverage gate (HashTool.Core >= 80%) if: runner.os == 'Linux' @@ -63,14 +85,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 @@ -83,6 +104,9 @@ jobs: timeout-minutes: 15 permissions: contents: read + env: + # The runner's Ubuntu image has no ICU; formatting needs no cultures. + DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -90,7 +114,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 +125,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() 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/.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/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..1634933 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,639 @@ +name: Release + +# 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.3.1 (must match Directory.Build.props to publish)" + required: true + type: string + publish: + 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: + - .gitea/workflows/release.yml + # vpk and CycloneDX versions. + - .config/dotnet-tools.json + - build/** + - eng/assert-release.py + - eng/release-notes.py + +permissions: + contents: read + +concurrency: + group: release-${{ 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 + PACK_ID: HashTool + PUBLIC_BASE: https://releases.poli0981.dev/hashtool + +jobs: + prepare: + name: prepare + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + outputs: + version: ${{ steps.version.outputs.version }} + publish: ${{ steps.version.outputs.publish }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Resolve version + id: version + env: + EVENT: ${{ github.event_name }} + INPUT_VERSION: ${{ inputs.version }} + INPUT_PUBLISH: ${{ inputs.publish }} + 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) + if [ "$EVENT" = workflow_dispatch ]; then + version="$INPUT_VERSION" + publish="$INPUT_PUBLISH" + else + # Pull request dry run: a pre-release above the last release. + version="$project-ci.$GITHUB_RUN_NUMBER" + publish=false + fi + if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then + echo "::error::'$version' is not a valid version (expected 1.2.3 or 1.2.3-suffix, no leading v)" + exit 1 + fi + if [ "$publish" = true ]; then + if [ "$version" != "$project" ]; then + echo "::error::Version $version does not match Directory.Build.props ($project)" + exit 1 + fi + if [ "$GITHUB_REF" != refs/heads/main ]; then + echo "::error::Releases are published from main only (got $GITHUB_REF)" + exit 1 + fi + 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" + echo "publish=$publish" + echo "notes=$project" + } >> "$GITHUB_OUTPUT" + echo "Version $version (publish: $publish)" + + - name: Release notes + env: + NOTES_VERSION: ${{ steps.version.outputs.notes }} + PUBLISH: ${{ steps.version.outputs.publish }} + run: | + set -euo pipefail + flags=() + if [ "$PUBLISH" = true ]; then flags+=(--require-date); fi + python3 -I eng/release-notes.py "$NOTES_VERSION" "${flags[@]}" > release-notes.md + cat release-notes.md + + - uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4 + with: + name: notes + path: release-notes.md + retention-days: 7 + + app: + name: app (${{ matrix.channel }}) + needs: prepare + strategy: + fail-fast: false + matrix: + include: + - { 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 + permissions: + contents: read + env: + VERSION: ${{ needs.prepare.outputs.version }} + RID: ${{ matrix.rid }} + CHANNEL: ${{ matrix.channel }} + MAIN_EXE: ${{ matrix.exe }} + 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: + global-json-file: global.json + + - uses: christopherhx/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4 + with: + name: notes + + # The runner's Ubuntu image has no ICU, without which .NET stops at start-up; the smoke test needs real cultures. + # mksquashfs builds the AppImage. The job container runs as root; sudo only where the image has it. + - name: Install ICU and squashfs-tools (Linux) + if: runner.os == 'Linux' + run: | + pkgs=(libicu-dev squashfs-tools) + if command -v sudo > /dev/null; then sudo apt-get update -q && sudo apt-get install -y -q --no-install-recommends "${pkgs[@]}" + else apt-get update -q && apt-get install -y -q --no-install-recommends "${pkgs[@]}"; 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 (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: 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-data + run: '"publish/$MAIN_EXE" --smoke-test --expect-version "$VERSION"' + + - name: Pack (Windows) + if: runner.os == 'Windows' + 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 + + - name: Pack (Linux) + if: runner.os == 'Linux' + run: | + set -euo pipefail + 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: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4 + with: + name: release-${{ matrix.channel }} + path: Releases/* + if-no-files-found: error + retention-days: 7 + + cli: + name: cli (${{ matrix.rid }}) + needs: prepare + strategy: + fail-fast: false + matrix: + include: + # 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 } + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + permissions: + contents: read + env: + VERSION: ${{ needs.prepare.outputs.version }} + RID: ${{ matrix.rid }} + CLI_NAME: hashtool-${{ needs.prepare.outputs.version }}-${{ matrix.rid }} + # The runner's Ubuntu image has no ICU; the build needs no cultures and the CLI itself is invariant. + DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1 + 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: + global-json-file: global.json + + - name: Install native toolchain (Linux) + if: runner.os == 'Linux' + 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, 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/" + # .NET's ZipFile rather than Compress-Archive: the runner's PowerShell cannot load Microsoft.PowerShell.Archive. + Add-Type -AssemblyName System.IO.Compression.ZipFile + [IO.Compression.ZipFile]::CreateFromDirectory((Resolve-Path "staging/$env:CLI_NAME").Path, + (Join-Path (Resolve-Path dist).Path "$env:CLI_NAME.zip"), [IO.Compression.CompressionLevel]::Optimal, $true) + Get-ChildItem dist, "staging/$env:CLI_NAME" + + - name: Test and archive (Linux) + if: runner.os == 'Linux' + run: | + set -euo pipefail + 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" + + - 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 (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: read + env: + VERSION: ${{ needs.prepare.outputs.version }} + R2_ACCOUNT_ID: ${{ vars.R2_ACCOUNT_ID }} + # The runner's Ubuntu image has no ICU; CycloneDX and vpk need no cultures. + DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1 + # 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_