Skip to content

Commit 7941fa7

Browse files
committed
JavaScript: Skip npmPublish when npmBuild is restored from cache
When npmBuild is restored from the build cache (no JS source changes), version.txt retains the timestamp from the original build, causing npm to reject the publish with a 403 since that version already exists. Adding onlyIf { npmBuild.get().state.didWork } to npmPublish for snapshot builds so we skip publishing when nothing actually changed.
1 parent 92424ce commit 7941fa7

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

rewrite-javascript/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ val npmPublish = tasks.register<NpmTask>("npmPublish") {
227227
args = provider { listOf("publish", npmPack.get().archiveFile.get().asFile.absolutePath) }
228228
if (!project.hasProperty("releasing")) {
229229
args.addAll("--tag", "next")
230+
// Skip publishing when nothing changed in the JavaScript implementation.
231+
// When npmBuild is restored from the build cache, version.txt retains the
232+
// timestamp from the original build, causing a conflict with the previously
233+
// published version on npmjs.
234+
onlyIf { npmBuild.get().state.didWork }
230235
}
231236

232237
workingDir.set(file("rewrite"))

0 commit comments

Comments
 (0)