Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
91 changes: 90 additions & 1 deletion .github/workflows/code-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,97 @@ jobs:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: pnpm --filter code run publish

publish-linux:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
arch: x64
- runner: ubuntu-24.04-arm
arch: arm64
runs-on: ${{ matrix.runner }}
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: Install AppImage build tooling
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
squashfs-tools zsync libfuse2t64

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

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

- name: Extract version from tag
id: version
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
echo "Version: $TAG_VERSION"
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"

- name: Set version in package.json
env:
APP_VERSION: ${{ steps.version.outputs.version }}
run: |
jq --arg v "$APP_VERSION" '.version = $v' apps/code/package.json > tmp.json && mv tmp.json apps/code/package.json
echo "Set apps/code/package.json version to $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 platform package
run: pnpm --filter @posthog/platform 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 enricher package
run: pnpm --filter @posthog/enricher 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

finalize-release:
needs: [publish-macos, publish-windows]
needs: [publish-macos, publish-windows, publish-linux]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Dependencies
node_modules/
.pnpm-store/

# Build outputs
dist/
Expand Down
14 changes: 14 additions & 0 deletions apps/code/forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MakerZIP } from "@electron-forge/maker-zip";
import { VitePlugin } from "@electron-forge/plugin-vite";
import { PublisherGithub } from "@electron-forge/publisher-github";
import type { ForgeConfig } from "@electron-forge/shared-types";
import { MakerAppImage } from "@reforged/maker-appimage";

const appleCodesignIdentity = process.env.APPLE_CODESIGN_IDENTITY;
const appleTeamId = process.env.APPLE_TEAM_ID;
Expand Down Expand Up @@ -193,6 +194,13 @@ const config: ForgeConfig = {
name: "PostHogCode",
setupIcon: "./build/app-icon.ico",
}),
new MakerAppImage({
options: {
icon: "./build/app-icon.png",
categories: ["Development"],
bin: "PostHog Code",
},
}),
new MakerZIP({}, ["darwin", "linux"]),
],
hooks: {
Expand Down Expand Up @@ -248,6 +256,12 @@ const config: ForgeConfig = {
? "@parcel/watcher-win32-arm64"
: "@parcel/watcher-win32-x64";
copyNativeDependency(watcherPkg, buildPath);
} else if (process.platform === "linux") {
const watcherPkg =
process.arch === "arm64"
? "@parcel/watcher-linux-arm64-glibc"
: "@parcel/watcher-linux-x64-glibc";
copyNativeDependency(watcherPkg, buildPath);
}

// Copy @parcel/watcher's hoisted dependencies
Expand Down
2 changes: 2 additions & 0 deletions apps/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"package": "electron-forge package",
"package:dev": "FORCE_DEV_MODE=1 SKIP_NOTARIZE=1 electron-forge package",
"make": "electron-forge make",
"make:linux": "bash scripts/build-linux-docker.sh",
"publish": "electron-forge publish",
"build": "pnpm package",
"build-native": "bash scripts/build-native-modules.sh",
Expand Down Expand Up @@ -50,6 +51,7 @@
"@electron-forge/plugin-vite": "^7.11.1",
"@electron-forge/publisher-github": "^7.11.1",
"@electron-forge/shared-types": "^7.11.1",
"@reforged/maker-appimage": "^5.2.0",
"@electron/rebuild": "^4.0.3",
"@playwright/test": "^1.42.0",
"@posthog/rollup-plugin": "^1.4.0",
Expand Down
59 changes: 59 additions & 0 deletions apps/code/scripts/build-linux-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -euo pipefail

ARCH="${ARCH:-x64}"
case "$ARCH" in
x64) DOCKER_PLATFORM="linux/amd64" ;;
arm64) DOCKER_PLATFORM="linux/arm64" ;;
*) echo "Unsupported ARCH=$ARCH (expected x64 or arm64)" >&2; exit 1 ;;
esac

REPO_ROOT="$(cd "$(dirname "$0")/../../.." && pwd)"
OUT_DIR="$REPO_ROOT/apps/code/out"
mkdir -p "$OUT_DIR"

# Stream the repo source (no node_modules / build artifacts) into the container
# so node_modules lives on the container's overlayfs, not a slow FUSE bind mount.
# Only the output dir is bind-mounted so artifacts come back to the host.
cd "$REPO_ROOT"
# COPYFILE_DISABLE stops bsdtar from embedding macOS extended attrs as ._ files.
COPYFILE_DISABLE=1 tar -cf - \
--exclude='./.git' \
--exclude='./.pnpm-store' \
--exclude='node_modules' \
--exclude='.turbo' \
--exclude='.vite' \
--exclude='dist' \
--exclude='out' \
--exclude='playwright-results' \
--exclude='._*' \
--exclude='.DS_Store' \
. | exec docker run --rm -i \
--platform "$DOCKER_PLATFORM" \
-e CI=true \
-e NODE_OPTIONS="--max-old-space-size=8192" \
-e NODE_ENV=production \
-e ARCH="$ARCH" \
-v "$OUT_DIR":/out \
node:22-bookworm bash -lc '
set -euo pipefail
trap "rc=\$?; echo >&2; echo \"[build-linux-docker] FAILED (exit \$rc) at line \$LINENO: \$BASH_COMMAND\" >&2; exit \$rc" ERR
mkdir -p /work && cd /work && tar -xf -
corepack enable && corepack prepare pnpm@latest --activate
apt-get update && apt-get install -y --no-install-recommends \
libsecret-1-dev fuse libfuse2 ca-certificates git squashfs-tools zsync zip
# Tarball arrived owned by the host uid; tell git not to refuse on uid mismatch.
git config --global --add safe.directory /work
# Postinstall scripts call `git rev-parse` — give them a repo to find.
git init -q && git add -A && git -c user.email=x@x -c user.name=x commit -q -m init
pnpm install --frozen-lockfile
pnpm --filter @posthog/electron-trpc build
pnpm --filter @posthog/platform build
pnpm --filter @posthog/shared build
pnpm --filter @posthog/git build
pnpm --filter @posthog/enricher build
pnpm --filter @posthog/agent build
pnpm --filter code make --platform=linux --arch="$ARCH"
mkdir -p /out
cp -r apps/code/out/make /out/
'
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ export function SessionView({
[onSendPrompt],
);

const { isOnline } = useConnectivity();
const handleBeforeSubmit = useCallback(
(text: string, clearEditor: () => void): boolean => {
if (!isOnline) {
Expand Down
27 changes: 27 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading