Files
coucou/.github/workflows/windows.yml
Rhytam BiswasandClaude Sonnet 5.5 a9e5dee963 CI: checkout v7, setup-node v7, cache v6, upload-artifact v7, download-artifact v8
Version bumps only, in linux.yml, windows.yml and windows-ci.yml. build.yml, release.yml
and gradle/actions are not touched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 15:56:15 +05:30

164 lines
6.8 KiB
YAML

name: Windows
# Builds the Windows app and publishes the installer.
# Triggered by tags like `windows-v0.1.0`; the macOS workflows are untouched.
on:
push:
tags:
- 'windows-v*'
workflow_dispatch:
permissions:
contents: write
# Publishing is on: Microsoft reviewed the Defender false positive
# (Trojan:Win32/Wacatac.H!ml) and removed the detection. Before pushing a
# windows-v* tag, run this workflow by hand and scan the artifacts with Defender:
# a new unsigned build can still trip its machine-learning model. Set this to
# 'false' to build tags without publishing.
env:
PUBLISH: 'true'
jobs:
build:
runs-on: windows-latest
defaults:
run:
working-directory: windows
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
cache-dependency-path: windows/package-lock.json
- name: Cache cargo
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
windows/target
key: windows-cargo-${{ hashFiles('windows/Cargo.lock') }}
restore-keys: windows-cargo-
- name: Install dependencies
run: npm ci
# Three files carry the version and they drift silently. Publishing a
# "0.1.1" that installs a 0.1.0 is the kind of thing nobody notices until
# a bug report arrives against the wrong build.
- name: Check the tag and every version agree
if: startsWith(github.ref, 'refs/tags/windows-v')
shell: pwsh
run: |
$tag = "${{ github.ref_name }}" -replace '^windows-v', ''
$conf = (Get-Content src-tauri/tauri.conf.json | ConvertFrom-Json).version
$pkg = (Get-Content package.json | ConvertFrom-Json).version
$cargo = (Select-String -Path Cargo.toml -Pattern '^version\s*=\s*"(.+)"').Matches[0].Groups[1].Value
"tag=$tag tauri.conf=$conf package.json=$pkg Cargo.toml=$cargo"
$bad = @()
if ($tag -ne $conf) { $bad += "tauri.conf.json says $conf" }
if ($tag -ne $pkg) { $bad += "package.json says $pkg" }
if ($tag -ne $cargo) { $bad += "Cargo.toml says $cargo" }
if ($bad) { throw "tag says $tag but $($bad -join '; ')" }
# `npm run build` (run by tauri as beforeBuildCommand) builds coucou-hook
# first, which tauri.conf.json then bundles as a resource. `pack` then
# copies the installer out of target/ under its shipping name.
- name: Build and pack the installer
id: pack
shell: pwsh
run: |
npm run pack
$version = (Get-Content src-tauri/tauri.conf.json | ConvertFrom-Json).version
"version=$version" >> $env:GITHUB_OUTPUT
Get-ChildItem release | Format-Table Name, Length
# Upload only on a manual run or when publishing a release.
# The repo is public, so artifacts are downloadable by any signed-in GitHub
# user; the condition keeps them off automatic tag builds while downloads
# are paused. retention-days: 3 limits exposure.
- uses: actions/upload-artifact@v7
if: github.event_name == 'workflow_dispatch' || env.PUBLISH == 'true'
with:
name: Coucou-Windows-setup
path: windows/release/Coucou-Windows-${{ steps.pack.outputs.version }}-setup.exe
retention-days: 3
# MSI installer generated via WiX toolset. Bypasses NSIS extractor false-positives
# and provides clean native Windows Installer deployment.
- uses: actions/upload-artifact@v7
if: github.event_name == 'workflow_dispatch' || env.PUBLISH == 'true'
with:
name: Coucou-Windows-msi
path: windows/release/Coucou-Windows-${{ steps.pack.outputs.version }}.msi
retention-days: 3
# The unsigned NSIS installer is what Defender false-positives on, so the
# bare binaries go up as well. hooks.rs already falls back to looking for
# coucou-hook.exe next to coucou.exe, which is exactly this layout, so the
# portable pair runs with working Claude Code hooks and no installer.
- uses: actions/upload-artifact@v7
if: github.event_name == 'workflow_dispatch' || env.PUBLISH == 'true'
with:
name: Coucou-Windows-portable
path: |
windows/target/release/coucou.exe
windows/target/release/coucou-hook.exe
retention-days: 3
- name: Publish the release
if: env.PUBLISH == 'true' && startsWith(github.ref, 'refs/tags/windows-v')
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$v = "${{ steps.pack.outputs.version }}"
$notes = @"
Coucou for Windows $v — Mochi at the top of your screen.
Download ``Coucou-Windows-$v.msi`` (Windows Installer) or ``Coucou-Windows-$v-setup.exe`` and run it. The installer is not
code-signed yet, so Windows SmartScreen shows a warning: click
**More info → Run anyway**.
"@
# --latest=false is not cosmetic: without it GitHub hands "Latest" to
# whichever release was published last, and the site's Download for Mac
# button points at /releases/latest. A Windows tag would silently send
# Mac users to the .exe. The macOS `v*` releases own that slot.
gh release create "${{ github.ref_name }}" `
"release/Coucou-Windows-$v-setup.exe" `
"release/Coucou-Windows-$v.msi" `
--title "Coucou for Windows $v" `
--notes $notes `
--latest=false
- name: Update the rolling windows-latest release
if: env.PUBLISH == 'true' && startsWith(github.ref, 'refs/tags/windows-v')
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$v = "${{ steps.pack.outputs.version }}"
$exists = gh release view windows-latest 2>$null
if ($LASTEXITCODE -eq 0) {
# The tag has to follow the release, or windows-latest keeps pointing
# at the first commit it was ever created from and anyone building
# from it gets an old tree.
git tag -f windows-latest "${{ github.sha }}"
git push -f origin windows-latest
gh release edit windows-latest --title "Coucou for Windows (latest)" --notes "Always the newest Windows build — currently $v."
gh release upload windows-latest "release/Coucou-Windows-setup.exe" "release/Coucou-Windows.msi" --clobber
} else {
gh release create windows-latest `
"release/Coucou-Windows-setup.exe" `
"release/Coucou-Windows.msi" `
--title "Coucou for Windows (latest)" `
--notes "Always the newest Windows build — currently $v." `
--latest=false
}