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
6 changes: 4 additions & 2 deletions .github/workflows/code-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,13 @@ jobs:
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false

- name: Install AppImage build tooling
- name: Install Linux packaging tooling
# squashfs-tools/zsync/libfuse2t64: AppImage. fakeroot: maker-deb.
# rpm: maker-rpm (provides rpmbuild).
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
squashfs-tools zsync libfuse2t64
squashfs-tools zsync libfuse2t64 fakeroot rpm

- name: Setup pnpm
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
Expand Down
31 changes: 31 additions & 0 deletions apps/code/forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import type { ChildProcess } from "node:child_process";
import { execSync } from "node:child_process";
import { cpSync, existsSync, mkdirSync, rmSync } from "node:fs";
import path from "node:path";
import { MakerDeb } from "@electron-forge/maker-deb";
import { MakerDMG } from "@electron-forge/maker-dmg";
import { MakerRpm } from "@electron-forge/maker-rpm";
import { MakerSquirrel } from "@electron-forge/maker-squirrel";
import { MakerZIP } from "@electron-forge/maker-zip";
import { VitePlugin } from "@electron-forge/plugin-vite";
Expand Down Expand Up @@ -206,6 +208,35 @@ const config: ForgeConfig = {
bin: "PostHog Code",
},
}),
new MakerDeb({
options: {
name: "posthog-code",
productName: "PostHog Code",
genericName: "Code Editor",
description: "PostHog Code desktop app",
bin: "PostHog Code",
icon: "./build/app-icon.png",
categories: ["Development"],
section: "devel",
maintainer: "PostHog <eng@posthog.com>",
homepage: "https://github.com/PostHog/code",
mimeType: ["x-scheme-handler/posthog-code"],
},
}),
new MakerRpm({
options: {
name: "posthog-code",
productName: "PostHog Code",
genericName: "Code Editor",
description: "PostHog Code desktop app",
bin: "PostHog Code",
license: "MIT",
icon: "./build/app-icon.png",
categories: ["Development"],
homepage: "https://github.com/PostHog/code",
mimeType: ["x-scheme-handler/posthog-code"],
},
}),
new MakerZIP({}, ["darwin", "linux"]),
],
hooks: {
Expand Down
2 changes: 2 additions & 0 deletions apps/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
"devDependencies": {
"@biomejs/biome": "2.2.4",
"@electron-forge/cli": "^7.11.1",
"@electron-forge/maker-deb": "^7.11.1",
"@electron-forge/maker-dmg": "^7.11.1",
"@electron-forge/maker-rpm": "^7.11.1",
"@electron-forge/maker-squirrel": "^7.11.1",
"@electron-forge/maker-zip": "^7.11.1",
"@electron-forge/plugin-vite": "^7.11.1",
Expand Down
38 changes: 36 additions & 2 deletions apps/code/scripts/build-linux-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ case "$ARCH" in
*) echo "Unsupported ARCH=$ARCH (expected x64 or arm64)" >&2; exit 1 ;;
esac

# Optional maker targets. Without any, all configured makers run (default).
# Accept friendly aliases or full maker package names, via repeatable
# --target/--targets flags (comma-separated) or the TARGETS env var.
RAW_TARGETS="${TARGETS:-}"
while [ $# -gt 0 ]; do
case "$1" in
--target|--targets) RAW_TARGETS="${RAW_TARGETS:+$RAW_TARGETS,}$2"; shift 2 ;;
--target=*|--targets=*) RAW_TARGETS="${RAW_TARGETS:+$RAW_TARGETS,}${1#*=}"; shift ;;
*) echo "Unknown argument: $1" >&2; exit 1 ;;
esac
done

MAKE_TARGETS=""
if [ -n "$RAW_TARGETS" ]; then
IFS=',' read -ra _targets <<< "$RAW_TARGETS"
for t in "${_targets[@]}"; do
t="$(echo "$t" | tr '[:upper:]' '[:lower:]' | xargs)" # lowercase + trim
[ -z "$t" ] && continue
case "$t" in
deb) pkg="@electron-forge/maker-deb" ;;
rpm) pkg="@electron-forge/maker-rpm" ;;
zip) pkg="@electron-forge/maker-zip" ;;
appimage) pkg="@reforged/maker-appimage" ;;
*/*) pkg="$t" ;; # already a maker package name
*) echo "Unknown target '$t' (expected: deb, rpm, zip, appimage, or a maker package name)" >&2; exit 1 ;;
esac
MAKE_TARGETS="${MAKE_TARGETS:+$MAKE_TARGETS,}$pkg"
done
fi

REPO_ROOT="$(cd "$(dirname "$0")/../../.." && pwd)"
OUT_DIR="$REPO_ROOT/apps/code/out"
mkdir -p "$OUT_DIR"
Expand Down Expand Up @@ -40,14 +70,16 @@ COPYFILE_DISABLE=1 tar -cf - \
-e NODE_ENV=production \
-e ARCH="$ARCH" \
-e BUILD_COMMIT="$HOST_COMMIT" \
-e MAKE_TARGETS="$MAKE_TARGETS" \
-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
apt-get update && apt-get install -y --no-install-recommends \
libsecret-1-dev fuse libfuse2 ca-certificates git squashfs-tools zsync zip
libsecret-1-dev fuse libfuse2 ca-certificates git squashfs-tools zsync zip \
fakeroot rpm
# 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.
Expand All @@ -59,7 +91,9 @@ COPYFILE_DISABLE=1 tar -cf - \
pnpm --filter @posthog/git build
pnpm --filter @posthog/enricher build
pnpm --filter @posthog/agent build
pnpm --filter code make --platform=linux --arch="$ARCH"
MAKE_TARGETS_FLAG=""
[ -n "${MAKE_TARGETS:-}" ] && MAKE_TARGETS_FLAG="--targets=$MAKE_TARGETS"
pnpm --filter code make --platform=linux --arch="$ARCH" $MAKE_TARGETS_FLAG
mkdir -p /out
cp -r apps/code/out/make /out/
'
Loading
Loading