A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.
feat(winget): automate WinGet manifest generation and submission with validation
CristianOlivera11d5ceb96872a
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 9b49a7d..c4e7d04 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -21,6 +21,10 @@ jobs:cache-dependency-path: apps/settings/pnpm-lock.yaml- uses: Swatinem/rust-cache@v2+ - name: Check WinGet automation without network or credentials+ shell: pwsh+ run: ./scripts/Test-WingetAutomation.ps1+# The settings app embeds its built front end at compile time.- name: Build settings UIworking-directory: apps/settingsdiff --git a/.github/workflows/winget.yml b/.github/workflows/winget.ymlindex 2a080af..dd903d2 100644--- a/.github/workflows/winget.yml+++ b/.github/workflows/winget.yml@@ -1,26 +1,97 @@name: winget-# When a release is published, opens a pull request in microsoft/winget-pkgs-# with the new version of CrafterStation.Muelle. It only works once the first-# version has been accepted there (submitted by hand; see FIRMA-DE-CODIGO.md),-# and only when the WINGET_TOKEN secret exists: a classic GitHub token with the-# public_repo scope, from an account that has a fork of winget-pkgs.on:release:- types: [released]+ types: [published]+ workflow_dispatch:+ inputs:+ tag:+ description: 'Published stable tag (empty = latest stable release)'+ type: string+ required: false+ submit:+ description: 'Submit a PR to microsoft/winget-pkgs (requires WINGET_TOKEN)'+ type: boolean+ default: false++permissions:+ contents: read++concurrency:+ group: winget-CrafterStation.Muelle+ cancel-in-progress: falsejobs:publish:+ if: github.event_name == 'workflow_dispatch' || !github.event.release.prereleaseruns-on: windows-latest- env:- WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }}+ timeout-minutes: 20+ defaults:+ run:+ shell: pwshsteps:- - name: Submit the new version to winget- if: env.WINGET_TOKEN != ''- uses: vedantmgoyal9/winget-releaser@v2+ - uses: actions/checkout@v4++ # Hosted Windows Server images do not always include App Installer.+ - name: Ensure the official WinGet validator is available+ run: |+ if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {+ Install-Module Microsoft.WinGet.Client -Repository PSGallery -Scope CurrentUser -Force+ Repair-WinGetPackageManager -Force -Latest+ }+ $aliases = Join-Path $env:LOCALAPPDATA 'Microsoft/WindowsApps'+ if (Test-Path -LiteralPath (Join-Path $aliases 'winget.exe')) {+ $env:PATH = "$aliases;$env:PATH"+ $aliases >> $env:GITHUB_PATH+ }+ winget --version+ if ($LASTEXITCODE) { throw 'WinGet is unavailable' }++ - name: Generate and validate the published installer manifest+ id: manifest+ env:+ GH_TOKEN: ${{ github.token }}+ RELEASE_TAG: ${{ inputs.tag || github.event.release.tag_name }}+ run: |+ $manifest = ./scripts/New-WingetManifest.ps1 -Tag $env:RELEASE_TAG -OutputRoot out/winget+ "directory=$($manifest.Directory)" >> $env:GITHUB_OUTPUT+ "version=$($manifest.Version)" >> $env:GITHUB_OUTPUT+ "## WinGet: CrafterStation.Muelle $($manifest.Version)" >> $env:GITHUB_STEP_SUMMARY+ "Validated SHA-256: ``$($manifest.Sha256)``" >> $env:GITHUB_STEP_SUMMARY+ "Installer: $($manifest.InstallerUrl)" >> $env:GITHUB_STEP_SUMMARY++ # Kept even when submission fails (missing/expired token, CLA, review).+ - name: Save validated manifests+ uses: actions/upload-artifact@v7with:- identifier: CrafterStation.Muelle- # The versioned file; Muelle-Setup.exe is the same installer under a- # name that never changes, which winget does not want.- installers-regex: '_x64-setup\.exe$'- token: ${{ secrets.WINGET_TOKEN }}+ name: winget-${{ steps.manifest.outputs.version }}+ path: out/winget+ retention-days: 30++ - name: Check submission credentials+ if: github.event_name == 'release' || inputs.submit+ env:+ WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_TOKEN }}+ run: |+ if (-not $env:WINGET_CREATE_GITHUB_TOKEN) {+ throw 'Add the WINGET_TOKEN repository secret and rerun with Submit enabled. The validated manifests are saved as an artifact. See FIRMA-DE-CODIGO.md.'+ }++ - name: Install the runtime required by the pinned submission tool+ if: github.event_name == 'release' || inputs.submit+ uses: actions/setup-dotnet@v4+ with:+ dotnet-version: '9.0.x'++ - name: Submit the first package or a new version+ if: github.event_name == 'release' || inputs.submit+ env:+ GH_TOKEN: ${{ github.token }}+ WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_TOKEN }}+ MANIFEST_DIRECTORY: ${{ steps.manifest.outputs.directory }}+ run: ./scripts/Submit-WingetManifest.ps1 -ManifestDirectory $env:MANIFEST_DIRECTORY++ - name: Explain preparation-only mode+ if: github.event_name == 'workflow_dispatch' && !inputs.submit+ run: |+ 'Preparation only: no PR was submitted. Run again with Submit enabled after configuring WINGET_TOKEN.' >> $env:GITHUB_STEP_SUMMARYdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex d1ca3f3..3a4828a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,9 @@ copia la sección de la versión que se publica a la release de GitHub.### English+- Automated WinGet manifest generation and submission for the first package and+ future stable releases, with manual retries, native validation, final installer+ checksum checks, duplicate detection and explicit missing-token failures.- Added bounded graphics-device recovery and recovery of an existing dock whenMuelle is opened again. The watchdog closes the old instance before restarting;a blocked recovery close has an eight-second deadline. Repeated device loss@@ -31,6 +34,9 @@ copia la sección de la versión que se publica a la release de GitHub.### Español+- Automatizada la generación y el envío de manifiestos de WinGet para la primera+ publicación y las próximas releases estables, con reintentos manuales, validación+ nativa, comprobación del hash final, detección de duplicados y error si falta el token.- Añadida recuperación limitada ante pérdida del dispositivo gráfico y al abrirMuelle de nuevo cuando ya existe una instancia. El guardián cierra la anteriorantes de reiniciarla; si el cierre de recuperación se bloquea, tiene un plazo dediff --git a/muelle/src/layouts/BaseLayout.astro b/muelle/src/layouts/BaseLayout.astroindex 66438bf..0742c17 100644--- a/muelle/src/layouts/BaseLayout.astro+++ b/muelle/src/layouts/BaseLayout.astro@@ -66,6 +66,7 @@ const schema = noindex || !product<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /><meta name="color-scheme" content="light dark" />+ <meta name="google-site-verification" content="MNGdMnCWivH5Bkg6WwcT-K_uSRLYkw1-dVJltkWgFPc" /><title>{title}</title><meta name="description" content={description} /><metadiff --git a/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.installer.yaml b/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.installer.yamlnew file mode 100644index 0000000..849cb15--- /dev/null+++ b/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.installer.yaml@@ -0,0 +1,27 @@+# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.10.0.schema.json+PackageIdentifier: CrafterStation.Muelle+PackageVersion: '0.1.16'+MinimumOSVersion: 10.0.19045.0+InstallerType: nullsoft+Scope: user+InstallModes:+ - interactive+ - silent+ - silentWithProgress+InstallerSwitches:+ Silent: /S+ SilentWithProgress: /P+UpgradeBehavior: install+ProductCode: Muelle+ReleaseDate: 2026-11-20+AppsAndFeaturesEntries:+ - DisplayName: Muelle+ Publisher: Muelle+ DisplayVersion: '0.1.16'+ ProductCode: Muelle+Installers:+ - Architecture: x64+ InstallerUrl: https://github.com/crafter-station/Muelle/releases/download/v0.1.16/Muelle_0.1.16_x64-setup.exe+ InstallerSha256: 80568BF463E307ADCEBF7FF1309AA251F0CE91778B08DA0094D802E5362EB8BF+ManifestType: installer+ManifestVersion: 1.10.0diff --git a/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.locale.en-US.yaml b/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.locale.en-US.yamlnew file mode 100644index 0000000..afca39a--- /dev/null+++ b/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.locale.en-US.yaml@@ -0,0 +1,23 @@+# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.10.0.schema.json+PackageIdentifier: CrafterStation.Muelle+PackageVersion: '0.1.16'+PackageLocale: en-US+Publisher: Muelle+PublisherUrl: https://github.com/crafter-station+PublisherSupportUrl: https://github.com/crafter-station/Muelle/issues+PrivacyUrl: https://muellee.vercel.app/privacy+PackageName: Muelle+PackageUrl: https://muellee.vercel.app+License: MIT+LicenseUrl: https://github.com/crafter-station/Muelle/blob/main/LICENSE+ShortDescription: A macOS-style dock and menu bar for Windows 10 and 11.+Description: Muelle replaces the Windows taskbar with a customizable dock, window previews and animations, and an optional menu bar. Quitting or uninstalling restores the Windows taskbar.+Moniker: muelle+Tags:+ - dock+ - taskbar+ - macos+ - launcher+ReleaseNotesUrl: https://github.com/crafter-station/Muelle/releases/tag/v0.1.16+ManifestType: defaultLocale+ManifestVersion: 1.10.0diff --git a/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.locale.es-MX.yaml b/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.locale.es-MX.yamlnew file mode 100644index 0000000..26e4acb--- /dev/null+++ b/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.locale.es-MX.yaml@@ -0,0 +1,8 @@+# yaml-language-server: $schema=https://aka.ms/winget-manifest.locale.1.10.0.schema.json+PackageIdentifier: CrafterStation.Muelle+PackageVersion: '0.1.16'+PackageLocale: es-MX+ShortDescription: Dock y barra superior al estilo de macOS para Windows 10 y 11.+Description: Muelle reemplaza la barra de tareas de Windows por un dock personalizable, con vistas previas de ventanas, animaciones y una barra superior opcional. Al salir o desinstalarlo restaura la barra de tareas de Windows.+ManifestType: locale+ManifestVersion: 1.10.0diff --git a/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.yaml b/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.yamlnew file mode 100644index 0000000..cb67487--- /dev/null+++ b/packaging/winget/manifests/c/CrafterStation/Muelle/0.1.16/CrafterStation.Muelle.yaml@@ -0,0 +1,6 @@+# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.10.0.schema.json+PackageIdentifier: CrafterStation.Muelle+PackageVersion: '0.1.16'+DefaultLocale: en-US+ManifestType: version+ManifestVersion: 1.10.0diff --git a/packaging/winget/templates/CrafterStation.Muelle.installer.yaml b/packaging/winget/templates/CrafterStation.Muelle.installer.yamlnew file mode 100644index 0000000..b54e31d--- /dev/null+++ b/packaging/winget/templates/CrafterStation.Muelle.installer.yaml@@ -0,0 +1,27 @@+# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.10.0.schema.json+PackageIdentifier: CrafterStation.Muelle+PackageVersion: '{{VERSION}}'+MinimumOSVersion: 10.0.19045.0+InstallerType: nullsoft+Scope: user+InstallModes:+ - interactive+ - silent+ - silentWithProgress+InstallerSwitches:+ Silent: /S+ SilentWithProgress: /P+UpgradeBehavior: install+ProductCode: Muelle+ReleaseDate: {{RELEASE_DATE}}+AppsAndFeaturesEntries:+ - DisplayName: Muelle+ Publisher: Muelle+ DisplayVersion: '{{VERSION}}'+ ProductCode: Muelle+Installers:+ - Architecture: x64+ InstallerUrl: {{INSTALLER_URL}}+ InstallerSha256: {{INSTALLER_SHA256}}+ManifestType: installer+ManifestVersion: 1.10.0diff --git a/packaging/winget/templates/CrafterStation.Muelle.locale.en-US.yaml b/packaging/winget/templates/CrafterStation.Muelle.locale.en-US.yamlnew file mode 100644index 0000000..939e6ac--- /dev/null+++ b/packaging/winget/templates/CrafterStation.Muelle.locale.en-US.yaml@@ -0,0 +1,23 @@+# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.10.0.schema.json+PackageIdentifier: CrafterStation.Muelle+PackageVersion: '{{VERSION}}'+PackageLocale: en-US+Publisher: Muelle+PublisherUrl: https://github.com/crafter-station+PublisherSupportUrl: https://github.com/crafter-station/Muelle/issues+PrivacyUrl: https://muellee.vercel.app/privacy+PackageName: Muelle+PackageUrl: https://muellee.vercel.app+License: MIT+LicenseUrl: https://github.com/crafter-station/Muelle/blob/main/LICENSE+ShortDescription: A macOS-style dock and menu bar for Windows 10 and 11.+Description: Muelle replaces the Windows taskbar with a customizable dock, window previews and animations, and an optional menu bar. Quitting or uninstalling restores the Windows taskbar.+Moniker: muelle+Tags:+ - dock+ - taskbar+ - macos+ - launcher+ReleaseNotesUrl: https://github.com/crafter-station/Muelle/releases/tag/v{{VERSION}}+ManifestType: defaultLocale+ManifestVersion: 1.10.0diff --git a/packaging/winget/templates/CrafterStation.Muelle.locale.es-MX.yaml b/packaging/winget/templates/CrafterStation.Muelle.locale.es-MX.yamlnew file mode 100644index 0000000..d6d14b7--- /dev/null+++ b/packaging/winget/templates/CrafterStation.Muelle.locale.es-MX.yaml@@ -0,0 +1,8 @@+# yaml-language-server: $schema=https://aka.ms/winget-manifest.locale.1.10.0.schema.json+PackageIdentifier: CrafterStation.Muelle+PackageVersion: '{{VERSION}}'+PackageLocale: es-MX+ShortDescription: Dock y barra superior al estilo de macOS para Windows 10 y 11.+Description: Muelle reemplaza la barra de tareas de Windows por un dock personalizable, con vistas previas de ventanas, animaciones y una barra superior opcional. Al salir o desinstalarlo restaura la barra de tareas de Windows.+ManifestType: locale+ManifestVersion: 1.10.0diff --git a/packaging/winget/templates/CrafterStation.Muelle.yaml b/packaging/winget/templates/CrafterStation.Muelle.yamlnew file mode 100644index 0000000..9122be1--- /dev/null+++ b/packaging/winget/templates/CrafterStation.Muelle.yaml@@ -0,0 +1,6 @@+# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.10.0.schema.json+PackageIdentifier: CrafterStation.Muelle+PackageVersion: '{{VERSION}}'+DefaultLocale: en-US+ManifestType: version+ManifestVersion: 1.10.0diff --git a/scripts/New-WingetManifest.ps1 b/scripts/New-WingetManifest.ps1new file mode 100644index 0000000..1747641--- /dev/null+++ b/scripts/New-WingetManifest.ps1@@ -0,0 +1,71 @@+# Requires PowerShell 7 and WinGet. Does not install or execute Muelle.+[CmdletBinding()]+param(+ [string]$Tag = '',+ [string]$OutputRoot = (Join-Path $PSScriptRoot '../packaging/winget')+)++$ErrorActionPreference = 'Stop'+$ProgressPreference = 'SilentlyContinue'+$repo = 'crafter-station/Muelle'+$id = 'CrafterStation.Muelle'+$versionPattern = '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)'+if ($Tag -and $Tag -cnotmatch "\Av?$versionPattern\z") {+ throw 'Tag must be a stable version such as v0.1.16.'+}+$headers = @{ Accept = 'application/vnd.github+json'; 'User-Agent' = 'Muelle-WinGet' }+if ($env:GH_TOKEN) { $headers.Authorization = "Bearer $env:GH_TOKEN" }+$endpoint = if ($Tag) { "tags/v$($Tag.TrimStart('v'))" } else { 'latest' }+$release = Invoke-RestMethod "https://api.github.com/repos/$repo/releases/$endpoint" -Headers $headers -TimeoutSec 60+if ($release.draft -or $release.prerelease -or $release.tag_name -cnotmatch "\Av$versionPattern\z") {+ throw 'Only published stable releases with a vX.Y.Z tag may be submitted.'+}+$version = $release.tag_name.Substring(1)+$filename = "Muelle_${version}_x64-setup.exe"+$url = "https://github.com/$repo/releases/download/v$version/$filename"+$assets = @($release.assets | Where-Object name -CEQ $filename)+if ($assets.Count -ne 1 -or $assets[0].browser_download_url -cne $url) {+ throw "Release v$version must contain exactly one versioned installer: $filename"+}+if (-not (Get-Command winget -ErrorAction SilentlyContinue)) { throw 'WinGet is required to validate manifests.' }++$download = Join-Path ([IO.Path]::GetTempPath()) "muelle-winget-$([guid]::NewGuid()).exe"+try {+ # Use the public, final release asset, after any Authenticode signing.+ Invoke-WebRequest $url -OutFile $download -TimeoutSec 120+ $file = Get-Item -LiteralPath $download+ $sha256 = (Get-FileHash -LiteralPath $download -Algorithm SHA256).Hash+ if ($file.Length -ne $assets[0].size) { throw 'The downloaded installer size differs from the release asset.' }+ if ($assets[0].digest -and $assets[0].digest -ine "sha256:$sha256") {+ throw 'The downloaded installer SHA-256 differs from the GitHub release digest.'+ }+ if ($file.VersionInfo.ProductVersion -ne $version -or $file.VersionInfo.ProductName -ne 'Muelle') {+ throw 'The installer product/version metadata differs from the release tag.'+ }+ $signature = Get-AuthenticodeSignature -LiteralPath $download+ if ($signature.Status -notin @('Valid', 'NotSigned') -or+ $signature.SignerCertificate.Thumbprint -eq '3A93532146A10D3B1FA8DEAF4192AD4A232FFCAC') {+ throw 'The installer has an invalid or test Authenticode signature; publish a production installer first.'+ }+ $directory = Join-Path ([IO.Path]::GetFullPath($OutputRoot, $PWD.Path)) "manifests/c/CrafterStation/Muelle/$version"+ New-Item -ItemType Directory -Force $directory | Out-Null+ $values = @{+ VERSION = $version+ INSTALLER_URL = $url+ INSTALLER_SHA256 = $sha256+ RELEASE_DATE = ([DateTimeOffset]$release.published_at).UtcDateTime.ToString('yyyy-MM-dd')+ }+ $templates = Join-Path $PSScriptRoot '../packaging/winget/templates'+ foreach ($name in @("$id.yaml", "$id.installer.yaml", "$id.locale.en-US.yaml", "$id.locale.es-MX.yaml")) {+ $content = Get-Content -LiteralPath (Join-Path $templates $name) -Raw+ foreach ($key in $values.Keys) { $content = $content.Replace("{{$key}}", $values[$key]) }+ if ($content -match '\{\{[A-Z_]+\}\}') { throw "Unresolved placeholder in $name" }+ [IO.File]::WriteAllText((Join-Path $directory $name), $content.Replace("`r`n", "`n"), [Text.UTF8Encoding]::new($false))+ }+ # Native output must not contaminate this script's structured return value.+ & winget validate --manifest $directory --disable-interactivity | Out-Host+ if ($LASTEXITCODE) { throw "WinGet rejected the generated manifest (exit $LASTEXITCODE)." }+ [pscustomobject]@{ Version = $version; Directory = $directory; Sha256 = $sha256; InstallerUrl = $url }+} finally {+ Remove-Item -LiteralPath $download -Force -ErrorAction SilentlyContinue+}diff --git a/scripts/Submit-WingetManifest.ps1 b/scripts/Submit-WingetManifest.ps1new file mode 100644index 0000000..ba66e22--- /dev/null+++ b/scripts/Submit-WingetManifest.ps1@@ -0,0 +1,71 @@+# Uses Microsoft's submission client for both a first package and updates.+# The PAT is read from WINGET_CREATE_GITHUB_TOKEN, never a command-line argument.+[CmdletBinding()]+param([Parameter(Mandatory)][string]$ManifestDirectory)++$ErrorActionPreference = 'Stop'+$ProgressPreference = 'SilentlyContinue'+$id = 'CrafterStation.Muelle'+$installer = Get-Content -LiteralPath (Join-Path $ManifestDirectory "$id.installer.yaml") -Raw+$version = [regex]::Match($installer, "(?m)^PackageVersion: '?([0-9]+\.[0-9]+\.[0-9]+)'?\s*$").Groups[1].Value+$sha256 = [regex]::Match($installer, '(?m)^\s+InstallerSha256: ([A-Fa-f0-9]{64})\s*$').Groups[1].Value+if (-not $version -or -not $sha256 -or $installer -notmatch '(?m)^PackageIdentifier: CrafterStation\.Muelle\s*$') {+ throw 'Expected a generated, validated CrafterStation.Muelle installer manifest.'+}+$headers = @{ Accept = 'application/vnd.github+json'; 'User-Agent' = 'Muelle-WinGet' }+$lookupToken = if ($env:WINGET_CREATE_GITHUB_TOKEN) { $env:WINGET_CREATE_GITHUB_TOKEN } else { $env:GH_TOKEN }+if ($lookupToken) { $headers.Authorization = "Bearer $lookupToken" }+function Get-GitHubJson([string]$Path) {+ try { Invoke-RestMethod "https://api.github.com/$Path" -Headers $headers -TimeoutSec 60 }+ catch {+ if ([int]$_.Exception.Response.StatusCode -eq 404) { return $null }+ throw+ }+}+function Write-Result([string]$Message) {+ Write-Host $Message+ if ($env:GITHUB_STEP_SUMMARY) { $Message >> $env:GITHUB_STEP_SUMMARY }+}++# Idempotent retries: do not replace a published hash or open duplicate PRs.+$existing = Get-GitHubJson "repos/microsoft/winget-pkgs/contents/manifests/c/CrafterStation/Muelle/$version/$id.installer.yaml"+if ($existing) {+ $published = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($existing.content))+ if ($published -notmatch "(?im)^\s*InstallerSha256: $sha256\s*$") {+ throw 'This version already exists in WinGet with a different hash. Publish a new version instead of replacing its installer.'+ }+ Write-Result "Already accepted in WinGet: $id $version. No PR was created."+ return+}+$query = [Uri]::EscapeDataString("repo:microsoft/winget-pkgs is:pr is:open in:title `"$id`" `"$version`"")+$prs = Get-GitHubJson "search/issues?q=$query&per_page=100"+$versionTitle = '(?<![\w.+-])' + [regex]::Escape($version) + '(?![\w.+-])'+$idTitle = '(?<![\w.-])' + [regex]::Escape($id) + '(?![\w.-])'+$open = $prs.items | Where-Object {+ $_.title -match $idTitle -and $_.title -match $versionTitle+} | Select-Object -First 1+if ($open) {+ Write-Result "Submission already awaiting review: $($open.html_url)"+ return+}+if (-not $env:WINGET_CREATE_GITHUB_TOKEN) {+ throw 'WINGET_TOKEN is missing. Add the repository Actions secret and rerun this workflow with Submit enabled; see FIRMA-DE-CODIGO.md. The validated artifact remains available.'+}++# Pin both version and digest; do not execute an unverified latest download.+$tool = Join-Path ([IO.Path]::GetTempPath()) "muelle-wingetcreate-$([guid]::NewGuid()).exe"+try {+ $package = Get-GitHubJson 'repos/microsoft/winget-pkgs/contents/manifests/c/CrafterStation/Muelle'+ $kind = if ($package) { 'New version' } else { 'New package' }+ Invoke-WebRequest 'https://github.com/microsoft/winget-create/releases/download/v1.28.1.0/wingetcreate.exe' -OutFile $tool -TimeoutSec 120+ if ((Get-FileHash -LiteralPath $tool -Algorithm SHA256).Hash -ne '63D980BA79E97042395BD6EB5992C2DB9E01E9E7A8A22958A95C288F27310413') {+ throw 'The Microsoft WinGetCreate download did not match its pinned SHA-256.'+ }+ & $tool submit --no-open --prtitle "${kind}: $id version $version" $ManifestDirectory+ if ($LASTEXITCODE) {+ throw "WinGetCreate submission failed (exit $LASTEXITCODE). Check the token permissions/expiry and Microsoft CLA; the validated artifact remains available."+ }+ Write-Result "Submitted $id $version to microsoft/winget-pkgs. Microsoft review and catalog indexing are still required."+} finally {+ Remove-Item -LiteralPath $tool -Force -ErrorAction SilentlyContinue+}diff --git a/scripts/Test-WingetAutomation.ps1 b/scripts/Test-WingetAutomation.ps1new file mode 100644index 0000000..a8b4027--- /dev/null+++ b/scripts/Test-WingetAutomation.ps1@@ -0,0 +1,132 @@+# Offline regression checks. Only test-owned temporary files are written;+# network, signature inspection and the native validator are replaced below.+$ErrorActionPreference = 'Stop'+$prepare = Join-Path $PSScriptRoot 'New-WingetManifest.ps1'+$submit = Join-Path $PSScriptRoot 'Submit-WingetManifest.ps1'+$root = Join-Path ([IO.Path]::GetTempPath()) "muelle-winget-test-$([guid]::NewGuid())"+$bytes = [Text.Encoding]::UTF8.GetBytes('Muelle installer fixture')+$hash = [Convert]::ToHexString([Security.Cryptography.SHA256]::HashData($bytes))+$savedToken = $env:WINGET_CREATE_GITHUB_TOKEN+$savedSummary = $env:GITHUB_STEP_SUMMARY+$savedExitCode = $global:LASTEXITCODE+$state = @{}+$state.downloads = 0+$state.validationExit = 0+$state.productVersion = '0.1.16'+$state.signatureStatus = 'NotSigned'+$state.certificateThumbprint = ''+$state.catalog = $null+$state.openPrs = @()+$state.fixture = [pscustomobject]@{+ tag_name = 'v0.1.16'; draft = $false; prerelease = $false+ published_at = '2026-11-20T00:56:52Z'+ assets = @([pscustomobject]@{+ name = 'Muelle_0.1.16_x64-setup.exe'; size = $bytes.Length; digest = "sha256:$hash"+ browser_download_url = 'https://github.com/crafter-station/Muelle/releases/download/v0.1.16/Muelle_0.1.16_x64-setup.exe'+ })+}+function Invoke-RestMethod {+ param($Uri, $Headers, $TimeoutSec)+ if ($Uri -like 'https://api.github.com/repos/crafter-station/Muelle/releases/*') { return $state.fixture }+ if ($Uri -like 'https://api.github.com/repos/microsoft/winget-pkgs/contents/*') { return $state.catalog }+ if ($Uri -like 'https://api.github.com/search/issues?*') { return @{ items = $state.openPrs } }+ throw "Unexpected test API call: $Uri"+}+function Invoke-WebRequest {+ param($Uri, $OutFile, $TimeoutSec)+ $state.downloads+++ [IO.File]::WriteAllBytes($OutFile, $bytes)+}+function Get-Item {+ param($LiteralPath)+ [pscustomobject]@{+ Length = $bytes.Length+ VersionInfo = @{ ProductVersion = $state.productVersion; ProductName = 'Muelle' }+ }+}+function Get-AuthenticodeSignature {+ param($LiteralPath)+ @{ Status = $state.signatureStatus; SignerCertificate = @{ Thumbprint = $state.certificateThumbprint } }+}+function winget {+ if ($args[0] -ne 'validate') { throw 'Only manifest validation is allowed in these tests.' }+ $global:LASTEXITCODE = $state.validationExit+}+# Capture the fixture object so a child script's scope cannot hide it.+foreach ($name in @('Invoke-RestMethod', 'Invoke-WebRequest', 'Get-Item', 'Get-AuthenticodeSignature', 'winget')) {+ $body = (Get-Command $name -CommandType Function).ScriptBlock+ Set-Item -LiteralPath "Function:$name" -Value ($body.GetNewClosure())+}+function Assert-Rejected([string]$Name, [scriptblock]$Action, [string]$Message) {+ $rejected = $false+ try { & $Action | Out-Null }+ catch {+ if ($_.Exception.Message -notlike $Message) { throw }+ $rejected = $true+ }+ if (-not $rejected) { throw "Failed to reject: $Name" }+ Write-Host "PASS: $Name"+}+try {+ $env:WINGET_CREATE_GITHUB_TOKEN = ''+ $env:GITHUB_STEP_SUMMARY = ''+ foreach ($file in @($prepare, $submit)) {+ $tokens = $null; $errors = $null+ $null = [Management.Automation.Language.Parser]::ParseFile($file, [ref]$tokens, [ref]$errors)+ if ($errors) { throw ($errors | Out-String) }+ }+ $manifest = & $prepare -Tag v0.1.16 -OutputRoot $root+ if ($manifest.Version -ne '0.1.16' -or $manifest.Sha256 -ne $hash -or+ @(Get-ChildItem -LiteralPath $manifest.Directory -Filter '*.yaml').Count -ne 4) {+ throw 'The valid release did not produce exactly four manifests with the computed hash.'+ }+ Write-Host 'PASS: stable published release generates four manifests'+ Assert-Rejected 'tag injection' { & $prepare -Tag 'v0.1.16; whoami' -OutputRoot $root } 'Tag must be*'+ $state.fixture.prerelease = $true+ Assert-Rejected 'prerelease' { & $prepare -OutputRoot $root } 'Only published stable releases*'+ $state.fixture.prerelease = $false+ $state.fixture.assets[0].browser_download_url = 'https://example.invalid/Muelle-Setup.exe'+ Assert-Rejected 'unversioned or foreign installer URL' { & $prepare -OutputRoot $root } '*exactly one versioned installer*'+ $state.fixture.assets[0].browser_download_url = 'https://github.com/crafter-station/Muelle/releases/download/v0.1.16/Muelle_0.1.16_x64-setup.exe'+ $state.fixture.assets[0].digest = 'sha256:BAD'+ Assert-Rejected 'altered asset digest' { & $prepare -OutputRoot $root } '*SHA-256 differs*'+ $state.fixture.assets[0].digest = "sha256:$hash"+ $state.productVersion = '0.1.15'+ Assert-Rejected 'mismatched installer version' { & $prepare -OutputRoot $root } '*product/version metadata*'+ $state.productVersion = '0.1.16'+ $state.signatureStatus = 'HashMismatch'+ Assert-Rejected 'invalid Authenticode' { & $prepare -OutputRoot $root } '*invalid or test Authenticode*'+ $state.signatureStatus = 'Valid'+ $state.certificateThumbprint = '3A93532146A10D3B1FA8DEAF4192AD4A232FFCAC'+ Assert-Rejected 'trusted local test certificate' { & $prepare -OutputRoot $root } '*invalid or test Authenticode*'+ $state.certificateThumbprint = ''+ $state.signatureStatus = 'NotSigned'+ $state.validationExit = 1+ Assert-Rejected 'native validator failure' { & $prepare -OutputRoot $root } 'WinGet rejected*'+ $state.validationExit = 0+ $beforeSubmit = $state.downloads+ Assert-Rejected 'missing submission token' { & $submit -ManifestDirectory $manifest.Directory } 'WINGET_TOKEN is missing*'+ $state.catalog = @{ content = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("InstallerSha256: $hash`n")) }+ & $submit -ManifestDirectory $manifest.Directory+ Write-Host 'PASS: accepted version is not resubmitted'+ $state.catalog = @{ content = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('InstallerSha256: DIFFERENT')) }+ Assert-Rejected 'replacing a published hash' { & $submit -ManifestDirectory $manifest.Directory } '*different hash*'+ $state.catalog = $null+ $state.openPrs = @(@{ title = 'New package: CrafterStation.Muelle.Beta version 0.1.16'; html_url = 'https://example.invalid/wrong-package' })+ Assert-Rejected 'other package is not treated as our PR' { & $submit -ManifestDirectory $manifest.Directory } 'WINGET_TOKEN is missing*'+ $state.openPrs = @(@{ title = 'New version: CrafterStation.Muelle version 0.1.160'; html_url = 'https://example.invalid/wrong-version' })+ Assert-Rejected 'other version is not treated as our PR' { & $submit -ManifestDirectory $manifest.Directory } 'WINGET_TOKEN is missing*'+ $state.openPrs = @(@{ title = 'New package: CrafterStation.Muelle version 0.1.16'; html_url = 'https://example.invalid/test-pr' })+ & $submit -ManifestDirectory $manifest.Directory+ if ($state.downloads -ne $beforeSubmit) { throw 'A duplicate/missing-token case downloaded a submission executable.' }+ Write-Host 'PASS: open PR is not duplicated; submission never executes a tool without a token'+} finally {+ $env:WINGET_CREATE_GITHUB_TOKEN = $savedToken+ $env:GITHUB_STEP_SUMMARY = $savedSummary+ $global:LASTEXITCODE = $savedExitCode+ # Check the absolute target before recursively removing the test directory.+ $resolved = [IO.Path]::GetFullPath($root)+ if (-not $resolved.StartsWith([IO.Path]::GetTempPath(), [StringComparison]::OrdinalIgnoreCase) -or+ -not [IO.Path]::GetFileName($resolved).StartsWith('muelle-winget-test-')) { throw 'Unsafe test cleanup path' }+ if (Test-Path -LiteralPath $resolved) { Remove-Item -LiteralPath $resolved -Recurse -Force }+}