From 91c99d9729ffb6b54e18833ecaf659b0f2d29d2d Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Wed, 21 Oct 2026 12:41:38 +0200 Subject: [PATCH 1/3] feat(release): publish the Windows build to winget; update through winget Each release renders packaging/winget/ (version, release date, the SHA-256 of the archive it built) and submits it to microsoft/winget-pkgs with wingetcreate (pinned by version and checksum), from the fork of the account whose token is the secret WINGET_TOKEN; without it the job warns and ends. Dry runs render and validate only. winget cannot replace a portable binary that runs (`remove_all: Access is denied`, measured with winget 1.29), and devstack's always runs: the hub, every stack's daemon. So `devstack update` on a devstack winget installed moves the running binary out of winget's directory, runs `winget upgrade --id nuetzliches.devstack`, and moves it back when winget put no new one there (also when winget's catalogue does not have the release yet). Measured with a portable package: the move-aside lets the upgrade succeed while the old process keeps running. `self uninstall` leaves the binary to `winget uninstall`. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 67 ++++++++++ CHANGELOG.md | 9 ++ README.md | 5 + SECURITY.md | 6 + crates/devstack/src/selfcmd.rs | 13 ++ crates/devstack/src/update.rs | 122 +++++++++++++++++- .../nuetzliches.devstack.installer.yaml | 20 +++ .../nuetzliches.devstack.locale.en-US.yaml | 39 ++++++ packaging/winget/nuetzliches.devstack.yaml | 8 ++ skills/devstack/SKILL.md | 1 + 10 files changed, 283 insertions(+), 7 deletions(-) create mode 100644 packaging/winget/nuetzliches.devstack.installer.yaml create mode 100644 packaging/winget/nuetzliches.devstack.locale.en-US.yaml create mode 100644 packaging/winget/nuetzliches.devstack.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec3c3ae7..efa2382a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,10 @@ name: release # read caches of main but not of another tag, and GitHub drops a cache unused # for 7 days, hence twice a week. # +# After the release, the Windows build goes to winget: job `winget` submits +# the manifests of packaging/winget/ as a pull request to +# microsoft/winget-pkgs (a dry run only renders and checks them). +# # Actions are pinned by commit SHA (the comment names the release); # Dependabot (.github/dependabot.yml) proposes updates. @@ -23,6 +27,7 @@ on: - '.github/workflows/release.yml' - 'install.ps1' - 'install.sh' + - 'packaging/winget/**' workflow_dispatch: schedule: - cron: '17 3 * * 1,4' @@ -163,3 +168,65 @@ jobs: run: | gh release create "$GITHUB_REF_NAME" dist/* --verify-tag \ --title "devstack ${GITHUB_REF_NAME#v}" --generate-notes + + winget: + # The manifests of packaging/winget/ with this release's version and the + # checksum of the archive just built, checked, and on a tag submitted to + # microsoft/winget-pkgs by wingetcreate (Microsoft, MIT; pinned by + # version and checksum). Its review takes days; `winget upgrade` offers + # the release once it is merged. The pull request comes from the fork of + # winget-pkgs of the account whose token is the secret WINGET_TOKEN (a + # classic token with `public_repo`); without the secret the job says so + # and ends. + needs: [build, publish] + if: ${{ !cancelled() && needs.build.result == 'success' && needs.publish.result != 'failure' }} + runs-on: windows-latest + env: + WINGETCREATE_VERSION: 1.12.13.0 + WINGETCREATE_SHA256: 24042BD37915805615E6CF969AC57C6439124C3FE85823327F5F3FB24BD9FFEA + HAS_TOKEN: ${{ secrets.WINGET_TOKEN != '' }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: x86_64-pc-windows-msvc + path: dist + - name: manifests + shell: pwsh + run: | + $version = if ($env:GITHUB_REF -like 'refs/tags/v*') { $env:GITHUB_REF_NAME.Substring(1) } else { (Select-String -Path Cargo.toml -Pattern '^version = "(.+)"' | Select-Object -First 1).Matches[0].Groups[1].Value } + $sha = (Get-FileHash dist/devstack-x86_64-pc-windows-msvc.zip -Algorithm SHA256).Hash + $date = (Get-Date).ToUniversalTime().ToString('yyyy-MM-dd') + $out = "winget/$version" + New-Item -ItemType Directory -Force $out | Out-Null + foreach ($f in Get-ChildItem packaging/winget -Filter *.yaml) { + $text = [IO.File]::ReadAllText($f.FullName) -replace '\{\{version\}\}', $version -replace '\{\{sha256\}\}', $sha -replace '\{\{date\}\}', $date + if ($text -match '\{\{') { throw "$($f.Name): a placeholder is left" } + [IO.File]::WriteAllText((Join-Path $out $f.Name), $text, [Text.UTF8Encoding]::new($false)) + } + # The archive holds what the manifest names. + Expand-Archive dist/devstack-x86_64-pc-windows-msvc.zip -DestinationPath unpacked + if (-not (Test-Path unpacked/devstack.exe)) { throw 'devstack.exe is not at the root of the archive' } + "MANIFESTS=$out" >> $env:GITHUB_ENV + Get-Content "$out/nuetzliches.devstack.installer.yaml" + - name: validate + shell: pwsh + run: | + if (Get-Command winget -ErrorAction SilentlyContinue) { + winget validate --manifest $env:MANIFESTS --disable-interactivity + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + } else { + "::notice::no winget on this runner; wingetcreate checks the manifests when it submits them" + } + - name: submit + if: startsWith(github.ref, 'refs/tags/v') + shell: pwsh + env: + WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_TOKEN }} + run: | + if ($env:HAS_TOKEN -ne 'true') { "::warning::no WINGET_TOKEN: not submitted to winget"; exit 0 } + Invoke-WebRequest "https://github.com/microsoft/winget-create/releases/download/v$env:WINGETCREATE_VERSION/wingetcreate.exe" -OutFile wingetcreate.exe + $hash = (Get-FileHash wingetcreate.exe -Algorithm SHA256).Hash + if ($hash -ne $env:WINGETCREATE_SHA256) { throw "wingetcreate.exe: checksum $hash, expected $env:WINGETCREATE_SHA256" } + ./wingetcreate.exe submit --no-open --prtitle "New version: nuetzliches.devstack version $($env:GITHUB_REF_NAME.Substring(1))" $env:MANIFESTS + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b81d912..54a94acf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,15 @@ and listed with their assets on the ### Added +- **winget**: `winget install nuetzliches.devstack` (once winget's catalogue + has the release). Each release submits its manifests + (`packaging/winget/`) to `microsoft/winget-pkgs`; the release workflow + needs the secret `WINGET_TOKEN` for it. `devstack update` (and the + dashboard's update) on a devstack winget installed runs `winget upgrade`, + moving the running binary out of winget's way first, since winget cannot + replace a file that runs; `devstack self uninstall` leaves that binary to + `winget uninstall`. + - **`prepare.link`** (ADR-0044, #159): directories `prepare` installs in a lane's copy (`link = ["web/node_modules"]`) are linked into the lane's worktree, a junction on Windows, so git hooks there (`npx eslint` in a diff --git a/README.md b/README.md index 9433179c..794c549d 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,11 @@ irm https://github.com/nuetzliches/devstack/releases/latest/download/install.ps1 curl -fsSL https://github.com/nuetzliches/devstack/releases/latest/download/install.sh | sh ``` +On Windows, `winget install nuetzliches.devstack` installs the same build +(releases after 0.15.0, once winget's catalogue has them, usually a few days +after the release); `devstack update` then updates it through winget, and +the first `devstack up` registers the hub as the installer would. + The scripts and `devstack update` check the download against the release's `SHA256SUMS`: that proves the archive is the one the release lists (not damaged or swapped on the way), not who built it, since both come from the diff --git a/SECURITY.md b/SECURITY.md index 6132e5be..bc50ace6 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -196,6 +196,12 @@ A pool is a group of machines that trust each other to a stated degree --signer-workflow nuetzliches/devstack/.github/workflows/release.yml`) and stop if it fails, showing gh's reason; you can run the same command yourself. +- The winget package `nuetzliches.devstack` names the release's archive on + GitHub and its SHA-256, taken by the release workflow from the archive it + built and published; winget checks the download against it. Its manifests + (`packaging/winget/`) go through the review of `microsoft/winget-pkgs` + before winget offers a release. A devstack winget installed is updated + through winget, never replaced behind its back. - `devstack update`, and a server node an admin updates ([ADR-0039](docs/adr/0039-an-admin-can-update-a-server-node.md)), check only `SHA256SUMS`: the trust is GitHub's TLS and control of this diff --git a/crates/devstack/src/selfcmd.rs b/crates/devstack/src/selfcmd.rs index 5c29ca83..832737d3 100644 --- a/crates/devstack/src/selfcmd.rs +++ b/crates/devstack/src/selfcmd.rs @@ -144,6 +144,7 @@ pub fn uninstall(yes: bool, with_coordinator: bool) -> Result<()> { let exe = std::env::current_exe()?; let ours = install_dir().is_some_and(|d| exe.parent() == Some(d.as_path())); + let winget = crate::update::is_winget_install(&exe); println!("devstack self uninstall removes:"); println!(" - the dashboard hub, its start at logon and the devstack:// link"); println!(" - {} (token, list of stacks, hub log)", root.display()); @@ -161,6 +162,12 @@ pub fn uninstall(yes: bool, with_coordinator: bool) -> Result<()> { } if ours { println!(" - {} and its PATH entry", exe.display()); + } else if winget { + println!( + " (not {}: winget installed it, `winget uninstall {}` removes it)", + exe.display(), + crate::update::WINGET_ID + ); } else { println!( " (not {}: it is not where the installer puts devstack)", @@ -207,6 +214,12 @@ pub fn uninstall(yes: bool, with_coordinator: bool) -> Result<()> { exe.parent().unwrap().display() ); } + if winget { + println!( + "The binary stays: `winget uninstall {}` removes it.", + crate::update::WINGET_ID + ); + } Ok(()) } diff --git a/crates/devstack/src/update.rs b/crates/devstack/src/update.rs index c1881aab..69da288e 100644 --- a/crates/devstack/src/update.rs +++ b/crates/devstack/src/update.rs @@ -7,6 +7,9 @@ //! shell environment: Windows PowerShell 5.1 started from PowerShell 7 finds //! the wrong modules and has no `Get-FileHash` (#12). //! +//! A devstack winget installed is updated by winget (`winget_upgrade`), so +//! its record of the version stays true. +//! //! Running stacks keep their daemon (and its version) until they restart; the //! dashboard offers that ("Restart stack"), the CLI says it. @@ -66,13 +69,17 @@ pub fn run(check_only: bool, version: Option<&str>) -> Result<()> { ); } println!("installing devstack {target} ..."); - // Where the installers put devstack, or the running copy if it lives - // elsewhere. - let into = crate::selfcmd::install_dir() - .map(|d| d.join(EXE)) - .filter(|p| p.is_file()) - .unwrap_or_else(|| exe.clone()); - let installed = install(&target, &into)?; + let installed = if is_winget_install(&exe) { + winget_upgrade(&exe, version.map(|_| target.as_str()))? + } else { + // Where the installers put devstack, or the running copy if it lives + // elsewhere. + let into = crate::selfcmd::install_dir() + .map(|d| d.join(EXE)) + .filter(|p| p.is_file()) + .unwrap_or_else(|| exe.clone()); + install(&target, &into)? + }; // The hub runs the old binary: stop it, start the new one. let _ = crate::hubcmd::stop(); @@ -261,6 +268,83 @@ fn is_cargo_install(exe: &Path) -> bool { && parts.next().is_some_and(|c| c.as_os_str() == ".cargo") } +/// The package winget installs devstack as (`packaging/winget/`). +pub(crate) const WINGET_ID: &str = "nuetzliches.devstack"; + +/// winget keeps a portable package in `...\WinGet\Packages\_\` +/// and puts a link to it in `...\WinGet\Links\` (per user under +/// `%LOCALAPPDATA%\Microsoft`, for the machine under `%ProgramFiles%`). +/// Replacing that binary behind winget's back leaves winget with the old +/// version on record. +pub(crate) fn is_winget_install(exe: &Path) -> bool { + let path = exe + .to_string_lossy() + .replace('/', "\\") + .to_ascii_lowercase(); + path.contains(r"\winget\packages\") || path.contains(r"\winget\links\") +} + +/// Update a devstack winget installed, through winget, so winget keeps the +/// version on record. winget cannot replace a binary that runs (the hub, +/// every stack's daemon): `remove_all: Access is denied`, measured with +/// winget 1.29. So the running file moves out of winget's directory first, +/// as `replace` does for the installers' copy (a running executable can be +/// moved on its volume, not overwritten), and back again when winget did +/// not put a new one there. Returns the path of the new binary. +fn winget_upgrade(exe: &Path, version: Option<&str>) -> Result { + // The file itself, not winget's link to it. + let real = plain(std::fs::canonicalize(exe)?); + let aside_dir = devstack_daemon::token::token_path() + .parent() + .expect("token path has a parent") + .join("replaced"); + std::fs::create_dir_all(&aside_dir)?; + for e in std::fs::read_dir(&aside_dir)?.flatten() { + let _ = std::fs::remove_file(e.path()); // still running: next time + } + let stamp = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map_or(0, |d| d.as_nanos()); + let aside = aside_dir.join(format!("devstack-{stamp}.exe")); + if let Err(e) = std::fs::rename(&real, &aside) { + bail!( + "cannot move the running {} out of winget's way ({e}); stop the hub (`devstack hub stop`) \ + and every stack (`devstack down`), then run `winget upgrade {WINGET_ID}`", + real.display() + ); + } + let mut cmd = std::process::Command::new("winget"); + cmd.args(["upgrade", "--id", WINGET_ID, "--exact", "--silent"]) + .args(["--accept-package-agreements", "--accept-source-agreements"]) + .arg("--disable-interactivity"); + if let Some(v) = version { + cmd.args(["--version", v]); + } + let ran = cmd.status(); + if ran.as_ref().is_ok_and(|s| s.success()) && real.is_file() { + return Ok(real); + } + if !real.exists() { + let _ = std::fs::rename(&aside, &real); + } + match ran { + Err(e) => bail!("cannot run winget ({e}); devstack is unchanged"), + Ok(_) => bail!( + "winget did not upgrade devstack (see above); it is unchanged. A release reaches winget's \ + catalogue a few days after GitHub: `winget upgrade {WINGET_ID}` later picks it up" + ), + } +} + +/// `\\?\C:\...` (what `canonicalize` gives on Windows) as `C:\...`, which +/// every program understands. +fn plain(p: PathBuf) -> PathBuf { + match p.to_str().and_then(|s| s.strip_prefix(r"\\?\")) { + Some(rest) if !rest.starts_with("UNC\\") => PathBuf::from(rest), + _ => p, + } +} + /// Write `binary` to `path` and make sure it is on disk before it is used. fn write_synced(path: &Path, binary: &[u8]) -> std::io::Result<()> { use std::io::Write; @@ -375,6 +459,30 @@ mod tests { assert!(!is_cargo_install(Path::new("/home/u/.local/bin/devstack"))); } + #[test] + fn a_winget_install_is_recognised() { + for winget in [ + r"C:\Users\u\AppData\Local\Microsoft\WinGet\Packages\nuetzliches.devstack_Microsoft.Winget.Source_8wekyb3d8bbwe\devstack.exe", + r"C:\Users\u\AppData\Local\Microsoft\WinGet\Links\devstack.exe", + r"C:\Program Files\WinGet\Packages\nuetzliches.devstack_Microsoft.Winget.Source_8wekyb3d8bbwe\devstack.exe", + ] { + assert!(is_winget_install(Path::new(winget)), "{winget}"); + } + for not in [ + r"C:\Users\u\AppData\Local\Programs\devstack\devstack.exe", + r"C:\src\winget-packages\devstack.exe", + "/home/u/.local/bin/devstack", + ] { + assert!(!is_winget_install(Path::new(not)), "{not}"); + } + assert_eq!( + plain(PathBuf::from(r"\\?\C:\Users\u\devstack.exe")), + PathBuf::from(r"C:\Users\u\devstack.exe") + ); + let unc = PathBuf::from(r"\\?\UNC\host\share\devstack.exe"); + assert_eq!(plain(unc.clone()), unc); + } + #[test] fn a_replaced_running_binary_is_found_at_its_path() { let gone = PathBuf::from("/usr/local/bin/devstack (deleted)"); diff --git a/packaging/winget/nuetzliches.devstack.installer.yaml b/packaging/winget/nuetzliches.devstack.installer.yaml new file mode 100644 index 00000000..652f4be2 --- /dev/null +++ b/packaging/winget/nuetzliches.devstack.installer.yaml @@ -0,0 +1,20 @@ +# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.12.0.schema.json +# Template: the release workflow fills in {{version}}, {{date}} and {{sha256}} +# (from the release's SHA256SUMS) and submits it (release.yml, job winget). + +PackageIdentifier: nuetzliches.devstack +PackageVersion: {{version}} +InstallerType: zip +NestedInstallerType: portable +NestedInstallerFiles: +- RelativeFilePath: devstack.exe + PortableCommandAlias: devstack +Commands: +- devstack +ReleaseDate: {{date}} +Installers: +- Architecture: x64 + InstallerUrl: https://github.com/nuetzliches/devstack/releases/download/v{{version}}/devstack-x86_64-pc-windows-msvc.zip + InstallerSha256: {{sha256}} +ManifestType: installer +ManifestVersion: 1.12.0 diff --git a/packaging/winget/nuetzliches.devstack.locale.en-US.yaml b/packaging/winget/nuetzliches.devstack.locale.en-US.yaml new file mode 100644 index 00000000..07602e7a --- /dev/null +++ b/packaging/winget/nuetzliches.devstack.locale.en-US.yaml @@ -0,0 +1,39 @@ +# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.12.0.schema.json +# Template: the release workflow fills in {{version}} and submits it (release.yml, job winget). + +PackageIdentifier: nuetzliches.devstack +PackageVersion: {{version}} +PackageLocale: en-US +Publisher: nuetzliches +PublisherUrl: https://github.com/nuetzliches +PublisherSupportUrl: https://github.com/nuetzliches/devstack/issues +PackageName: devstack +PackageUrl: https://github.com/nuetzliches/devstack +License: MIT OR Apache-2.0 +LicenseUrl: https://github.com/nuetzliches/devstack/blob/main/LICENSE-MIT +ShortDescription: Local development orchestrator for a whole stack, its worktrees and its containers +Description: |- + devstack runs a repository's whole stack on a developer machine: native + services, their Compose infrastructure and every git worktree beside it, + each from a build that compiled and passed its health check, so the running + stack never breaks on a broken save. One CLI, one dashboard in the browser + and one MCP server for coding agents; lanes can run on a team's server. +Moniker: devstack +Tags: +- cli +- compose +- developer-tools +- docker +- git-worktree +- mcp +- orchestrator +InstallationNotes: |- + `devstack doctor` checks the machine; `devstack init` drafts a devstack.toml + in a repository, `devstack up` starts it. `devstack update` updates through + winget. +ReleaseNotesUrl: https://github.com/nuetzliches/devstack/releases/tag/v{{version}} +Documentations: +- DocumentLabel: Stack file reference + DocumentUrl: https://github.com/nuetzliches/devstack/blob/main/docs/stack-file.md +ManifestType: defaultLocale +ManifestVersion: 1.12.0 diff --git a/packaging/winget/nuetzliches.devstack.yaml b/packaging/winget/nuetzliches.devstack.yaml new file mode 100644 index 00000000..3a3639e0 --- /dev/null +++ b/packaging/winget/nuetzliches.devstack.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.12.0.schema.json +# Template: the release workflow fills in {{version}} and submits it (release.yml, job winget). + +PackageIdentifier: nuetzliches.devstack +PackageVersion: {{version}} +DefaultLocale: en-US +ManifestType: version +ManifestVersion: 1.12.0 diff --git a/skills/devstack/SKILL.md b/skills/devstack/SKILL.md index f2d7c346..2c529310 100644 --- a/skills/devstack/SKILL.md +++ b/skills/devstack/SKILL.md @@ -25,6 +25,7 @@ install it yourself. ```powershell # Windows irm https://github.com/nuetzliches/devstack/releases/latest/download/install.ps1 | iex +# or, once winget has the release: winget install nuetzliches.devstack ``` ```bash From b9839e666dc2d6df54f83d047bf6b4ee2023ffa9 Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Wed, 21 Oct 2026 13:11:00 +0200 Subject: [PATCH 2/3] fix(release): a winget validation with warnings does not fail the job Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index efa2382a..7a59d1b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -213,8 +213,13 @@ jobs: shell: pwsh run: | if (Get-Command winget -ErrorAction SilentlyContinue) { - winget validate --manifest $env:MANIFESTS --disable-interactivity - if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + "winget $(winget --version)" + # An older winget on the runner warns about a newer schema in the + # header comment, and exits non-zero for that too: only a failed + # validation fails the job. + $out = winget validate --manifest $env:MANIFESTS --disable-interactivity 2>&1 | Out-String + $out + if ($LASTEXITCODE -ne 0 -and $out -notmatch 'succeeded with warnings') { exit 1 } } else { "::notice::no winget on this runner; wingetcreate checks the manifests when it submits them" } From e1d4639cdf94d1c82769a05c39723604e266b56c Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Wed, 21 Oct 2026 13:18:13 +0200 Subject: [PATCH 3/3] fix(release): the winget check ends with its own verdict, not winget's exit code Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a59d1b0..dd958ab9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -220,6 +220,7 @@ jobs: $out = winget validate --manifest $env:MANIFESTS --disable-interactivity 2>&1 | Out-String $out if ($LASTEXITCODE -ne 0 -and $out -notmatch 'succeeded with warnings') { exit 1 } + exit 0 # the step would end with winget's exit code otherwise } else { "::notice::no winget on this runner; wingetcreate checks the manifests when it submits them" }