Skip to content

Commit 88955c9

Browse files
he-man86claude
andcommitted
feat(release): git-derived one version, dev/stable channels, one publish pipeline
The version is now computed from git and injected, so nothing is hand-maintained across files (the anomalyco#36232 trap): version.ts derives the base X.Y.Z from volt-desktop's package.json (the one human-set number — git can't infer a patch-vs-feature bump) and the build number from the commit count; CI stamps the base into every package.json and passes the full version via VOLT_VERSION. - release.yml consolidated (opencode-style, one parameterized workflow): push to dev → PRERELEASE X.Y.Z.<count> (dev channel, no smoke-gate, fast); push a tag → STABLE X.Y.Z (latest, smoke-gated). --prerelease is the only difference. - Updater: VOLT_UPDATE_CHANNEL — stable (latest final, default) / dev (newest prerelease). System.Version compare unchanged; the vsix stays 3-part (vsce rejects a 4-part version), installer + connector carry the 4-part build. - Update UX hardened: one-click apply now stops the bridge workers + Electron GUI before the in-place upgrade so it can't fail on a locked file; the "update available" toast is clickable; the tooltip + header show it; the update item moved to the top of the tray menu, accent-tinted. - Cleanups: dropped release.yml's two version-guards (CI stamps them equal), simplified release.ts, added Volt.Cli.Connector.Tests to CI's volt-cli job (an untested gap), build-installer gained --prerelease + tag-at-commit publish. - Reset to 0.0.1 for a fresh release history (old GitHub releases deleted). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent 4dbe0ca commit 88955c9

9 files changed

Lines changed: 285 additions & 144 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ jobs:
100100
dotnet-version: 8.0.x
101101
- name: Build the whole toolchain (all TFMs — CLI, IDE hosts, connector)
102102
run: dotnet build packages/volt-cli/Volt.Cli.sln -c Release --nologo
103-
- name: Test — pipe transport + ported sync + black-box
103+
- name: Test — pipe transport + ported sync + black-box + CODESYS multi-instance
104104
run: dotnet test packages/volt-cli/test/Volt.Cli.Tests/Volt.Cli.Tests.csproj -c Release --nologo
105105
- name: Test — shared engine (parsing/PLCopen/VG + push/validate incl. delete-idempotency)
106106
run: dotnet test packages/volt-cli/test/Volt.Engine.Tests/Volt.Engine.Tests.csproj -c Release --nologo
107+
- name: Test — connector (connection model, discovery source, single-active + disconnect)
108+
run: dotnet test packages/volt-cli/test/Volt.Cli.Connector.Tests/Volt.Cli.Connector.Tests.csproj -c Release --nologo
107109

108110
# Validate the proposals in openspec/changes. NOT path-filtered: it's a required check, and a path-filtered
109111
# required check blocks PRs that don't touch openspec/ (GitHub waits forever for a check that never reports).

‎.github/workflows/release.yml‎

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
1-
# Cut a Volt desktop release: build the single Inno Setup installer (Volt-win-Setup.exe) and publish it to GitHub
2-
# Releases on he-man86/volt (this repo). The always-running C# connector polls the releases API and self-updates
3-
# by re-running a newer Setup.exe (Updater.cs), so the GitHub release IS the update feed.
1+
# Volt's ONE publish pipeline (opencode-style: one parameterized workflow, not a stable/dev copy-paste).
42
#
5-
# WHY THIS EXISTS: releases used to be built + uploaded by hand (`bun volt-scripts/build-installer.ts --upload` on a dev
6-
# box). That is how v0.2.1 shipped without the installer asset — a manual run dropped it. This automates the whole
7-
# cut so every release is consistent and complete, and verifies the installer landed.
3+
# push to dev → a PRERELEASE, versioned X.Y.Z.<commit-count> (the DEV channel). Every dev push ships a testable
4+
# installer. The connector's stable updater ignores prereleases; only VOLT_UPDATE_CHANNEL=dev picks
5+
# them up — so dev builds never reach stable users.
6+
# push a tag → a STABLE release, versioned as the tag X.Y.Z (the latest release the stable updater tracks).
87
#
9-
# - One installer (Inno Setup) + connector-driven auto-update — so a single windows-latest job, not a per-OS
10-
# matrix. Volt's PLC tooling (bridges, CODESYS) is Windows-native anyway.
11-
# - Triggered by a bare-version tag (X.Y.Z — the connector's updater compares it to the installed version; a
12-
# `v` prefix would break that compare). Cut by tagging dev.
8+
# The ONE version is computed from git (volt-scripts/version.ts) and INJECTED — stamped into every package.json +
9+
# passed as VOLT_VERSION — so no version is hand-maintained across files (sst/opencode#36232 is the bug that
10+
# happens when an artifact reads its own stored version instead of the injected one).
1311
#
14-
# TO CUT A RELEASE: bump packages/volt-desktop/package.json, commit to dev, then tag `X.Y.Z` (bare, matching that
15-
# version) and push the tag. This workflow builds version X.Y.Z and publishes the GitHub release at tag `X.Y.Z`.
16-
#
17-
# Signing: intentionally PARKED — the installer ships unsigned (Windows SmartScreen warns on first run). opencode
18-
# signs via Azure Trusted Signing (see their publish.yml); add an equivalent step here if/when signing is revisited.
12+
# Cut a stable release: `bun run release` (tags the current volt-desktop version on dev + pushes the tag).
13+
# Signing: intentionally PARKED — the installer ships unsigned (opencode signs via Azure Trusted Signing).
1914
name: release
2015

2116
on:
2217
push:
23-
tags:
24-
- "[0-9]+.[0-9]+.[0-9]+" # bare semver — the connector's updater compares it to the installed version; e.g. 0.2.2
25-
workflow_dispatch: {} # manual re-run — uses the current packages/volt-desktop/package.json version
18+
branches: [dev]
19+
tags: ["[0-9]+.[0-9]+.[0-9]+"] # bare semver X.Y.Z — a 4-part dev tag never matches, so it can't re-trigger
20+
workflow_dispatch: {} # manual stable re-run of the current volt-desktop version
2621

27-
concurrency: release-${{ github.ref }}
22+
# Supersede an in-flight DEV build when a newer commit lands (ref = refs/heads/dev). A stable build's ref is the
23+
# unique tag, so its group is unique and it is never cancelled.
24+
concurrency:
25+
group: release-${{ github.ref }}
26+
cancel-in-progress: true
2827

2928
permissions:
30-
contents: write # `gh release create` (build-installer.ts --upload-only) creates/updates the GitHub Release on this repo
29+
contents: write # gh release create/edit/upload on this repo
3130

3231
jobs:
3332
release:
34-
if: github.repository == 'he-man86/volt' # never run from a fork (opencode's publish.yml does the same)
35-
runs-on: windows-latest # Inno Setup (ISCC), electron-builder, and the C# connector are all Windows-native
33+
if: github.repository == 'he-man86/volt' # never from a fork
34+
runs-on: windows-latest # Inno Setup (ISCC), electron-builder, the C# connector — all Windows-native
3635
steps:
3736
- uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0 # full history — the build number is the commit count (version.ts)
3839

3940
- uses: oven-sh/setup-bun@v2
4041
with:
@@ -50,59 +51,48 @@ jobs:
5051
- name: Install dependencies
5152
run: bun install --frozen-lockfile
5253

53-
# On a tag push, the tag MUST match the desktop package version — build-installer.ts names the GitHub release
54-
# from the package version, so a mismatch would publish under a different tag than the one that triggered this.
55-
- name: Guard — tag matches desktop version
56-
if: github.ref_type == 'tag'
54+
- name: Compute the one version (git-derived)
55+
id: v
5756
shell: bash
58-
run: |
59-
version=$(node -p "require('./packages/volt-desktop/package.json').version")
60-
if [ "${GITHUB_REF_NAME}" != "${version}" ]; then
61-
echo "::error::tag ${GITHUB_REF_NAME} != ${version} (packages/volt-desktop/package.json). Bump the package version to match the tag."
62-
exit 1
63-
fi
64-
echo "releasing ${version}"
57+
run: bun volt-scripts/version.ts | tee -a "$GITHUB_OUTPUT"
6558

66-
# Volt ships ONE version: volt-desktop is the source of truth, and the .vsix the installer sideloads must
67-
# carry the same number. They're separate package.json files (the extension also publishes to the
68-
# Marketplace on its own), so nothing but this keeps them from drifting apart again. Runs on
69-
# workflow_dispatch too — there's no tag to compare there, but the two packages must still agree.
70-
- name: Guard — extension version matches the release
59+
# Inject the base X.Y.Z into every package.json so the vsix + electron app carry the one version (vsce rejects
60+
# a 4-part version, so packages get `base`; the installer + connector get the full `version` via VOLT_VERSION).
61+
- name: Stamp the version into every package.json
7162
shell: bash
7263
run: |
73-
version=$(node -p "require('./packages/volt-desktop/package.json').version")
74-
ext=$(node -p "require('./packages/volt-vscode/package.json').version")
75-
if [ "${ext}" != "${version}" ]; then
76-
echo "::error::volt-vscode ${ext} != volt-desktop ${version}. Volt ships one version — bump both."
77-
exit 1
78-
fi
79-
echo "extension ${ext} matches"
64+
base='${{ steps.v.outputs.base }}'
65+
for f in packages/volt-desktop/package.json packages/volt-vscode/package.json; do
66+
node -e "const fs=require('fs'),p='$f',j=JSON.parse(fs.readFileSync(p));j.version='$base';fs.writeFileSync(p,JSON.stringify(j,null,2)+'\n')"
67+
done
68+
echo "stamped base $base into every package.json"
8069
8170
- name: Build the Volt installer
71+
env:
72+
VOLT_VERSION: ${{ steps.v.outputs.version }}
8273
run: bun volt-scripts/build-installer.ts
8374

84-
# Gate: install the freshly-built installer, verify it configured everything, uninstall it, verify a clean
85-
# revert. A dirty uninstall (leftover env / registry / files / process) fails here and blocks the publish.
75+
# Install → verify → uninstall → verify-clean. Stable only (it really installs on the runner) — dev builds
76+
# skip it to stay fast, since every dev push runs this workflow.
8677
- name: Smoke-test install / uninstall
78+
if: steps.v.outputs.prerelease == 'false'
8779
run: bun run test:install
8880

89-
- name: Publish the Volt installer
90-
run: bun volt-scripts/build-installer.ts --upload-only
81+
- name: Publish
9182
env:
9283
GH_TOKEN: ${{ github.token }}
84+
VOLT_VERSION: ${{ steps.v.outputs.version }}
85+
run: bun volt-scripts/build-installer.ts --upload-only ${{ steps.v.outputs.prerelease == 'true' && '--prerelease' || '' }}
9386

94-
# Guard against the exact v0.2.1 failure: a publish that omits the installer. Fail loudly if Setup.exe (the
95-
# thing new users download) isn't on the release.
9687
- name: Verify the installer was published
9788
shell: bash
9889
env:
9990
GH_TOKEN: ${{ github.token }}
10091
run: |
101-
version=$(node -p "require('./packages/volt-desktop/package.json').version")
102-
assets=$(gh release view "${version}" --repo "${GITHUB_REPOSITORY}" --json assets --jq '.assets[].name')
103-
echo "published assets:"; echo "$assets"
92+
version='${{ steps.v.outputs.version }}'
93+
assets=$(gh release view "$version" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name')
10494
echo "$assets" | grep -qx "Volt-win-Setup.exe" || {
105-
echo "::error::release ${version} is missing Volt-win-Setup.exe — the installer did not publish"
95+
echo "::error::release $version is missing Volt-win-Setup.exe — the installer did not publish"
10696
exit 1
10797
}
108-
echo "✓ Volt-win-Setup.exe published on ${version}"
98+
echo "✓ Volt-win-Setup.exe published on $version"

‎packages/volt-cli/src/Volt.Cli.Connector/TrayContext.cs‎

Lines changed: 77 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public sealed class TrayContext : ApplicationContext
2727
private ToolStripMenuItem _headerItem = null!;
2828
private ToolStripMenuItem _connectItem = null!;
2929
private ToolStripMenuItem _updateItem = null!;
30+
private ToolStripSeparator _updateSeparator = null!;
3031
private string? _updateShown;
3132
private BridgeStatus _prevAggregate = BridgeStatus.Unknown;
3233

@@ -45,6 +46,8 @@ public TrayContext()
4546
ContextMenuStrip = BuildMenu(),
4647
};
4748
_icon.DoubleClick += (_, _) => _icon.ContextMenuStrip?.Show(Cursor.Position);
49+
// Clicking the "update available" toast starts the update directly — no hunting for the tray menu.
50+
_icon.BalloonTipClicked += (_, _) => { if (Updater.PendingVersion != null && !Updater.IsApplying) ApplyUpdate(); };
4851

4952
// Control plane (:8550) — the extension / desktop app see + drive the connection over the model.
5053
_control = new ControlServer(Snapshot, ConnectById, () => _conn.Disconnect(), RestartWorker);
@@ -64,11 +67,16 @@ private async Task TickAsync()
6467
await _conn.RefreshAsync();
6568

6669
var agg = _conn.Aggregate();
70+
var pending = Updater.PendingVersion;
6771
_icon.Icon = StatusIcons.For(agg);
68-
_icon.Text = Truncate("Volt Connector — " + StatusText(), 63);
72+
// Tooltip surfaces the update too, so it's discoverable on hover even after the toast fades.
73+
var tip = "Volt Connector — " + StatusText() + (pending != null ? " · update available" : "");
74+
_icon.Text = Truncate(tip, 63);
6975
if (agg != _prevAggregate) { OnAggregateChanged(_prevAggregate, agg); _prevAggregate = agg; }
7076

71-
_headerItem.Text = $"Volt Connector · {Updater.CurrentVersion}";
77+
_headerItem.Text = pending != null
78+
? $"Volt Connector · {Updater.CurrentVersion} → {pending}"
79+
: $"Volt Connector · {Updater.CurrentVersion}";
7280
RebuildConnectMenu();
7381
ShowUpdateIfReady();
7482
}
@@ -131,30 +139,38 @@ private ContextMenuStrip BuildMenu()
131139
menu.Items.Add(_headerItem);
132140
menu.Items.Add(new ToolStripSeparator());
133141

134-
_connectItem = new ToolStripMenuItem("Connect to") { Image = Glyph("") }; // Link
142+
// Update lives at the TOP (right under the header) so it's the first thing seen, accent-tinted + bold to
143+
// stand out. Hidden with its own separator until a newer release is available.
144+
_updateItem = new ToolStripMenuItem("Restart to update", Glyph(0xE777, VoltAccent), (_, _) => ApplyUpdate()) // UpdateRestore
145+
{
146+
Visible = false,
147+
ForeColor = VoltAccent,
148+
Font = new Font(SystemFonts.MenuFont ?? new Font("Segoe UI", 9f), FontStyle.Bold),
149+
};
150+
_updateSeparator = new ToolStripSeparator { Visible = false };
151+
menu.Items.Add(_updateItem);
152+
menu.Items.Add(_updateSeparator);
153+
154+
_connectItem = new ToolStripMenuItem("Connect to") { Image = Glyph(0xE71B) }; // Link
135155
_connectItem.DropDownItems.Add(new ToolStripMenuItem("(no project detected)") { Enabled = false });
136156
menu.Items.Add(_connectItem);
137157
menu.Items.Add(new ToolStripSeparator());
138158

139-
_updateItem = new ToolStripMenuItem("Restart to update", null, (_, _) =>
140-
{
141-
_updateItem.Enabled = false;
142-
_updateItem.Text = "Downloading update…";
143-
Updater.RestartToApply();
144-
}) { Visible = false, Image = Glyph("") }; // UpdateRestore
145-
menu.Items.Add(_updateItem);
146-
menu.Items.Add(new ToolStripMenuItem("Show logs", Glyph(""), (_, _) => ShowLogs())); // Page
159+
menu.Items.Add(new ToolStripMenuItem("Show logs", Glyph(0xE7C3), (_, _) => ShowLogs())); // Page
147160

148161
// ── Help ──
149162
menu.Items.Add(new ToolStripSeparator());
150-
menu.Items.Add(new ToolStripMenuItem("Activate in CODESYS…", Glyph("", VoltAccent), (_, _) => ShowCodesysActivation())); // Help
151-
menu.Items.Add(new ToolStripMenuItem("Exit", Glyph(""), (_, _) => ExitThreadCore())); // ChromeClose
163+
menu.Items.Add(new ToolStripMenuItem("Activate in CODESYS…", Glyph(0xE897, VoltAccent), (_, _) => ShowCodesysActivation())); // Help
164+
menu.Items.Add(new ToolStripMenuItem("Exit", Glyph(0xE8BB), (_, _) => ExitThreadCore())); // ChromeClose
152165
return menu;
153166
}
154167

155168
// Volt's accent (blue), used to tint the help glyph so it reads as a help affordance.
156169
private static readonly Color VoltAccent = Color.FromArgb(0x2F, 0x7C, 0xF6);
157170

171+
/// <summary>Menu icon by Segoe MDL2 codepoint (e.g. 0xE777) — avoids embedding raw glyph chars in source.</summary>
172+
private static Image Glyph(int codepoint, Color? color = null) => Glyph(char.ConvertFromUtf32(codepoint), color);
173+
158174
/// <summary>A 16×16 monochrome menu icon from the built-in Segoe MDL2 Assets glyph font (ships on
159175
/// Win10/11) — a themed icon with no image assets to bundle. Colour defaults to the menu text colour.</summary>
160176
private static Image Glyph(string ch, Color? color = null)
@@ -195,7 +211,7 @@ private void RebuildConnectMenu()
195211
}
196212
// Disconnect = clear the active connection (every host stays live). Enabled only when one is connected.
197213
_connectItem.DropDownItems.Add(new ToolStripSeparator());
198-
_connectItem.DropDownItems.Add(new ToolStripMenuItem("Disconnect", Glyph(""), (_, _) => _conn.Disconnect()) // PowerButton
214+
_connectItem.DropDownItems.Add(new ToolStripMenuItem("Disconnect", Glyph(0xE7E8), (_, _) => _conn.Disconnect()) // PowerButton
199215
{
200216
Enabled = _conn.ActiveConnection != null,
201217
});
@@ -228,14 +244,56 @@ private void ShowLogs()
228244
private void ShowUpdateIfReady()
229245
{
230246
var pending = Updater.PendingVersion;
231-
if (pending == null) return;
232-
_updateItem.Visible = true;
233-
_updateItem.Enabled = !Updater.IsApplying;
234-
_updateItem.Text = Updater.IsApplying ? "Downloading update…" : $"Restart to update to {pending}";
247+
var show = pending != null;
248+
_updateItem.Visible = show;
249+
_updateSeparator.Visible = show;
250+
if (!show) return;
251+
// While a download/apply is in flight, ApplyUpdate owns the item's text/enabled state — don't fight it.
252+
if (!Updater.IsApplying)
253+
{
254+
_updateItem.Enabled = true;
255+
_updateItem.Text = $"Restart to update to {pending}";
256+
}
235257
if (pending == _updateShown) return;
236258
_updateShown = pending;
237259
_icon.ShowBalloonTip(8000, "Volt update available",
238-
$"Volt {pending} is available. Pick “Restart to update to {pending}” from the tray.", ToolTipIcon.Info);
260+
$"Volt {pending} is available — click here to update, or pick “Restart to update” from the tray.", ToolTipIcon.Info);
261+
}
262+
263+
// The one-click update: download the installer, THEN orderly-stop everything holding {app} files so Inno's
264+
// silent upgrade never fails on a lock the Restart Manager can't clear (a tray/Electron window), then launch
265+
// it and exit. async void is correct here — it's a UI-thread action and the awaits resume on the UI thread.
266+
private async void ApplyUpdate()
267+
{
268+
if (Updater.IsApplying) return;
269+
_updateItem.Enabled = false;
270+
_updateItem.Text = "Downloading update…";
271+
var installer = await Updater.DownloadPendingAsync();
272+
if (installer == null) // download failed / already in flight — restore the action (the tick refreshes it)
273+
{
274+
_updateItem.Enabled = true;
275+
_updateItem.Text = $"Restart to update to {Updater.PendingVersion}";
276+
return;
277+
}
278+
_updateItem.Text = "Installing update…";
279+
// Stop the timer FIRST so it can't respawn a worker we're about to kill, then drop everything under {app}:
280+
// the bridge-worker child tree (supervisor) and the Electron GUI. Now the installer replaces free files.
281+
_timer.Stop();
282+
_supervisor.Dispose();
283+
CloseDesktopGui();
284+
Updater.LaunchInstallerAndExit(installer); // Process.Start(Setup) + Environment.Exit(0)
285+
}
286+
287+
/// <summary>Close the desktop GUI (the Electron shell, <c>Volt.exe</c>) if it's running, so the in-place
288+
/// upgrade can replace it — graceful close first, force-kill if it won't go. NOT the connector itself
289+
/// (VoltConnector) or the workers; the installer relaunches the connector when done.</summary>
290+
private static void CloseDesktopGui()
291+
{
292+
foreach (var p in System.Diagnostics.Process.GetProcessesByName("Volt"))
293+
{
294+
try { if (!p.CloseMainWindow() || !p.WaitForExit(3000)) p.Kill(); }
295+
catch { /* already gone / access denied — best effort */ }
296+
}
239297
}
240298

241299
private static string Truncate(string s, int max) => s.Length <= max ? s : s.Substring(0, max - 1) + "…";

0 commit comments

Comments
 (0)