Skip to content

CI: fix IntelliJ Marketplace publish (clobbered ZIP version) - #454

Merged
lagergren merged 2 commits into
masterfrom
lagergren/fix-intellij-publish-version-clobber
May 1, 2026
Merged

lagergren merged 2 commits into
masterfrom
lagergren/fix-intellij-publish-version-clobber

Conversation

@lagergren

Copy link
Copy Markdown
Contributor

Summary

  • Restores IntelliJ Marketplace alpha publishing on master (broken since 2026-04-30; last successful publish was 0.4.4-SNAPSHOT.20260429204308).
  • Collapses the standalone "Verify IntelliJ plugin compatibility" step into the main build so verification and the staged distribution ZIP are always the same artifact.
  • Adds two defenses in publish-snapshot.yml so a regression of this class fails loudly instead of going green.

Root cause

PR #452 added a standalone Verify IntelliJ plugin compatibility step that re-ran :lang:intellij-plugin:verifyPlugin in a separate Gradle invocation, gated only on validate-lang == 'true'. That invocation passed only -PincludeBuildLang/-PincludeBuildAttachLang — not -PenablePublish=true or -Pjetbrains.publish.suffix=<utc>. verifyPlugin depends on buildPlugin which depends on patchPluginXml, so the second invocation re-evaluated jetbrainsPublishVersionProvider with publishEnabled=false, fell into the bare-base-version branch of lang/intellij-plugin/build.gradle.kts:40-49, and overwrote lang/intellij-plugin/build/distributions/intellij-plugin-0.4.4-SNAPSHOT.zip with a ZIP whose META-INF/plugin.xml said <version>0.4.4-SNAPSHOT</version> — clobbering the timestamped artifact the main build had just staged for intellij-plugin-dist-<sha>.

publish-snapshot.yml then promoted that clobbered ZIP. Marketplace correctly returned HTTP 400 with channel 'alpha' already contains version 0.4.4-SNAPSHOT (the bare base was already published as id 1016162 when the plugin was first registered). The script's idempotency heuristic substring-matched "already contains version" and declared the upload a successful no-op. CI stayed green for two days while no new alpha version landed on Marketplace.

Verified locally:

  • :lang:intellij-plugin:patchPluginXml with -PenablePublish=true -Pjetbrains.publish.suffix=20260501TEST → <version>0.4.4-SNAPSHOT.20260501TEST</version>
  • Same task without those properties → <version>0.4.4-SNAPSHOT</version>

Fix in commit.yml

Collapse to one Gradle invocation that owns both buildPlugin and verifyPlugin. The main Build the XDK and create a distribution step now handles all three IntelliJ paths:

  1. effective == 'true' (master push with lang/ changes, or manual dispatch with publish flags) — adds buildSearchableOptions + buildPlugin + verifyPlugin to BUILD_TASKS along with -PenablePublish and -Pjetbrains.publish.suffix. Publication path.
  2. validate-lang == 'true' && effective != 'true' (PR build with lang/ changes, or manual dispatch with include-lang) — adds verifyPlugin only, no publish properties. Verification-only path; nothing is staged for Marketplace.
  3. Otherwise — IntelliJ tasks are not in BUILD_TASKS at all. lang/intellij-plugin/build/distributions/ stays empty, nothing to clobber.

The standalone Verify IntelliJ plugin compatibility step and its two Skip companion steps are deleted. There is now exactly one place in CI that runs verifyPlugin, and the staged distribution ZIP is by construction the same artifact that was just verified.

Marketplace publication trigger is unchanged — the snapshot-publish workflow is kicked off only by master pushes (or manual dispatch), in the same job that fires Homebrew, Docker, and GitHub release updates. PR builds verify the plugin but never publish.

Fix in publish-snapshot.yml

Two defenses so a regression of this class fails loudly:

  1. Pre-upload sanity check. Extract <version> from the ZIP's META-INF/plugin.xml and abort if it doesn't match the publishVersion the CI build claimed it baked in. Marketplace derives the upload version from the ZIP, not from any form field, so a mismatch means the build produced a stale or bare-versioned artifact.
  2. Tightened idempotent heuristic. Only treat an "already contains version" 400 as a successful no-op when the response body explicitly references the version we just tried to upload. The previous loose substring match accepted already contains version 0.4.4-SNAPSHOT as proof that 0.4.4-SNAPSHOT.<timestamp> was published — exactly the substitution that hid this regression for two days. Full Marketplace response is now echoed in the idempotent path.

Mismatch check uses unzip + sed on the inner plugin JAR — no new tooling required on the runner image.

Test plan

  • patchPluginXml with publish props produces timestamped <version> (verified locally)
  • patchPluginXml without publish props produces bare <version> (verified — the bug)
  • Full buildSearchableOptions + buildPlugin with publish props produces inner JAR named intellij-plugin-0.4.4-SNAPSHOT.<suffix>.jar (verified locally)
  • Sanity check correctly extracts <version> from the inner JAR (verified locally)
  • Sanity check aborts when ZIP version is bare (today's bug pattern) (verified locally)
  • Tightened idempotent heuristic rejects today's response body, accepts a real same-version re-upload (verified locally)
  • Both YAMLs parse
  • First master merge after this PR successfully publishes a new alpha version to Marketplace
  • PR build with lang/ changes still runs verifyPlugin (now via the consolidated path)

…place publish

Two changes that together restore IntelliJ Marketplace publishing
(broken on master since 2026-04-30) and remove the structural
weakness that made it possible.

== Root cause ==

PR #452 added a standalone "Verify IntelliJ plugin compatibility"
step that re-ran :lang:intellij-plugin:verifyPlugin in a separate
Gradle invocation, gated only on validate-lang == 'true'. That
invocation passed only -PincludeBuildLang/-PincludeBuildAttachLang;
critically NOT -PenablePublish=true or
-Pjetbrains.publish.suffix=<utc>. verifyPlugin depends on
buildPlugin which depends on patchPluginXml, so the second
invocation re-evaluated jetbrainsPublishVersionProvider with
publishEnabled=false, fell into the bare-base-version branch, and
overwrote
  lang/intellij-plugin/build/distributions/intellij-plugin-0.4.4-SNAPSHOT.zip
with a ZIP whose META-INF/plugin.xml said
  <version>0.4.4-SNAPSHOT</version>
clobbering the timestamped artifact the main build had just staged
for the intellij-plugin-dist-<sha> upload.

publish-snapshot.yml then promoted that clobbered ZIP to
Marketplace, which correctly returned HTTP 400 with
  "channel 'alpha' already contains version 0.4.4-SNAPSHOT"
since the bare base version was already published as id 1016162
back when the plugin was first registered. The script's idempotency
heuristic (a substring match for "already contains version") then
declared the upload a successful no-op, and CI stayed green for two
days while no new alpha version landed on Marketplace. Last
successful publish: 0.4.4-SNAPSHOT.20260429204308 on Apr 29.

Verified locally: :lang:intellij-plugin:patchPluginXml with
-PenablePublish=true -Pjetbrains.publish.suffix=20260501TEST
produces <version>0.4.4-SNAPSHOT.20260501TEST</version>; the same
task without those properties produces <version>0.4.4-SNAPSHOT</version>.

== Fix in commit.yml ==

Collapse to one Gradle invocation that owns both buildPlugin and
verifyPlugin. The main "Build the XDK and create a distribution"
step now handles all three IntelliJ paths:

  1. effective == 'true' (master push with lang/ changes, or
     manual dispatch with publish flags) -- adds
     buildSearchableOptions + buildPlugin + verifyPlugin to
     BUILD_TASKS along with -PenablePublish + -Pjetbrains.publish.suffix.
     This is the publication path.

  2. validate-lang == 'true' && effective != 'true' (PR build with
     lang/ changes, or manual dispatch with include-lang) --
     adds verifyPlugin only, with -PincludeBuildLang/-PincludeBuildAttachLang
     and no publish properties. The plugin is built and verified
     but nothing is staged for Marketplace.

  3. Otherwise -- the IntelliJ plugin tasks are not in BUILD_TASKS
     at all. lang/intellij-plugin/build/distributions/ stays empty
     and there is nothing to clobber.

The standalone "Verify IntelliJ plugin compatibility" step and its
two "Skip" companion steps are deleted. There is now exactly one
place in CI that runs verifyPlugin, and the staged distribution
ZIP is by construction the same artifact that was just verified.

The "Cache IntelliJ IDE distributions" step keeps the same
validate-lang gate (it warms the cache for whichever path runs
verifyPlugin in the main build) and the "Upload Plugin Verifier
reports" step is unchanged.

Marketplace publication trigger is unchanged: the snapshot-publish
workflow is kicked off only by master pushes (or manual dispatch),
in the same job that fires Homebrew, Docker, and GitHub release
updates. PR builds verify the plugin but never publish.

== Fix in publish-snapshot.yml ==

Two defenses so a regression of this class fails loudly instead of
hiding behind the green-checkmark camouflage that masked this one:

  1. Before calling Marketplace, extract <version> from the ZIP's
     META-INF/plugin.xml and abort if it doesn't match the
     publishVersion the CI build claimed it baked in. Marketplace
     derives the upload version from the ZIP, not from any form
     field, so a mismatch here means the build produced a stale or
     bare-versioned artifact -- uploading it can only fail (or
     worse, succeed against a stale version).

  2. Tighten the idempotent-rerun heuristic: only treat an
     "already contains version" 400 as a successful no-op when the
     response body explicitly references the version we just
     tried to upload. The previous loose-substring match accepted
     "channel 'alpha' already contains version 0.4.4-SNAPSHOT" as
     proof that 0.4.4-SNAPSHOT.<timestamp> was published -- exactly
     the substitution that hid this regression for two days. The
     full Marketplace response is now echoed in the idempotent
     path so future debuggers don't have to guess at it.

The mismatch check uses unzip + sed on the inner plugin JAR, no
new tooling required on the runner image.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes IntelliJ Marketplace snapshot publishing in CI by ensuring the verified IntelliJ plugin artifact is the same one staged for publication, and by adding guards that fail loudly if a “bare”/stale versioned ZIP is about to be uploaded.

Changes:

  • Consolidates IntelliJ verifyPlugin execution into the main Gradle build invocation (removing the standalone verifier step that could clobber the staged ZIP version).
  • Adds a pre-upload sanity check in publish-snapshot.yml to confirm the ZIP’s embedded plugin.xml version matches the expected publish version.
  • Tightens the “already contains version” idempotency heuristic to only treat it as a no-op when the response references the exact version being uploaded.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/publish-snapshot.yml Adds ZIP/plugin.xml version sanity-check and stricter handling of Marketplace “already contains version” responses.
.github/workflows/commit.yml Collapses IntelliJ verification into the main CI Gradle invocation and removes the standalone verifier step.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/publish-snapshot.yml Resolved
Comment thread .github/workflows/commit.yml Resolved
lagergren added a commit that referenced this pull request May 1, 2026
Two follow-up tweaks from the PR review.

== Drop the IntelliJ IDE distribution cache ==

Pre-PR, lang/.intellijPlatform/ides was cached via actions/cache@v4
with a step ordered AFTER the main build, so the cache restore was a
no-op for the run that needed it (Gradle had already downloaded the
IDE). The save still happened post-job, so subsequent runs benefited
slightly -- but only via the standalone verifier that this PR has now
deleted, so the cache no longer accelerates anything in the new shape.

Rather than fix the ordering, drop the cache entirely. ~1 GB per
cached IDE eats into the 10 GB per-repo GitHub cache budget that's
much more valuable for PR Gradle / dep caches that hit on every build.
The verifier only needs the IDE on the rare lang/-changed run (PR
validation or master publish), and the IntelliJ Platform Gradle Plugin
redownloads it on demand. ~1-2 minutes slower on those rare runs, but
it stops displacing caches that hit on every PR.

A NOTE comment is added where the cache step used to live so this
decision doesn't get re-litigated by someone reading "but we should
cache the IDE!" without context.

== Better diagnostics in the pre-upload sanity check ==

Copilot review on PR #454 flagged that the previous version-mismatch
diagnostic was ambiguous when the failure was actually structural --
e.g., the find expression returned empty because the IntelliJ Platform
Gradle Plugin changed its ZIP layout, not because the version was
wrong. Both paths printed the same "<version>: <empty>" message.

Split the diagnostic into three explicit failure modes, each with
targeted output:

  1. INNER_JAR not found in the ZIP -- print top-level ZIP layout so
     the next maintainer can see what the plugin actually produced
     and update the find expression.

  2. plugin.xml found but no <version> element extracted -- print
     JAR contents and the first 80 lines of plugin.xml so a malformed
     descriptor or missing META-INF entry is obvious.

  3. Version mismatch (the original case this PR was meant to catch)
     -- now also echoes the inner JAR path so reviewers can correlate
     against build/distributions/ in the build artifacts.

No behavioural change for the happy path or for the bug-detection
path; just better signal when something else goes wrong.
Two follow-up tweaks from the PR review.

== Drop the explicit IntelliJ IDE distribution cache ==

Pre-PR, lang/.intellijPlatform/ides was cached via actions/cache@v4
with a step ordered AFTER the main build, so the cache restore was a
no-op for the run that needed it (Gradle had already downloaded the
IDE). The save still happened post-job, so subsequent runs benefited
slightly -- but only via the standalone verifier that this PR has now
deleted, so the explicit cache no longer accelerates anything in the
new shape.

Rather than fix the ordering, drop the explicit cache entirely. ~1 GB
per cached IDE eats into the 10 GB per-repo GitHub cache budget that's
much more valuable for PR Gradle / dep caches that hit on every build.
The verifier only needs the IDE on the rare lang/-changed run (PR
validation or master publish), and the IntelliJ Platform Gradle Plugin
redownloads it on demand. ~1-2 minutes slower on those rare runs, but
it stops the duplicate explicit cache entry from displacing caches
that hit on every PR.

A NOTE comment is added where the cache step used to live so this
decision doesn't get re-litigated by someone reading "but we should
cache the IDE!" without context.

Caveat (for completeness, not addressed by this PR): the IntelliJ
Platform Gradle Plugin also unpacks the IDE under
  ~/.gradle/caches/9.5.0/transforms/.../transformed/idea-261*/
which is captured by setup-gradle's gradle-transforms-v1 cache
pattern (/home/runner/.gradle/caches/*/transforms/*/) -- a few hundred
MB end up in that cache key on lang/-changed runs. This behaviour
predates PR #452 (the bug this PR is fixing), is not new, and is left
alone here. Eliminating it would require filtering setup-gradle's
gradle-home-cache-excludes, with destabilization risk for unrelated
artifact transforms. Punted as a separate cache-tuning task if the
gradle-transforms key ever becomes a budget problem; this PR is about
the publish-version regression, not full IDE-cache eradication.

== Better diagnostics in the pre-upload sanity check ==

Copilot review on PR #454 flagged that the previous version-mismatch
diagnostic was ambiguous when the failure was actually structural --
e.g., the find expression returned empty because the IntelliJ Platform
Gradle Plugin changed its ZIP layout, not because the version was
wrong. Both paths printed the same "<version>: <empty>" message.

Split the diagnostic into three explicit failure modes, each with
targeted output:

  1. INNER_JAR not found in the ZIP -- print top-level ZIP layout so
     the next maintainer can see what the plugin actually produced
     and update the find expression.

  2. plugin.xml found but no <version> element extracted -- print
     JAR contents and the first 80 lines of plugin.xml so a malformed
     descriptor or missing META-INF entry is obvious.

  3. Version mismatch (the original case this PR was meant to catch)
     -- now also echoes the inner JAR path so reviewers can correlate
     against build/distributions/ in the build artifacts.

No behavioural change for the happy path or for the bug-detection
path; just better signal when something else goes wrong.
@lagergren
lagergren force-pushed the lagergren/fix-intellij-publish-version-clobber branch from 548aaea to a2ed7fc Compare May 1, 2026 19:40

@ggleyzer ggleyzer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Blindly trusting it :)

@lagergren
lagergren merged commit 8e8eac7 into master May 1, 2026
4 checks passed
@lagergren
lagergren deleted the lagergren/fix-intellij-publish-version-clobber branch May 1, 2026 19:57
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.

3 participants