Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
42ca078
feat: Add Windows support
littlekirkycode Mar 14, 2026
f9e4e45
fix: Make build and dev scripts cross-platform for Windows support
littlekirkycode Mar 14, 2026
1f86128
fix: Remove duplicate patchedDependencies from package.json
littlekirkycode Mar 14, 2026
4c99295
fix: Remove maker-squirrel, use ZIP maker for Windows builds
littlekirkycode Mar 14, 2026
ef2b71c
fix: Add Squirrel installer for Windows and fix invisible window
littlekirkycode Mar 14, 2026
9446064
fix(code): fix file path doubling on Windows
littlekirkycode Mar 16, 2026
d643880
fix(code): prevent Windows title bar buttons overlapping git actions
littlekirkycode Mar 16, 2026
c612ceb
fix(code): fix fonts not loading in packaged builds
littlekirkycode Mar 16, 2026
d1a440a
fix: Windows compatibility for symlinks, paths, and font loading
littlekirkycode Mar 16, 2026
8b0f690
fix: Windows compatibility for symlinks, paths, and font loading
littlekirkycode Mar 16, 2026
202f52e
Merge branch 'main' into feat/windows-support
littlekirkycode Mar 18, 2026
8063a39
fix: resolve merge conflicts with main and fix CI failures
littlekirkycode Mar 18, 2026
60a6669
Merge branch 'main' into feat/windows-support
littlekirkycode Mar 19, 2026
76e3ec6
Merge branch 'main' into feat/windows-support
littlekirkycode Mar 19, 2026
f24fc5c
Fix CI: add missing maker-squirrel dep and fix shell injection
littlekirkycode Mar 19, 2026
47bac9c
Merge remote-tracking branch 'origin/main' into feat/windows-support
littlekirkycode Mar 20, 2026
4dd1085
fix(code): validate OTEL export URL before creating exporter
littlekirkycode Mar 20, 2026
48abee2
fix: allow electron-winstaller install script in pnpm
littlekirkycode Mar 20, 2026
e79f96d
Merge branch 'main' of github.com:PostHog/Twig into feat/windows-support
jonathanlab Mar 23, 2026
cd7d629
Merge branch 'main' into feat/windows-support
jonathanlab Mar 23, 2026
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
75 changes: 74 additions & 1 deletion .github/workflows/code-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
cancel-in-progress: false

jobs:
publish:
publish-macos:
runs-on: macos-latest
permissions:
id-token: write
Expand Down Expand Up @@ -129,3 +129,76 @@ jobs:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
APP_VERSION: ${{ steps.version.outputs.version }}
run: gh release edit "v$APP_VERSION" --repo PostHog/code --draft=false

publish-windows:
runs-on: windows-latest
permissions:
id-token: write
contents: write
env:
NODE_OPTIONS: "--max-old-space-size=8192"
NODE_ENV: production
VITE_POSTHOG_API_KEY: ${{ secrets.VITE_POSTHOG_API_KEY }}
VITE_POSTHOG_API_HOST: ${{ secrets.VITE_POSTHOG_API_HOST }}
steps:
- name: Get app token
id: app-token
uses: getsentry/action-github-app-token@d4b5da6c5e37703f8c3b3e43abb5705b46e159cc # v3
with:
app_id: ${{ secrets.GH_APP_ARRAY_RELEASER_APP_ID }}
private_key: ${{ secrets.GH_APP_ARRAY_RELEASER_PRIVATE_KEY }}

- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false

- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4

- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
cache: "pnpm"

- name: Extract version from tag
id: version
shell: pwsh
run: |
$tagVersion = "${{ github.ref }}" -replace "refs/tags/v", ""
echo "Version: $tagVersion"
echo "version=$tagVersion" >> $env:GITHUB_OUTPUT

- name: Set version in package.json
shell: pwsh
env:
APP_VERSION: ${{ steps.version.outputs.version }}
run: |
$pkg = Get-Content apps/code/package.json -Raw | ConvertFrom-Json
$pkg.version = "$env:APP_VERSION"
$pkg | ConvertTo-Json -Depth 10 | Set-Content apps/code/package.json
echo "Set apps/code/package.json version to $env:APP_VERSION"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build electron-trpc package
run: pnpm --filter @posthog/electron-trpc run build

- name: Build shared package
run: pnpm --filter @posthog/shared run build

- name: Build git package
run: pnpm --filter @posthog/git run build

- name: Build agent package
run: pnpm --filter @posthog/agent run build

- name: Publish with Electron Forge
env:
APP_VERSION: ${{ steps.version.outputs.version }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: pnpm --filter code run publish
38 changes: 26 additions & 12 deletions apps/code/forge.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { ChildProcess } from "node:child_process";
import { execSync } from "node:child_process";
import { cpSync, existsSync, mkdirSync, rmSync, statSync } from "node:fs";
import { cpSync, existsSync, mkdirSync, rmSync } from "node:fs";
import path from "node:path";
import { MakerDMG } from "@electron-forge/maker-dmg";
import { MakerSquirrel } from "@electron-forge/maker-squirrel";
import { MakerZIP } from "@electron-forge/maker-zip";
import { VitePlugin } from "@electron-forge/plugin-vite";
import { PublisherGithub } from "@electron-forge/publisher-github";
Expand Down Expand Up @@ -181,28 +182,30 @@ const config: ForgeConfig = {
}
: {}),
}),
new MakerZIP({}, ["darwin", "linux", "win32"]),
new MakerSquirrel({
name: "PostHogCode",
setupIcon: "./build/app-icon.ico",
}),
new MakerZIP({}, ["darwin", "linux"]),
],
hooks: {
generateAssets: async () => {
const isNewer = (src: string, dest: string) =>
!existsSync(dest) || statSync(src).mtimeMs > statSync(dest).mtimeMs;
if (process.platform !== "darwin") return;

if (
existsSync("build/app-icon.png") &&
isNewer("build/app-icon.png", "build/app-icon.icns")
!existsSync("build/app-icon.icns")
) {
execSync("bash scripts/generate-icns.sh", { stdio: "inherit" });
}

if (
existsSync("build/icon.icon") &&
isNewer("build/icon.icon/icon.json", "build/Assets.car")
) {
if (existsSync("build/icon.icon") && !existsSync("build/Assets.car")) {
execSync("bash scripts/compile-glass-icon.sh", { stdio: "inherit" });
}
},
prePackage: async () => {
if (process.platform !== "darwin") return;

// Build native modules for DMG maker on Node.js 22
const modules = ["macos-alias", "fs-xattr"];

Expand All @@ -221,9 +224,20 @@ const config: ForgeConfig = {
copyNativeDependency("node-pty", buildPath);
copyNativeDependency("node-addon-api", buildPath);
copyNativeDependency("@parcel/watcher", buildPath);
copyNativeDependency("@parcel/watcher-darwin-arm64", buildPath);
copyNativeDependency("file-icon", buildPath);
copyNativeDependency("p-map", buildPath);

// Platform-specific native dependencies
if (process.platform === "darwin") {
copyNativeDependency("@parcel/watcher-darwin-arm64", buildPath);
copyNativeDependency("file-icon", buildPath);
copyNativeDependency("p-map", buildPath);
} else if (process.platform === "win32") {
const watcherPkg =
process.arch === "arm64"
? "@parcel/watcher-win32-arm64"
: "@parcel/watcher-win32-x64";
copyNativeDependency(watcherPkg, buildPath);
}

// Copy @parcel/watcher's hoisted dependencies
copyNativeDependency("micromatch", buildPath);
copyNativeDependency("is-glob", buildPath);
Expand Down
3 changes: 2 additions & 1 deletion apps/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"postinstall": "bash scripts/postinstall.sh",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"clean": "rm -rf .vite .turbo out node_modules/.vite",
"clean": "node ../../scripts/rimraf.mjs .vite .turbo out node_modules/.vite",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:view": "drizzle-kit studio"
Expand All @@ -45,6 +45,7 @@
"@biomejs/biome": "2.2.4",
"@electron-forge/cli": "^7.11.1",
"@electron-forge/maker-dmg": "^7.11.1",
"@electron-forge/maker-squirrel": "^7.11.1",
"@electron-forge/maker-zip": "^7.11.1",
"@electron-forge/plugin-vite": "^7.11.1",
"@electron-forge/publisher-github": "^7.11.1",
Expand Down
4 changes: 3 additions & 1 deletion apps/code/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ const handleShutdownSignal = async (signal: string) => {

process.on("SIGTERM", () => handleShutdownSignal("SIGTERM"));
process.on("SIGINT", () => handleShutdownSignal("SIGINT"));
process.on("SIGHUP", () => handleShutdownSignal("SIGHUP"));
if (process.platform !== "win32") {
process.on("SIGHUP", () => handleShutdownSignal("SIGHUP"));
}

process.on("uncaughtException", (error) => {
if (error.message === "write EIO") {
Expand Down
Loading
Loading