Skip to content

Removed public app versions from their package.json files - #29718

Closed
9larsons wants to merge 4 commits into
mainfrom
slars/public-app-version-single-source
Closed

9larsons wants to merge 4 commits into
mainfrom
slars/public-app-version-single-source

Conversation

@9larsons

@9larsons 9larsons commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

ref #29710

Problem

A public UMD app's version lives in two halves, and neither of them is the app's package.json:

  • defaults.json pins the major.minor line, because Ghost core serves each app from <pkg>@~<major.minor> on jsDelivr.
  • npm holds the patch number, since Automate patch releases for public UMD apps #28980 made patches publish automatically on merge to main.

package.json's version was a third copy of the line that nothing reads as authoritative — the publish job overwrites it with npm pkg set before building. So it could only ever drift, and check-app-version-bump.js existed solely to police that drift on every PR.

It had already drifted in a visible way. Every app still carried the patch digit it happened to have when auto-publishing landed, which reads as a bug from outside the release flow — sodo-search sat at 1.8.31 in the repo against 1.8.231 on npm, which is what prompted #29710.

Approach

Make defaults.json the single source of the version line, and reduce package.json's version to a 0.0.0 placeholder.

What changed

  • compute-next-app-version — reads the line from defaults.json instead of package.json, and takes a package name rather than a working directory. A fresh line now starts at .0 explicitly instead of echoing back package.json. Converted from CJS to ESM so it can share scripts/lib/public-apps.js (the rest of that directory is already ESM).
  • release-apps.js (pnpm ship) — bumps the line in defaults.json alone. It works on lines (1.8 → 1.9) rather than round-tripping through a full semver version.
  • check-app-version-bump.js — removed, along with its CI step. Its one invariant was package.json major.minor == defaults.json, which no longer has two sides. The job it shared with the changeset check is renamed job_changeset_check for what it now does; it is not a required status check in the org ruleset, so nothing needs reconfiguring.
  • lib/public-apps.js — majorMinor(version) (unused once the above went) replaced by parseVersionLine / bumpVersionLine / versionLineFor, which operate on lines.
  • Six apps/*/package.json — version set to 0.0.0.

Note for reviewers

Portal was the only app reading its own package.json version at build time, baking it into REACT_APP_VERSION for its Sentry release tag. CI still sets the real version before building, so published bundles are unaffected. For local builds it now defines null rather than a misleading 0.0.0, which lets app.jsx fall back to the portal_version Ghost reports — the fallback that was already written there but unreachable.

This does not change how often the apps publish; that's #29710's other half and is a separate PR.

Verification

  • pnpm --filter @internal/scripts test — 63 pass, including new coverage for computeNextVersion and the line helpers
  • node scripts/compute-next-app-version.js @tryghost/sodo-search against live npm → 1.8.233 (and @tryghost/portal → 2.69.223), matching what the old script would have produced
  • pnpm nx build for sodo-search and portal; pnpm --filter @tryghost/portal test — 583 pass
  • ci.yml parsed and asserted: renamed job present, old job gone, no dangling needs in the rollup gate
  • pnpm install --frozen-lockfile clean — workspace importers don't record versions, so the lockfile is untouched

ref #29710

A public app's version lives in two halves: defaults.json pins the
major.minor line Ghost core serves from jsDelivr, and npm holds the patch
number since patches auto-publish on merge to main. Its package.json
version was a third copy of the line that nothing read as authoritative —
the publish job overwrites it before building — so it could only ever
drift, and check-app-version-bump existed solely to police that drift.

The stale patch digits it carried (sodo-search 1.8.31 against npm's
1.8.231) also read as a bug to anyone outside the release flow.

- compute-next-app-version reads the line from defaults.json and is
  addressed by package name rather than cwd; converted to ESM so it can
  share scripts/lib
- release-apps bumps the line in defaults.json alone
- removed check-app-version-bump and its CI step; the job it shared with
  the changeset check is renamed for what it now does
- public app package.json versions are 0.0.0 placeholders
- portal only defines REACT_APP_VERSION when the placeholder has been
  replaced, so a local build falls back to the version Ghost reports
@nx-cloud

nx-cloud Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 4ccf7d4

Command Status Duration Result
nx run ghost:test:integration ✅ Succeeded 3m 30s View ↗
nx run @tryghost/admin:test:acceptance ✅ Succeeded 5m 49s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 4s View ↗
nx run ghost:test:legacy ✅ Succeeded 2m 55s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 49s View ↗
nx run @tryghost/koenig-lexical:test:acceptance ✅ Succeeded 2m 32s View ↗
nx run @tryghost/comments-ui:test:acceptance ✅ Succeeded 42s View ↗
nx run @tryghost/activitypub:test:acceptance ✅ Succeeded 40s View ↗
Additional runs (8) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-03 16:17:20 UTC

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 90a21a38-fe86-4e05-8e57-8c705ba014f2

📥 Commits

Reviewing files that changed from the base of the PR and between bfd0282 and 4ccf7d4.

📒 Files selected for processing (2)
  • scripts/build-public-apps-matrix.js
  • scripts/test/build-public-apps-matrix.test.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • scripts/test/build-public-apps-matrix.test.js
  • scripts/build-public-apps-matrix.js

Walkthrough

Public app packages now use 0.0.0, while defaults.json stores their major.minor version lines. Shared helpers validate and update those lines. Release automation changes only the configured line, and a new script computes stable patch versions from npm. The publish matrix detects version-line changes from the Nx base revision. CI now checks for changesets and uses the new version script during publishing. Portal builds omit the placeholder version.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: public app package.json versions were replaced with placeholders.
Description check ✅ Passed The description directly explains the version-source changes, script updates, CI changes, and verification steps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch slars/public-app-version-single-source

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.44%. Comparing base (1938a05) to head (4ccf7d4).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29718      +/-   ##
==========================================
+ Coverage   75.42%   75.44%   +0.02%     
==========================================
  Files        1609     1611       +2     
  Lines      141448   141824     +376     
  Branches    17486    17541      +55     
==========================================
+ Hits       106691   107005     +314     
- Misses      33683    33768      +85     
+ Partials     1074     1051      -23     
Flag Coverage Δ
e2e-tests 77.58% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

ref #29710

Three places name the CI gate "Check app version bump" while describing
what it actually does — fail a PR that changes a publishable package with
no changeset. Dropping the version-bump step renames the job to match, so
point them at the new name.
ref #29710

Defaults-only releases do not appear as affected public app projects in Nx, so the publish matrix must also compare version lines with its base revision.
ref #29710

Comparing version lines against the Nx base reads defaults.json at that
revision, and throwing when it can't be read puts a git failure — a base
force-pushed away, a blob the treeless job_setup checkout can't fetch —
in the one job every other job depends on. A transient failure there fails
the entire run for the repo rather than just skipping a publish.

Fall back to no comparison instead, which selects on the affected set
alone: exactly what this script did before version lines were considered.
@9larsons
9larsons marked this pull request as draft August 5, 2026 16:10
@9larsons 9larsons closed this Aug 10, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Aug 13, 2026
3 tasks done
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.

1 participant