|
| 1 | +name: beta |
| 2 | + |
| 3 | +# Manual only. There is deliberately no push trigger and no tag trigger, so this |
| 4 | +# cannot fire as a side effect of committing, merging, or tagging anything. |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +# Read-only token. This workflow cannot create a release, push a tag, or write to |
| 9 | +# the repository even if a step tried to: the GITHUB_TOKEN it is handed has no |
| 10 | +# write scope. The beta EXE leaves as a workflow artifact and nothing else. |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: beta-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + beta: |
| 20 | + runs-on: windows-latest |
| 21 | + # No permissions block here either -- the job inherits the read-only set above. |
| 22 | + # release.yml needs contents/id-token/attestations write to publish; this one |
| 23 | + # intentionally has none of them. |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + fetch-tags: true |
| 29 | + |
| 30 | + - name: Resolve beta version |
| 31 | + id: ver |
| 32 | + shell: pwsh |
| 33 | + run: | |
| 34 | + # Same shape as dev-build.yml: a numeric base for AssemblyVersion and |
| 35 | + # FileVersion (which must stay a pure a.b.c.d), and a descriptive |
| 36 | + # InformationalVersion carrying the -beta.<sha> suffix. AppIdentity parses |
| 37 | + # the sha back out of it for the in-app BETA marker. |
| 38 | + # Stable tags only -- 'v*.*.*' also matches prerelease tags, and [int] on |
| 39 | + # a "65-beta" patch component throws. |
| 40 | + $latest = (git tag --list 'v*.*.*' --sort=-v:refname | Where-Object { $_ -notmatch '-' } | Select-Object -First 1) |
| 41 | + if ([string]::IsNullOrWhiteSpace($latest)) { $latest = 'v0.0.0' } |
| 42 | + $parts = ($latest -replace '^v','').Split('.') |
| 43 | + $patch = [int]$parts[2] + 1 |
| 44 | + $base = "$($parts[0]).$($parts[1]).$patch" |
| 45 | + $sha = $env:GITHUB_SHA.Substring(0,7) |
| 46 | + $full = "$base-beta.$sha" |
| 47 | + "base=$base" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 48 | + "version=$full" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 49 | + "sha=$sha" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 50 | + Write-Host "Building beta $full (numeric base $base) from $env:GITHUB_REF_NAME" |
| 51 | +
|
| 52 | + - name: Setup .NET 8 |
| 53 | + uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0 |
| 54 | + with: |
| 55 | + dotnet-version: '8.0.x' |
| 56 | + |
| 57 | + - name: Restore |
| 58 | + run: dotnet restore GamerGuardian.sln |
| 59 | + |
| 60 | + # A beta goes to real testers, so it does not ship without the suite passing. |
| 61 | + # This builds the default (non-BETA) flavor, which is also the check that the |
| 62 | + # non-beta path still compiles warning-free. |
| 63 | + - name: Test |
| 64 | + run: dotnet test GamerGuardian.sln --nologo |
| 65 | + |
| 66 | + - name: Publish beta (self-contained, single-file, win-x64) |
| 67 | + # Identical publish flags to release.yml, plus -p:Beta=true to define the |
| 68 | + # BETA constant and an explicit InformationalVersion for the sha marker. |
| 69 | + run: > |
| 70 | + dotnet publish src/GamerGuardian/GamerGuardian.csproj |
| 71 | + -c Release |
| 72 | + -r win-x64 |
| 73 | + --self-contained true |
| 74 | + -p:PublishSingleFile=true |
| 75 | + -p:IncludeNativeLibrariesForSelfExtract=true |
| 76 | + -p:EnableCompressionInSingleFile=true |
| 77 | + -p:Beta=true |
| 78 | + -p:Version=${{ steps.ver.outputs.base }} |
| 79 | + -p:AssemblyVersion=${{ steps.ver.outputs.base }}.0 |
| 80 | + -p:FileVersion=${{ steps.ver.outputs.base }}.0 |
| 81 | + -p:InformationalVersion=${{ steps.ver.outputs.version }} |
| 82 | + -o publish |
| 83 | +
|
| 84 | + # Fails the run if the update path somehow survived into a beta build. |
| 85 | + # |
| 86 | + # Scans the managed assembly, NOT publish\GamerGuardian.exe. The shipped EXE is |
| 87 | + # a single-file bundle published with EnableCompressionInSingleFile, so its |
| 88 | + # assemblies are compressed: scanning the EXE's bytes finds nothing even in a |
| 89 | + # stable build. An earlier version of this step did exactly that and passed on |
| 90 | + # both flavors, which made it false assurance rather than a check. The DLL |
| 91 | + # below is the same assembly that gets bundled into that EXE. |
| 92 | + # |
| 93 | + # build.yml proves this check can actually fail, by asserting the differential |
| 94 | + # against a stable build. Here we only assert the absolute property. |
| 95 | + - name: Verify the update path is absent from the beta assembly |
| 96 | + shell: pwsh |
| 97 | + run: | |
| 98 | + $dll = Get-ChildItem -Recurse -Path "src/GamerGuardian/bin/Release" -Filter "GamerGuardian.dll" | |
| 99 | + Select-Object -First 1 |
| 100 | + if (-not $dll) { throw "Could not find the built GamerGuardian.dll to scan." } |
| 101 | + $bytes = [System.IO.File]::ReadAllBytes($dll.FullName) |
| 102 | + # .NET stores string literals as UTF-16 in the #US heap, but at arbitrary |
| 103 | + # byte offsets. Decoding from offset 0 only sees even-aligned literals; an |
| 104 | + # odd-aligned one decodes to garbage and is missed. Check both alignments. |
| 105 | + $even = [System.Text.Encoding]::Unicode.GetString($bytes, 0, $bytes.Length - ($bytes.Length % 2)) |
| 106 | + $odd = [System.Text.Encoding]::Unicode.GetString($bytes, 1, $bytes.Length - 1 - (($bytes.Length - 1) % 2)) |
| 107 | + $pattern = 'api\.github\.com/repos/carterscode/GamerGuardian/releases' |
| 108 | + if ([regex]::IsMatch($even, $pattern) -or [regex]::IsMatch($odd, $pattern)) { |
| 109 | + throw "BETA build still contains the update-feed URL -- the update path was not compiled out." |
| 110 | + } |
| 111 | + Write-Host "OK: no update-feed URL in $($dll.FullName)" |
| 112 | +
|
| 113 | + - name: List artifacts |
| 114 | + shell: pwsh |
| 115 | + run: Get-ChildItem -Recurse publish | Select-Object FullName, Length |
| 116 | + |
| 117 | + # The only output. No installer is built, no release is created, no tag is |
| 118 | + # pushed, and nothing is published to the update feed. |
| 119 | + - name: Upload beta EXE artifact |
| 120 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 121 | + with: |
| 122 | + name: GamerGuardian-beta-r${{ github.run_number }}-${{ steps.ver.outputs.sha }} |
| 123 | + path: publish/GamerGuardian.exe |
| 124 | + if-no-files-found: error |
0 commit comments