|
| 1 | +name: Published release smoke |
| 2 | + |
| 3 | +# Runs the archives and the install.ps1 that a published release serves, |
| 4 | +# each on its own platform (#418). release-candidate.yml runs archives built |
| 5 | +# in its own run; this runs the bytes users download. It only reads: the |
| 6 | +# token is read-only and nothing is uploaded, tagged or edited. |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + tag: |
| 11 | + description: Published release tag to check, v0.9.2 or later |
| 12 | + required: true |
| 13 | + default: v0.9.2 |
| 14 | + pull_request: |
| 15 | + paths: |
| 16 | + - '.github/workflows/published-release-smoke.yml' |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +# A pull request has no inputs, so it checks this fallback. Keep it equal to |
| 22 | +# the dispatch default above. |
| 23 | +env: |
| 24 | + TAG: ${{ inputs.tag || 'v0.9.2' }} |
| 25 | + TAG_PATTERN: '^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$' |
| 26 | + |
| 27 | +jobs: |
| 28 | + # ── Every asset against SHA256SUMS and GitHub's digest ────────────── |
| 29 | + # patch-release.yml replaces assets under an existing tag and moves the |
| 30 | + # tag. Coven pins digests per version, so either counts as a failure here. |
| 31 | + checksums: |
| 32 | + name: Published assets match SHA256SUMS |
| 33 | + runs-on: ubuntu-latest |
| 34 | + timeout-minutes: 10 |
| 35 | + env: |
| 36 | + GH_TOKEN: ${{ github.token }} |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v5 |
| 39 | + with: |
| 40 | + ref: refs/tags/${{ env.TAG }} |
| 41 | + persist-credentials: false |
| 42 | + |
| 43 | + - name: Download every published asset |
| 44 | + run: | |
| 45 | + [[ "$TAG" =~ $TAG_PATTERN ]] || { echo "::error::$TAG is not a release tag"; exit 1; } |
| 46 | + gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --dir published |
| 47 | +
|
| 48 | + - name: Compare every digest |
| 49 | + run: | |
| 50 | + set -euo pipefail |
| 51 | + release="$(gh api "repos/$GITHUB_REPOSITORY/releases/tags/$TAG")" |
| 52 | + published_at="$(jq -r .published_at <<<"$release")" |
| 53 | + target="$(jq -r .target_commitish <<<"$release")" |
| 54 | + head="$(git rev-parse HEAD)" |
| 55 | + echo "$TAG published $published_at from $target; the tag is now at $head" |
| 56 | + failures=() |
| 57 | + # release.yml publishes from a commit SHA; patch-release.yml moves |
| 58 | + # the tag but leaves target_commitish alone. |
| 59 | + if [[ "$target" =~ ^[0-9a-f]{40}$ && "$target" != "$head" ]]; then |
| 60 | + failures+=("$TAG moved to $head after it was published from $target") |
| 61 | + fi |
| 62 | + [[ -f published/SHA256SUMS ]] || { echo "::error::$TAG has no SHA256SUMS"; exit 1; } |
| 63 | + echo "Published SHA256SUMS:" |
| 64 | + cat published/SHA256SUMS |
| 65 | + echo |
| 66 | + archives='coven-code-linux-aarch64.tar.gz coven-code-linux-x86_64.tar.gz coven-code-macos-aarch64.tar.gz coven-code-macos-x86_64.tar.gz coven-code-windows-x86_64.zip' |
| 67 | + listed="$(awk '{print $2}' published/SHA256SUMS | xargs)" |
| 68 | + [[ "$listed" == "$archives" ]] || failures+=("SHA256SUMS lists [$listed], expected [$archives]") |
| 69 | + assets="$(jq -r '[.assets[].name] | sort | join(" ")' <<<"$release")" |
| 70 | + expected="$(tr ' ' '\n' <<<"$archives SHA256SUMS install.ps1 install.sh" | LC_ALL=C sort | xargs)" |
| 71 | + [[ "$assets" == "$expected" ]] || failures+=("release assets are [$assets], expected [$expected]") |
| 72 | + for name in $expected; do |
| 73 | + if [[ ! -f "published/$name" ]]; then |
| 74 | + failures+=("$name: not downloaded") |
| 75 | + continue |
| 76 | + fi |
| 77 | + downloaded="$(sha256sum "published/$name" | cut -d' ' -f1)" |
| 78 | + github="$(jq -r --arg n "$name" '.assets[] | select(.name == $n) | .digest | sub("^sha256:"; "")' <<<"$release")" |
| 79 | + uploaded="$(jq -r --arg n "$name" '.assets[] | select(.name == $n) | .created_at' <<<"$release")" |
| 80 | + echo "$name" |
| 81 | + echo " downloaded $downloaded" |
| 82 | + echo " GitHub $github (computed at upload, $uploaded)" |
| 83 | + [[ "$downloaded" == "$github" ]] || failures+=("$name: downloaded digest differs from GitHub's") |
| 84 | + if [[ "$uploaded" > "$published_at" ]]; then |
| 85 | + failures+=("$name: uploaded at $uploaded, after the release was published at $published_at") |
| 86 | + fi |
| 87 | + if [[ "$name" == install.* ]]; then |
| 88 | + if cmp -s "published/$name" "$name"; then |
| 89 | + echo " tag file identical to $name at $TAG" |
| 90 | + else |
| 91 | + failures+=("$name: differs from $name at $TAG") |
| 92 | + fi |
| 93 | + elif [[ "$name" != SHA256SUMS ]]; then |
| 94 | + manifest="$(awk -v n="$name" '$2 == n {print $1}' published/SHA256SUMS)" |
| 95 | + echo " SHA256SUMS $manifest" |
| 96 | + [[ "$downloaded" == "$manifest" ]] || failures+=("$name: digest differs from SHA256SUMS") |
| 97 | + fi |
| 98 | + done |
| 99 | + echo |
| 100 | + if (( ${#failures[@]} )); then |
| 101 | + printf '::error::%s\n' "${failures[@]}" |
| 102 | + exit 1 |
| 103 | + fi |
| 104 | + echo "All five archives match SHA256SUMS, every download matches GitHub's digest, and nothing was uploaded or moved after publication." |
| 105 | +
|
| 106 | + # ── Each published archive on its own platform ────────────────────── |
| 107 | + archive: |
| 108 | + strategy: |
| 109 | + fail-fast: false |
| 110 | + matrix: |
| 111 | + include: |
| 112 | + - artifact: coven-code-linux-x86_64 |
| 113 | + archive: coven-code-linux-x86_64.tar.gz |
| 114 | + os: ubuntu-latest |
| 115 | + - artifact: coven-code-linux-aarch64 |
| 116 | + archive: coven-code-linux-aarch64.tar.gz |
| 117 | + os: ubuntu-24.04-arm |
| 118 | + - artifact: coven-code-windows-x86_64 |
| 119 | + archive: coven-code-windows-x86_64.zip |
| 120 | + os: windows-latest |
| 121 | + runs-on: ${{ matrix.os }} |
| 122 | + name: Run published ${{ matrix.artifact }} |
| 123 | + timeout-minutes: 15 |
| 124 | + steps: |
| 125 | + # The smoke script expects the version stamped in its own checkout. |
| 126 | + - uses: actions/checkout@v5 |
| 127 | + with: |
| 128 | + ref: refs/tags/${{ env.TAG }} |
| 129 | + persist-credentials: false |
| 130 | + |
| 131 | + - uses: actions/setup-python@v6 |
| 132 | + with: |
| 133 | + python-version: '3.12' |
| 134 | + |
| 135 | + # Linux archives load the system ALSA library for the voice feature. |
| 136 | + - name: Install the Linux audio runtime library |
| 137 | + if: runner.os == 'Linux' |
| 138 | + run: | |
| 139 | + sudo apt-get update |
| 140 | + sudo apt-get install -y libasound2t64 || sudo apt-get install -y libasound2 |
| 141 | +
|
| 142 | + # Only the download gets the token; coven-code reads GH_TOKEN. |
| 143 | + - name: Download the published archive and SHA256SUMS |
| 144 | + shell: bash |
| 145 | + env: |
| 146 | + GH_TOKEN: ${{ github.token }} |
| 147 | + run: | |
| 148 | + [[ "$TAG" =~ $TAG_PATTERN ]] || { echo "::error::$TAG is not a release tag"; exit 1; } |
| 149 | + [[ -f scripts/smoke-release-archive.py ]] || { echo "::error::$TAG predates scripts/smoke-release-archive.py"; exit 1; } |
| 150 | + gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --dir published \ |
| 151 | + --pattern '${{ matrix.archive }}' --pattern SHA256SUMS |
| 152 | + echo "Runner: $RUNNER_OS $RUNNER_ARCH ($(uname -srm)); source $(git rev-parse HEAD)" |
| 153 | + echo "SHA256SUMS $(awk '$2 == "${{ matrix.archive }}" {print $1}' published/SHA256SUMS)" |
| 154 | + echo "downloaded $(sha256sum 'published/${{ matrix.archive }}' | cut -d' ' -f1)" |
| 155 | +
|
| 156 | + - name: Verify digest, contents, version and one turn |
| 157 | + run: python scripts/smoke-release-archive.py published ${{ matrix.artifact }} |
| 158 | + |
| 159 | + # ── The published install.ps1, into a throwaway home ──────────────── |
| 160 | + install-ps1: |
| 161 | + name: Run published install.ps1 |
| 162 | + runs-on: windows-latest |
| 163 | + timeout-minutes: 15 |
| 164 | + steps: |
| 165 | + # Only the download gets the token: install.ps1 and coven-code run |
| 166 | + # in the steps below, and coven-code reads GH_TOKEN. |
| 167 | + - name: Download the published install.ps1, Windows archive and SHA256SUMS |
| 168 | + shell: bash |
| 169 | + env: |
| 170 | + GH_TOKEN: ${{ github.token }} |
| 171 | + run: | |
| 172 | + [[ "$TAG" =~ $TAG_PATTERN ]] || { echo "::error::$TAG is not a release tag"; exit 1; } |
| 173 | + gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --dir published \ |
| 174 | + --pattern install.ps1 --pattern coven-code-windows-x86_64.zip --pattern SHA256SUMS |
| 175 | +
|
| 176 | + # USERPROFILE and TEMP point at a throwaway directory. -NoModifyPath |
| 177 | + # keeps the runner's user PATH, and dropping GITHUB_PATH keeps later |
| 178 | + # steps' PATH, as they were. The user PATH is read unexpanded: it |
| 179 | + # holds %USERPROFILE% references, which this step changes. |
| 180 | + - name: Install with the published install.ps1 |
| 181 | + shell: pwsh |
| 182 | + run: | |
| 183 | + $root = Join-Path $env:RUNNER_TEMP 'install-ps1' |
| 184 | + $tempDir = Join-Path $root 'temp' |
| 185 | + New-Item -ItemType Directory -Path (Join-Path $root 'home'), $tempDir | Out-Null |
| 186 | + $userPath = (Get-Item HKCU:\Environment).GetValue('Path', '', 'DoNotExpandEnvironmentNames') |
| 187 | + $env:USERPROFILE = Join-Path $root 'home' |
| 188 | + $env:TEMP = $tempDir |
| 189 | + $env:TMP = $tempDir |
| 190 | + Remove-Item Env:GITHUB_PATH |
| 191 | + pwsh -NoLogo -NoProfile -File published/install.ps1 -Version $env:TAG -NoModifyPath |
| 192 | + if ($LASTEXITCODE -ne 0) { throw "install.ps1 exited with $LASTEXITCODE" } |
| 193 | + $after = (Get-Item HKCU:\Environment).GetValue('Path', '', 'DoNotExpandEnvironmentNames') |
| 194 | + if ($after -ne $userPath) { throw "install.ps1 changed the user PATH from '$userPath' to '$after'" } |
| 195 | + Write-Host "User PATH unchanged: $userPath" |
| 196 | + if (Get-ChildItem -Force $tempDir) { throw 'install.ps1 left files in TEMP' } |
| 197 | +
|
| 198 | + - name: Check the installed binary against SHA256SUMS and run it |
| 199 | + shell: pwsh |
| 200 | + run: | |
| 201 | + $root = Join-Path $env:RUNNER_TEMP 'install-ps1' |
| 202 | + $bin = Join-Path $root 'home\.coven-code\bin' |
| 203 | + $zip = 'published/coven-code-windows-x86_64.zip' |
| 204 | + $manifest = (Get-Content published/SHA256SUMS | Where-Object { $_ -match ' coven-code-windows-x86_64\.zip$' }) -split ' ' | Select-Object -First 1 |
| 205 | + $archive = (Get-FileHash $zip -Algorithm SHA256).Hash.ToLowerInvariant() |
| 206 | + Expand-Archive $zip -DestinationPath (Join-Path $root 'archive') |
| 207 | + $member = (Get-FileHash (Join-Path $root 'archive\coven-code.exe') -Algorithm SHA256).Hash.ToLowerInvariant() |
| 208 | + $installed = (Get-FileHash (Join-Path $bin 'coven-code.exe') -Algorithm SHA256).Hash.ToLowerInvariant() |
| 209 | + $alias = (Get-FileHash (Join-Path $bin 'coven-cave.exe') -Algorithm SHA256).Hash.ToLowerInvariant() |
| 210 | + Write-Host "SHA256SUMS $manifest coven-code-windows-x86_64.zip" |
| 211 | + Write-Host "downloaded zip $archive" |
| 212 | + Write-Host "zip member $member coven-code.exe" |
| 213 | + Write-Host "installed $installed $bin\coven-code.exe" |
| 214 | + Write-Host "installed alias $alias $bin\coven-cave.exe" |
| 215 | + if ($archive -ne $manifest) { throw 'The published zip does not match SHA256SUMS' } |
| 216 | + if ($installed -ne $member -or $alias -ne $member) { throw 'The installed binaries are not the verified archive member' } |
| 217 | + foreach ($name in 'USERPROFILE', 'HOME', 'APPDATA', 'LOCALAPPDATA') { |
| 218 | + Set-Item "Env:$name" (Join-Path $root 'home') |
| 219 | + } |
| 220 | + $env:Path = "$bin;$env:Path" |
| 221 | + $resolved = (Get-Command coven-code).Source |
| 222 | + $printed = (coven-code --version | Out-String).Trim() |
| 223 | + if ($LASTEXITCODE -ne 0) { throw "coven-code --version exited with $LASTEXITCODE" } |
| 224 | + Write-Host "$resolved --version: $printed" |
| 225 | + $expected = 'coven-code ' + ($env:TAG -replace '^v', '') |
| 226 | + if ($resolved -ne (Join-Path $bin 'coven-code.exe')) { throw "coven-code resolved to $resolved" } |
| 227 | + if ($printed -cne $expected) { throw "expected '$expected', got '$printed'" } |
0 commit comments