|
| 1 | +name: Code Build Test |
| 2 | + |
| 3 | +# Full build + code signing + verification of apps/code on every push to this |
| 4 | +# branch (and on demand), producing downloadable artifacts for inspection. |
| 5 | +# |
| 6 | +# This intentionally does NOT create or publish any GitHub release — it exists |
| 7 | +# to prove the packaging pipeline works end to end before merge. The real |
| 8 | +# release pipeline lives in code-release.yml and runs only on v* tags. |
| 9 | +# |
| 10 | +# Temporary: retarget or delete the branch trigger once this branch is merged. |
| 11 | + |
| 12 | +on: |
| 13 | + push: |
| 14 | + branches: |
| 15 | + - refactor/electron-vite |
| 16 | + workflow_dispatch: |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: code-build-test-${{ github.ref }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +jobs: |
| 23 | + build-macos: |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - arch: arm64 |
| 29 | + runner: macos-15 |
| 30 | + - arch: x64 |
| 31 | + runner: macos-15-intel |
| 32 | + runs-on: ${{ matrix.runner }} |
| 33 | + permissions: |
| 34 | + id-token: write |
| 35 | + contents: read |
| 36 | + env: |
| 37 | + NODE_OPTIONS: "--max-old-space-size=8192" |
| 38 | + NODE_ENV: production |
| 39 | + npm_config_arch: ${{ matrix.arch }} |
| 40 | + npm_config_platform: darwin |
| 41 | + VITE_POSTHOG_API_KEY: ${{ secrets.VITE_POSTHOG_API_KEY }} |
| 42 | + VITE_POSTHOG_API_HOST: ${{ secrets.VITE_POSTHOG_API_HOST }} |
| 43 | + POSTHOG_SOURCEMAP_API_KEY: ${{ secrets.POSTHOG_SOURCEMAP_API_KEY }} |
| 44 | + POSTHOG_ENV_ID: ${{ secrets.POSTHOG_ENV_ID }} |
| 45 | + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} |
| 46 | + CSC_LINK: ${{ secrets.APPLE_CODESIGN_CERT_BASE64 }} |
| 47 | + CSC_KEY_PASSWORD: ${{ secrets.APPLE_CODESIGN_CERT_PASSWORD }} |
| 48 | + APPLE_ID: ${{ secrets.APPLE_ID }} |
| 49 | + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} |
| 50 | + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 51 | + steps: |
| 52 | + - name: Checkout |
| 53 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 54 | + with: |
| 55 | + fetch-depth: 0 |
| 56 | + persist-credentials: false |
| 57 | + |
| 58 | + - name: Setup pnpm |
| 59 | + uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0 |
| 60 | + |
| 61 | + - name: Setup Node.js |
| 62 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 63 | + with: |
| 64 | + node-version: 22 |
| 65 | + cache: "pnpm" |
| 66 | + |
| 67 | + - name: Install dependencies |
| 68 | + run: pnpm install --frozen-lockfile |
| 69 | + |
| 70 | + - name: Configure AWS credentials |
| 71 | + uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 |
| 72 | + with: |
| 73 | + role-to-assume: ${{ secrets.AWS_TWIG_APP_ASSETS_ROLE_ARN }} |
| 74 | + aws-region: ${{ secrets.AWS_TWIG_APP_ASSETS_REGION }} |
| 75 | + mask-aws-account-id: true |
| 76 | + unset-current-credentials: true |
| 77 | + |
| 78 | + - name: Download BerkeleyMono fonts from S3 |
| 79 | + run: aws s3 cp s3://${{ secrets.AWS_TWIG_APP_ASSETS_BUCKET }}/fonts/BerkeleyMono/ apps/code/assets/fonts/BerkeleyMono/ --recursive |
| 80 | + |
| 81 | + - name: Build workspace packages |
| 82 | + run: | |
| 83 | + pnpm --filter @posthog/electron-trpc run build |
| 84 | + pnpm --filter @posthog/platform run build |
| 85 | + pnpm --filter @posthog/shared run build |
| 86 | + pnpm --filter @posthog/git run build |
| 87 | + pnpm --filter @posthog/enricher run build |
| 88 | + pnpm --filter @posthog/agent run build |
| 89 | +
|
| 90 | + - name: Build app |
| 91 | + working-directory: apps/code |
| 92 | + run: | |
| 93 | + pnpm exec electron-vite build |
| 94 | + if [[ "${{ matrix.arch }}" == "arm64" ]]; then |
| 95 | + pnpm exec electron-builder build --mac --arm64 --publish never --config electron-builder.ts |
| 96 | + else |
| 97 | + pnpm exec electron-builder build --mac --x64 --publish never --config electron-builder.ts |
| 98 | + fi |
| 99 | +
|
| 100 | + - name: Verify package |
| 101 | + run: | |
| 102 | + if [[ "${{ matrix.arch }}" == "arm64" ]]; then |
| 103 | + APP_BUNDLE="apps/code/out/mac-arm64/PostHog Code.app" |
| 104 | + else |
| 105 | + APP_BUNDLE="apps/code/out/mac/PostHog Code.app" |
| 106 | + fi |
| 107 | + RESOURCES="$APP_BUNDLE/Contents/Resources" |
| 108 | + UNPACKED="$RESOURCES/app.asar.unpacked/node_modules" |
| 109 | +
|
| 110 | + if [[ ! -f "$RESOURCES/app-update.yml" ]]; then |
| 111 | + echo "FAIL: app-update.yml missing at $RESOURCES/app-update.yml" |
| 112 | + exit 1 |
| 113 | + fi |
| 114 | + echo "OK: app-update.yml" |
| 115 | +
|
| 116 | + for mod in node-pty better-sqlite3 "@parcel/watcher"; do |
| 117 | + if [[ ! -d "$UNPACKED/$mod" ]]; then |
| 118 | + echo "FAIL: $mod missing in app.asar.unpacked/node_modules" |
| 119 | + exit 1 |
| 120 | + fi |
| 121 | + echo "OK: $mod" |
| 122 | + done |
| 123 | +
|
| 124 | + for bin in claude-cli codex-acp; do |
| 125 | + if [[ ! -d "$RESOURCES/app.asar.unpacked/.vite/build/$bin" ]]; then |
| 126 | + echo "FAIL: $bin missing in bundled binaries" |
| 127 | + exit 1 |
| 128 | + fi |
| 129 | + echo "OK: $bin" |
| 130 | + done |
| 131 | +
|
| 132 | + - name: Install Playwright |
| 133 | + run: pnpm --filter code exec playwright install |
| 134 | + |
| 135 | + - name: Smoke test packaged app |
| 136 | + env: |
| 137 | + CI: true |
| 138 | + E2E_APP_ARCH: ${{ matrix.arch }} |
| 139 | + run: pnpm --filter code exec playwright test --config=tests/e2e/playwright.config.ts tests/e2e/tests/smoke.spec.ts |
| 140 | + |
| 141 | + - name: Upload Playwright report |
| 142 | + if: failure() |
| 143 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 144 | + with: |
| 145 | + name: build-test-playwright-macos-${{ matrix.arch }} |
| 146 | + path: apps/code/playwright-report/ |
| 147 | + retention-days: 7 |
| 148 | + |
| 149 | + - name: Upload artifacts |
| 150 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 151 | + with: |
| 152 | + name: code-macos-${{ matrix.arch }} |
| 153 | + path: | |
| 154 | + apps/code/out/*.dmg |
| 155 | + apps/code/out/*-mac.zip |
| 156 | + apps/code/out/*.blockmap |
| 157 | + apps/code/out/latest-mac.yml |
| 158 | + retention-days: 7 |
| 159 | + |
| 160 | + build-windows: |
| 161 | + runs-on: windows-2022 |
| 162 | + permissions: |
| 163 | + contents: read |
| 164 | + env: |
| 165 | + NODE_OPTIONS: "--max-old-space-size=8192" |
| 166 | + NODE_ENV: production |
| 167 | + VITE_POSTHOG_API_KEY: ${{ secrets.VITE_POSTHOG_API_KEY }} |
| 168 | + VITE_POSTHOG_API_HOST: ${{ secrets.VITE_POSTHOG_API_HOST }} |
| 169 | + steps: |
| 170 | + - name: Checkout |
| 171 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 172 | + with: |
| 173 | + fetch-depth: 0 |
| 174 | + persist-credentials: false |
| 175 | + |
| 176 | + - name: Setup pnpm |
| 177 | + uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0 |
| 178 | + |
| 179 | + - name: Setup Node.js |
| 180 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 181 | + with: |
| 182 | + node-version: 22 |
| 183 | + cache: "pnpm" |
| 184 | + |
| 185 | + - name: Install dependencies |
| 186 | + run: pnpm install --frozen-lockfile |
| 187 | + |
| 188 | + - name: Build workspace packages |
| 189 | + run: | |
| 190 | + pnpm --filter @posthog/electron-trpc run build |
| 191 | + pnpm --filter @posthog/platform run build |
| 192 | + pnpm --filter @posthog/shared run build |
| 193 | + pnpm --filter @posthog/git run build |
| 194 | + pnpm --filter @posthog/enricher run build |
| 195 | + pnpm --filter @posthog/agent run build |
| 196 | +
|
| 197 | + - name: Build app |
| 198 | + working-directory: apps/code |
| 199 | + run: | |
| 200 | + pnpm exec electron-vite build |
| 201 | + pnpm exec electron-builder build --win --x64 --publish never --config electron-builder.ts |
| 202 | +
|
| 203 | + - name: Upload artifacts |
| 204 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 205 | + with: |
| 206 | + name: code-windows |
| 207 | + path: | |
| 208 | + apps/code/out/*.exe |
| 209 | + apps/code/out/latest.yml |
| 210 | + apps/code/out/*.blockmap |
| 211 | + apps/code/out/squirrel-windows/** |
| 212 | + retention-days: 7 |
| 213 | + if-no-files-found: ignore |
| 214 | + |
| 215 | + build-linux: |
| 216 | + strategy: |
| 217 | + fail-fast: false |
| 218 | + matrix: |
| 219 | + include: |
| 220 | + - runner: ubuntu-24.04 |
| 221 | + arch: x64 |
| 222 | + - runner: ubuntu-24.04-arm |
| 223 | + arch: arm64 |
| 224 | + runs-on: ${{ matrix.runner }} |
| 225 | + permissions: |
| 226 | + contents: read |
| 227 | + env: |
| 228 | + NODE_OPTIONS: "--max-old-space-size=8192" |
| 229 | + NODE_ENV: production |
| 230 | + VITE_POSTHOG_API_KEY: ${{ secrets.VITE_POSTHOG_API_KEY }} |
| 231 | + VITE_POSTHOG_API_HOST: ${{ secrets.VITE_POSTHOG_API_HOST }} |
| 232 | + steps: |
| 233 | + - name: Checkout |
| 234 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 235 | + with: |
| 236 | + fetch-depth: 0 |
| 237 | + persist-credentials: false |
| 238 | + |
| 239 | + - name: Install Linux packaging tooling |
| 240 | + # squashfs-tools/zsync/libfuse2t64: AppImage. fakeroot: deb. rpm: rpmbuild. |
| 241 | + run: | |
| 242 | + sudo apt-get update |
| 243 | + sudo apt-get install -y --no-install-recommends \ |
| 244 | + squashfs-tools zsync libfuse2t64 fakeroot rpm |
| 245 | +
|
| 246 | + - name: Setup pnpm |
| 247 | + uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0 |
| 248 | + |
| 249 | + - name: Setup Node.js |
| 250 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 251 | + with: |
| 252 | + node-version: 22 |
| 253 | + cache: "pnpm" |
| 254 | + |
| 255 | + - name: Install dependencies |
| 256 | + run: pnpm install --frozen-lockfile |
| 257 | + |
| 258 | + - name: Build workspace packages |
| 259 | + run: | |
| 260 | + pnpm --filter @posthog/electron-trpc run build |
| 261 | + pnpm --filter @posthog/platform run build |
| 262 | + pnpm --filter @posthog/shared run build |
| 263 | + pnpm --filter @posthog/git run build |
| 264 | + pnpm --filter @posthog/enricher run build |
| 265 | + pnpm --filter @posthog/agent run build |
| 266 | +
|
| 267 | + - name: Build app |
| 268 | + working-directory: apps/code |
| 269 | + run: | |
| 270 | + pnpm exec electron-vite build |
| 271 | + if [[ "${{ matrix.arch }}" == "arm64" ]]; then |
| 272 | + pnpm exec electron-builder build --linux --arm64 --publish never --config electron-builder.ts |
| 273 | + else |
| 274 | + pnpm exec electron-builder build --linux --x64 --publish never --config electron-builder.ts |
| 275 | + fi |
| 276 | +
|
| 277 | + - name: Upload artifacts |
| 278 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 279 | + with: |
| 280 | + name: code-linux-${{ matrix.arch }} |
| 281 | + path: | |
| 282 | + apps/code/out/*.AppImage |
| 283 | + apps/code/out/*.deb |
| 284 | + apps/code/out/*.rpm |
| 285 | + retention-days: 7 |
0 commit comments