Skip to content

Reapply "Distribute Linux dev builds to AppsCDN"#3464

Merged
ivan-ottinger merged 2 commits into
trunkfrom
redo-distribute-linux-dev-builds
May 15, 2026
Merged

Reapply "Distribute Linux dev builds to AppsCDN"#3464
ivan-ottinger merged 2 commits into
trunkfrom
redo-distribute-linux-dev-builds

Conversation

@ivan-ottinger
Copy link
Copy Markdown
Contributor

Related issues

Re-applies #3363 after it was reverted in #3462. Blocked on the upstream fastlane-plugin gap landing — see RSM-3058 and wordpress-mobile/release-toolkit#720.

How AI was used in this PR

AI-assisted: re-applied the original change as a revert-of-revert commit, drafted this PR body explaining the dependency chain. Author reviewed.

Why this PR exists

The original #3363 wired Linux DEBs into the existing dev-distribution flow (fastlane + Buildkite). On merge it caused trunk's Distribute Dev Builds step to fail because the upload_build_to_apps_cdn fastlane action has a client-side platform allowlist that doesn't include Linux. We reverted in #3462 to restore trunk health.

The upstream fix is in flight at wordpress-mobile/release-toolkit#720, which adds 'Linux - x64' and 'Linux - ARM64' to the action's VALID_PLATFORMS constant. Once that PR merges and a new gem version is released, we can re-apply the original Studio-side change and ship Linux dev distribution.

What this PR contains

Pure re-apply of #3363 (revert-of-revert commit). Two files:

  • .buildkite/pipeline.yml: adds - step: dev-linux to Distribute Dev Builds's depends_on and buildkite-agent artifact download "*.deb" . to its command block.
  • fastlane/Fastfile: adds the linux_deb_path helper and the release_tag.nil? block with the two Linux entries (linux_x64_deb, linux_arm64_deb).

No changes to Gemfile / Gemfile.lock here — that bump comes as a separate, smaller PR landed before this one (see merge order below).

Merge order (important)

  1. wordpress-mobile/release-toolkit#720 merges → release-toolkit team cuts a new gem release.
  2. Separate small PR bumps Studio's Gemfile.lock to the new gem version (via bundle update fastlane-plugin-wpmreleasetoolkit). The Gemfile pessimistic constraint (~> 14.2) already accepts the new minor version, so only the lock file changes.
  3. This PR is marked ready for review, CI runs against the bumped gem, reviewed, merged.
  4. Next trunk build's Distribute Dev Builds should now succeed for all three platforms.

Until step 2 lands, this PR's CI will keep hitting the same plugin-validation error as #3363 did. It stays draft until then.

Out of scope

  • Release pipeline Linux integration (RSM-2587). A separate PR will wire Linux into .buildkite/release-build-and-distribute.yml and lift the release_tag.nil? gate from Fastfile. Conceptually expands the same Linux distribution work to release-time uploads, but it's a different pipeline file and a meaningfully different blast radius, so it deserves its own PR.

Testing Instructions

Once the gem bump PR lands and this is marked ready:

  1. Push a commit (or let CI re-run on the existing commit) and confirm Lint, Unit Tests, E2E Tests, Performance Metrics all stay green.
  2. After merge, watch the first trunk build's Distribute Dev Builds step. Should succeed and the log should contain CDN URLs for both Linux entries (Linux - x64, Linux - ARM64) alongside the existing Mac and Windows uploads.
  3. Optionally curl -IL one of the returned Linux CDN URLs to confirm it serves the .deb.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
  • Gemfile.lock bump PR is merged.
  • Trunk's Distribute Dev Builds step succeeds end-to-end after this lands and reports CDN URLs for both Linux entries.

@ivan-ottinger ivan-ottinger self-assigned this May 13, 2026
@ivan-ottinger ivan-ottinger marked this pull request as ready for review May 13, 2026 10:32
@ivan-ottinger ivan-ottinger requested review from a team and gavande1 May 13, 2026 10:32
@ivan-ottinger ivan-ottinger mentioned this pull request May 13, 2026
4 tasks
Copy link
Copy Markdown
Contributor

@gavande1 gavande1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Checks are still pending per the testing instructions, so something might be wrong. I'm going to update the branch with the latest trunk. Let's see how it goes, but approving anyway.

@gavande1
Copy link
Copy Markdown
Contributor

Update: checks passed after merging latest trunk. Disregard my earlier concern.

ivan-ottinger added a commit that referenced this pull request May 14, 2026
## Related issues
Unblocks [#3464](#3464) (Linux
dev build distribution re-apply).

## How AI was used in this PR
AI-assisted: ran the `bundle update --conservative` command, drafted
this PR body. Author reviewed.

## Proposed Changes
Bumps `fastlane-plugin-wpmreleasetoolkit` to v14.6.0 to pick up Linux
platform support added upstream in
[wordpress-mobile/release-toolkit#720](wordpress-mobile/release-toolkit#720).
Without this, the `upload_build_to_apps_cdn` action in Studio's fastlane
lanes rejects `'Linux - x64'` and `'Linux - ARM64'` as invalid platform
values client-side, which is what failed [build
#16073](https://buildkite.com/automattic/studio/builds/16073) and
prompted the revert in
[#3462](#3462).

The lockfile changes are limited to the targeted gem and its required
deps (used `bundle update --conservative`): the gem bump itself, removal
of `activesupport` and its transitive deps (release-toolkit dropped that
dep in 14.3.1), and bumps for `aws-sdk-core`/`kms`/`s3` which
release-toolkit's google-cloud-storage requires. `nokogiri` requirement
also tightens (14.6.0 raised its minimum).

## Testing Instructions
CI passing is the test. Existing macOS/Windows distribution behavior is
unchanged — the new gem adds platform values without modifying existing
ones.

## Pre-merge Checklist
- [ ] Have you checked for TypeScript, React or other console errors?
- [ ] CI is green.
@ivan-ottinger ivan-ottinger merged commit 0c5c0a4 into trunk May 15, 2026
10 checks passed
@ivan-ottinger ivan-ottinger deleted the redo-distribute-linux-dev-builds branch May 15, 2026 09:46
ivan-ottinger added a commit that referenced this pull request May 15, 2026
## Related issues
Follow-up to [#3464](#3464)
(Linux dev build distribution).

## How AI was used in this PR
AI-assisted: spotted the duplicated arch/version in the uploaded
filename while verifying the first trunk Distribute Dev Builds run,
drafted the fix and PR body. Author reviewed.

## Proposed Changes

The Linux DEBs uploaded to AppsCDN by [build
#16245](https://buildkite.com/automattic/studio/builds/16245) landed
with names like:

- `studio_1.9.0dev51_amd64-x64-v1.9.0-dev51.deb`
- `studio_1.9.0dev51_arm64-arm64-v1.9.0-dev51.deb`

Both arch (`amd64` + `x64`) and version (`1.9.0dev51` + `v1.9.0-dev51`)
appear twice. The cause: `electron-installer-debian` produces filenames
like `studio_1.9.0~dev51_amd64.deb`, then `create_versioned_file` (in
this Fastfile) blindly appends `-<arch>-v<version>` to the base name.
For Mac the input is a clean `Studio.app.zip`, so the result is
`studio-x64-v1.9.0.zip`; for Linux the input already carries
arch+version, so the suffix is duplicated. WordPress's media library
then strips the `~`, mashing the version slug.

This change renames the Linux DEB to a clean `studio.deb` stem in
`linux_deb_path` before returning the path. `create_versioned_file` then
produces the Mac-style `studio-<arch>-v<version>.deb` (e.g.
`studio-x64-v1.9.0-dev51.deb`). The rename is idempotent — retries pick
up the already-renamed file.

**Why this is cosmetic-only:**
- Version checking goes through the WPCOM `studio-app/updates` endpoint,
which compares the `version` field in upload metadata (passed explicitly
to `upload_file_to_apps_cdn`), not the filename.
- `apt`/`dpkg` install behavior reads the DEB's internal control file,
not the filename.
- The CDN `media_url` is composed from `platform/version/build_number`,
not the filename — only `Content-Disposition` after the 302 changes.

User-visible impact: the filename users see in their Downloads folder
after clicking the in-app update button (#3465) becomes readable.

## Testing Instructions
- After this lands on trunk, watch the next Distribute Dev Builds run.
- Open the `cdn-link` annotation on the Distribute Dev Builds job.
- Click the **Linux - x64 (DEB)** and **Linux - ARM64 (DEB)** links and
confirm the downloaded filenames look like `studio-x64-v<version>.deb` /
`studio-arm64-v<version>.deb`.

## Pre-merge Checklist
- [ ] Have you checked for TypeScript, React or other console errors?
- [ ] CI is green.
ivan-ottinger added a commit that referenced this pull request May 15, 2026
## Related issues

Part of [RSM-1314](https://linear.app/a8c/issue/RSM-1314) — Linux
release prep.

## How AI was used in this PR

AI-assisted: drafted the Linux branch in `apps/studio/src/updates.ts`,
the unit tests, and this PR body. Author reviewed.

## Proposed Changes

Adds Linux support to the in-app update flow. Electron's built-in
`autoUpdater` is macOS/Windows only, so this PR adds a custom polling
branch in `apps/studio/src/updates.ts` that hits the same WPCOM
endpoint, parses the agreed Linux response, and shows an OS dialog when
an update is available. The dialog has a `Download` button that opens
the user's browser to the `.deb` URL via `shellOpenExternalWrapper`; the
user installs manually via `sudo apt install`.

<img width="1666" height="1238" alt="CleanShot 2026-05-13 at 14 29
43@2x"
src="https://github.com/user-attachments/assets/6c7c9342-bcae-45ea-9473-195ad9e24e01"
/>

### Response handling

| Server response | Client behavior |
| --- | --- |
| `200 { version, downloadUrl }` | Show dialog with the new version +
Download/Later buttons. On Download, validate URL is `http:`/`https:`
then open via `shellOpenExternalWrapper`. Reschedule. |
| `204` | No update. Silent on auto-poll; "No updates available" dialog
on manual check (shared with Mac/Windows). |
| `404` | Should not happen. Log to Sentry and treat as no-op. |
| Other errors | Log to Sentry. Reschedule. |

The server runs `version_compare()` and returns `204` when the client is
current, so the client trusts the response without further comparison.

## Out of scope

- **Linux dev/release distribution to AppsCDN** — tracked in
[#3464](#3464) and
[RSM-2587](https://linear.app/a8c/issue/RSM-2587/wire-linux-into-the-release-pipeline).
This PR is independent: the WPCOM `studio-app/updates` endpoint is
already deployed and serves Linux responses today.
- **Automatic install** — `.deb` installation requires root, can't be
silent. Flow is intentionally "open browser, user installs."

## Testing Instructions

**Automated:** unit tests cover the three main response paths (200, 204,
server error). They run in CI; locally:

```bash
npx vitest run apps/studio/src/tests/updates.test.ts
```

**Visual verification of the dialog on Linux:** because no Linux release
exists in AppsCDN yet, the server returns `204` for any version. To
exercise the dialog locally, apply this temporary diff to force-trigger
the 200 path, then revert when done. Run on a Linux machine (or VM):

```bash
git checkout add-linux-in-app-updater
git apply <<'PATCH'
diff --git a/apps/studio/src/updates.ts b/apps/studio/src/updates.ts
--- a/apps/studio/src/updates.ts
+++ b/apps/studio/src/updates.ts
@@ -222,6 +222,12 @@ async function showUpdateReadyToInstallNotice() {
 }
 
 function setupLinuxUpdates() {
+	// TEMP for local testing — REMOVE BEFORE COMMIT
+	console.log( 'TEMP: bypassing shouldPoll for local Linux updater test' );
+	void pollLinuxUpdates();
+	return;
+	// END TEMP
+
 	if ( ! shouldPoll ) {
 		console.log( 'Skipping Linux auto-updates', {
 			env: process.env.NODE_ENV,
@@ -238,6 +244,22 @@ function setupLinuxUpdates() {
 async function pollLinuxUpdates() {
 	updaterState = 'checking-for-update';
 
+	// TEMP for local testing — REMOVE BEFORE COMMIT
+	// Stubs a fake 200 response so the dialog renders without a real WPCOM call.
+	// Swap to `return;` (in the try) to test the 204 path instead.
+	console.log( 'TEMP: stubbing fake 200 response' );
+	try {
+		await showLinuxUpdateAvailableNotice(
+			'1.9.9',
+			'https://appscdn.wordpress.com/downloads/wordpress-com-studio/linux-arm64/v1.9.9/update/studio_1.9.9_arm64.deb'
+		);
+	} finally {
+		showManualCheckDialogs = false;
+		rescheduleLinuxOrFinish();
+	}
+	return;
+	// END TEMP
+
 	const url = new URL( 'https://public-api.wordpress.com/wpcom/v2/studio-app/updates' );
 	url.searchParams.append( 'platform', process.platform );
 	url.searchParams.append( 'studioArch', process.arch );
PATCH
npm start
```

Within ~1 second of the main window appearing, the dialog should render.
Verify:

- Title "New Version Available", message "Studio 1.9.9 is available".
- Install command on its own line: `sudo apt install
~/Downloads/studio_1.9.9_arm64.deb`.
- Click "Download" → browser opens to the URL (it'll 404 — that's
expected; verifying `shellOpenExternalWrapper` fires).
- Click "Later" → dialog dismisses.
- `Help → Check for Updates` triggers the same dialog.

When done, revert:

```bash
git checkout apps/studio/src/updates.ts
```

**No regression on Mac/Windows:** `npm start` on Mac or Windows should
behave exactly as before this PR (no entry into the Linux branch).

## Pre-merge Checklist

- [ ] Have you checked for TypeScript, React or other console errors?
- [ ] Unit tests pass (`npx vitest run
apps/studio/src/tests/updates.test.ts`).
- [ ] Visual smoke test on a Linux machine confirms the dialog renders
correctly.
- [ ] Mac/Windows update flow is unchanged.

---------

Co-authored-by: Rahul Gavande <rahul.gavande@automattic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants