Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ on:
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
group: release-preparation
cancel-in-progress: false
jobs:
validate:
# GitHub restricts draft visibility to push-capable credentials. This job only reads releases.
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
mode: ${{ steps.preflight.outputs.mode }}
release_run: ${{ steps.preflight.outputs.release_run }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
Expand All @@ -36,10 +41,21 @@ jobs:
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
output.write('version=' + version + '\n')
PY
- name: Refuse published versions and identify resumable drafts
id: preflight
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_VERSION: ${{ steps.version.outputs.version }}
RELEASE_COMMIT: ${{ github.sha }}
RELEASE_RUN: ${{ github.run_id }}
run: python3 scripts/prepare_release.py --preflight
build:
if: needs.validate.outputs.mode == 'new'
needs: validate
uses: ./.github/workflows/dotnet-ci.yml
draft:
if: always() && needs.validate.result == 'success' && (needs.build.result == 'success' || needs.build.result == 'skipped') && needs.validate.outputs.mode != 'complete'
needs: [validate, build]
runs-on: ubuntu-latest
permissions:
Expand All @@ -53,7 +69,7 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_RUN: ${{ github.run_id }}
RELEASE_RUN: ${{ needs.validate.outputs.release_run }}
run: |
gh run download "$RELEASE_RUN" --pattern 'spn-*-preview' --dir release-input
mkdir release-files
Expand All @@ -66,9 +82,7 @@ jobs:
GH_REPO: ${{ github.repository }}
RELEASE_VERSION: ${{ needs.validate.outputs.version }}
RELEASE_COMMIT: ${{ github.sha }}
RELEASE_RUN: ${{ needs.validate.outputs.release_run }}
run: |
flags=()
RELEASE_TAG="v$RELEASE_VERSION"
if [[ "$RELEASE_TAG" == *-* ]]; then flags+=(--prerelease); fi
gh release create "$RELEASE_TAG" --target "$RELEASE_COMMIT" --draft --title "SidePulse.NET $RELEASE_VERSION" --notes-file "docs/releases/$RELEASE_VERSION.md" "${flags[@]}" release-files/*
python3 scripts/prepare_release.py --directory release-files
echo "Release draft prepared. Review downloads, notes and acceptance before publishing." >> "$GITHUB_STEP_SUMMARY"
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ an agent is working, waiting for input or finished.
The baseline is **C# / .NET 10 LTS**, **Spectre.Console** and
**Spectre.Console.Cli**. Windows, macOS and Linux are supported by the preview;
see the [platform matrix](docs/wiki/Platforms.md) for native credential requirements
and architecture-specific validation. No release has been published yet.
and architecture-specific validation. Beta 1 and beta 2 have been published; subsequent changes on main remain unreleased.

Hardware/firmware, real provider sessions and the public release/update flow still
need acceptance evidence. A live dashboard, device aliases, explicit Python
Expand Down Expand Up @@ -154,7 +154,8 @@ with an installation manifest; older previews need one manual upgrade. Stop the
host first and confirm `installed` before restarting it. See
[updating and recovery](docs/wiki/Updating.md). Adding the release workflow does not
publish a release. A matching version tag or manual Prepare release run on `main`
builds and verifies six archives, then creates an unpublished release draft.
builds and verifies six archives, then creates an unpublished release draft. Published
versions are refused; repeat runs reuse complete drafts or resume their original artifacts.
Publishing the reviewed draft is a separate explicit release action.

### Device storage and firmware
Expand Down
1 change: 1 addition & 0 deletions SidePulse.NET.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
</Folder>
<Folder Name="/tests/">
<Project Path="tests/SidePulse.Tests/SidePulse.Tests.csproj" />
<Project Path="tests/SidePulse.UpdateFixture/SidePulse.UpdateFixture.csproj" />
</Folder>
</Solution>
28 changes: 28 additions & 0 deletions docs/reviews/release-draft-2026-11-30.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Beta 2 draft audit — 2026-11-30

Issue #57 records an extra draft for `v0.1.0-beta.2`.

| Release | ID | State | Target |
|---|---|---|---|
| Beta 1 | 422776643 | Published, preserved | f02d61a9607a4105b5d510d7bff391c0e5177316 |
| Beta 2 | 422825899 | Published, preserved | b5982f259ac2818f3fb39038c6809d1c191969ca |
| Extra Beta 2 | 424050144 | Unpublished, retained | b5982f259ac2818f3fb39038c6809d1c191969ca |

The extra draft and its seven assets were created by `github-actions[bot]`. Assets
were uploaded on 2026-10-26 at 09:24 UTC. The successful tag-push Prepare release
[run 40298814975](https://github.com/Anheledir/SidePulse.NET/actions/runs/40298814975)
started at 09:20 UTC at the same target commit. The old workflow unconditionally
ran `gh release create --draft` and used a per-ref concurrency key, allowing repeat
or tag/dispatch preparation to produce another draft.

Both beta.2 records have six archives plus `SHA256SUMS`, but all seven GitHub asset
digests differ. Equal target commits do not establish byte-identical artifacts.
The draft was therefore retained as unpublished evidence. No release, asset or tag
was deleted, replaced, renamed or published during this work. This is a deliberate
retention decision, not a claim that the duplicate was removed.

The revised workflow refuses this published version even when a same-tag draft
exists. A read-only live preflight against beta.2 confirmed the refusal. Future
preparation uses a shared concurrency group, recorded provenance, immutable asset
checks and original-run artifact resumption. No live release was created to test
those mutation paths; deterministic API-contract tests cover them.
45 changes: 37 additions & 8 deletions docs/wiki/Updating.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,50 @@ the backup directory manually before the CLI can run again.

Unknown user-added files are copied into the new directory unless they collide
with a new application-owned file. Existing directory access permissions and access
permissions on user-added files are preserved. Avoid editing the installation
during updating.
permissions on user-added files are preserved. Preparation records content and access
permission fingerprints of the current and staged trees, including empty directories.
Apply checks both again under the update lock before renaming anything. Additions,
equal-size edits, deletions, permission changes or altered staged copies refuse the
swap and preserve the current directory; stop writers and prepare again. Plans from
older versions without fingerprints are refused rather than assumed safe.

The helper checks again after moving the old directory to its backup and after the
startup probe. Detected changes during that interval trigger rollback. A modified
replacement is retained under `workspace/failed-package`; edits there are not silently
merged into the restored installation. Writers must remain stopped throughout the
transaction: file fingerprints cannot freeze arbitrary external processes or their
already-open handles. Inspect both retained trees after a failure.
Phone links, profiles and hooks normally live outside it and are not changed.
The complete old installation and temporary download/helper workspace are retained
for recovery. Once installation is confirmed and no helper is running, these
paths may be removed manually to reclaim space. Failed updates preserve evidence.

## Publishing

The Release workflow runs on `vVERSION` tags or manual dispatch on such a tag.
The tag must match the project version. It reuses all three native CI jobs and
self-contained smoke checks, collects all six archives, writes `SHA256SUMS`, uploads
a draft release and only then publishes it. Hyphenated versions are prereleases.
No release or tag is created simply by adding this workflow to a branch. Existing
release tags are not overwritten. Review the release notes/assets after publishing.
The Prepare release workflow accepts matching `vVERSION` tags or manual dispatch on
`main`. The project version and matching `docs/releases/VERSION.md` are required.
It builds/tests all three native platforms and verifies all six runtime archives.
**Publication stays manual:** preparation creates an unpublished draft; it never
publishes a release or rewrites an existing tag.

All preparation runs share one non-cancelling concurrency group, including tag and
manual-dispatch runs. Preflight refuses any already-published version before building,
even if an extra draft has the same tag. Use a new project version and matching notes.
An existing draft must match its commit, notes, prerelease flag and recorded asset
inventory. Complete drafts are reused without rebuilding or replacing anything.
Partial drafts resume only missing uploads from their original workflow artifacts;
accepted uploads are reconciled by SHA-256/size instead of replayed or overwritten.
If those artifacts expired, preserve/review the draft and choose a new version rather
than mixing rebuilt binaries into it. Conflicting metadata/assets or multiple drafts
are refused. Do not publish manually while a preparation workflow is still running;
GitHub does not offer an atomic draft-state condition on an asset upload.

The hidden release-plan comment records the originating run, commit and seven asset
digests. Do not edit it during preparation. Legacy drafts without that provenance
require explicit review. The existing extra beta.2 draft was inspected and retained
because its archive hashes differ from the published beta.2; see
[the audit](../reviews/release-draft-2026-11-30.md). Neither public beta nor its assets
or tags were changed.

`update status --json` always exposes the same lower-camel-case fields: `state`,
`version`, `target`, `backup`, `workspace`, `error`, and `receipt`. Missing values
Expand Down
158 changes: 158 additions & 0 deletions scripts/prepare_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
"""Prepare or resume one immutable release draft; never publish or replace assets."""
import argparse
import hashlib
import json
import os
from pathlib import Path
import re
import subprocess
from urllib.parse import quote

from verify_release import verify

NAMES = {f'spn-{platform}-{arch}' + ('.zip' if platform == 'win' else '.tar.gz')
for platform in ('win', 'linux', 'osx') for arch in ('x64', 'arm64')} | {'SHA256SUMS'}
MARKER = 'spn-release-plan-v1:'


class GitHub:
def __init__(self, repository):
if not re.fullmatch(r'[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+', repository):
raise ValueError('Invalid repository name')
self.repository = repository

def api(self, path, method='GET', payload=None, file=None):
command = ['gh', 'api', path, '--method', method]
data = None
if payload is not None:
command += ['--input', '-']
data = json.dumps(payload)
if file is not None:
command += ['--input', str(file), '-H', 'Content-Type: application/octet-stream']
response = subprocess.run(command, input=data, capture_output=True, text=True, check=True)
return json.loads(response.stdout)

def releases(self):
releases = []
page = 1
while True:
batch = self.api(f'repos/{self.repository}/releases?per_page=100&page={page}')
releases.extend(batch)
if len(batch) < 100:
return releases
page += 1

def get(self, release_id):
return self.api(f'repos/{self.repository}/releases/{release_id}')

def create(self, payload):
return self.api(f'repos/{self.repository}/releases', 'POST', payload=payload)

def upload(self, release_id, path):
return self.api(f'https://uploads.github.com/repos/{self.repository}/releases/{release_id}/assets?name={quote(path.name)}', 'POST', file=path)


def metadata(release, version, commit, notes):
if not release.get('draft'):
raise ValueError('Version is already published; choose a new version and matching release notes. No release was modified.')
if (release['tag_name'] != 'v' + version or release['target_commitish'] != commit
or release['name'] != 'SidePulse.NET ' + version or release['prerelease'] != ('-' in version)):
raise ValueError('Existing draft metadata differs. Review it; no release was modified.')
body = release.get('body') or ''
pattern = r'\n\n<!-- ' + MARKER + r'([^\n]+) -->\n?'
matches = list(re.finditer(pattern, body))
if len(matches) != 1 or matches[0].end() != len(body) or body[:matches[0].start()] != notes.strip():
raise ValueError('Existing draft notes or provenance differ. No release was modified.')
plan = json.loads(matches[0][1])
if (plan.get('commit') != commit or not re.fullmatch(r'[1-9][0-9]*', str(plan.get('run', '')))
or set(plan.get('files', {})) != NAMES):
raise ValueError('Existing draft provenance is invalid')
for entry in plan['files'].values():
if not isinstance(entry.get('size'), int) or entry['size'] <= 0 or not re.fullmatch(r'sha256:[0-9a-f]{64}', entry.get('digest', '')):
raise ValueError('Invalid draft asset inventory')
seen = set()
for asset in release['assets']:
name = asset['name']
if name in seen or name not in plan['files'] or any(asset.get(key) != plan['files'][name][key] for key in ('size', 'digest')):
raise ValueError('Existing draft assets differ from the verified inventory. Nothing will be overwritten.')
seen.add(name)
return plan, NAMES - seen


def inspect(api, version, commit, notes):
matches = [r for r in api.releases() if r['tag_name'] == 'v' + version]
if any(not r['draft'] for r in matches):
raise ValueError('Version is already published; choose a new version and matching release notes. No release was modified.')
if len(matches) > 1:
raise ValueError('Multiple drafts exist for this version. Resolve the ambiguity before preparing another release.')
if not matches:
return None, None, NAMES
release = api.get(matches[0]['id'])
plan, missing = metadata(release, version, commit, notes)
return release, plan, missing


def preflight(api, version, commit, notes, run):
release, plan, missing = inspect(api, version, commit, notes)
return {'mode': 'new' if release is None else 'resume' if missing else 'complete',
'release_run': str(plan['run'] if plan else run)}


def prepare(api, root, version, commit, notes, run):
# Refuse a published version before touching local artifacts or remote state.
release, plan, missing = inspect(api, version, commit, notes)
if release is not None and not missing:
return release['id']
verify(root, version)
inventory = {name: {'size': (root / name).stat().st_size,
'digest': 'sha256:' + hashlib.sha256((root / name).read_bytes()).hexdigest()}
for name in sorted(NAMES)}
if plan is not None and inventory != plan['files']:
raise ValueError('Resume requires the original verified build artifacts. Existing assets were preserved.')
if release is None:
plan = {'commit': commit, 'run': str(run), 'files': inventory}
body = notes.strip() + '\n\n<!-- ' + MARKER + json.dumps(plan, sort_keys=True, separators=(',', ':')) + ' -->\n'
release = api.create({'tag_name': 'v' + version, 'target_commitish': commit, 'draft': True,
'prerelease': '-' in version, 'name': 'SidePulse.NET ' + version, 'body': body})
# Check ID, draft state, metadata and digest inventory before each non-overwriting upload.
# Never retry a POST after an ambiguous result; the next run reconciles server state.
for name in sorted(NAMES):
current, current_plan, current_missing = inspect(api, version, commit, notes)
if current is None or current['id'] != release['id'] or current_plan != plan:
raise ValueError('Release changed during preparation. Stop and review it.')
if name in current_missing:
api.upload(release['id'], root / name)
final = api.get(release['id'])
_, missing = metadata(final, version, commit, notes)
if missing:
raise ValueError('Draft is incomplete; rerun preparation to resume its original artifacts')
return release['id']


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--preflight', action='store_true')
parser.add_argument('--directory', type=Path)
args = parser.parse_args()
version, commit, run = (os.environ[name] for name in ('RELEASE_VERSION', 'RELEASE_COMMIT', 'RELEASE_RUN'))
if not re.fullmatch(r'\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?', version):
raise ValueError('Invalid release version')
if not re.fullmatch(r'[0-9a-f]{40}', commit) or not re.fullmatch(r'[1-9][0-9]*', run):
raise ValueError('A full commit SHA and originating workflow run ID are required')
notes = Path('docs/releases', version + '.md').read_text(encoding='utf-8')
api = GitHub(os.environ['GH_REPO'])
if args.preflight:
decision = preflight(api, version, commit, notes, run)
if os.environ.get('GITHUB_OUTPUT'):
with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as output:
for key, value in decision.items():
output.write(f'{key}={value}\n')
print(json.dumps(decision))
else:
if args.directory is None:
parser.error('--directory is required to prepare a draft')
print('Unpublished draft verified:', prepare(api, args.directory, version, commit, notes, run))


if __name__ == '__main__':
main()
Loading
Loading