From 2a09f6c9962c37343eb5433b19d20b7fb63cee63 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Mon, 31 Jul 2023 17:05:51 +0100 Subject: [PATCH] fix: downgrade semantic-release (#1344) To prevent mixed ESM/CJS imports --- package.json | 4 ++-- src/release-rc.js | 42 +++++++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index d2758bffd..a6c53702c 100644 --- a/package.json +++ b/package.json @@ -232,7 +232,7 @@ "@semantic-release/commit-analyzer": "^10.0.1", "@semantic-release/git": "^10.0.1", "@semantic-release/github": "^9.0.3", - "@semantic-release/npm": "^10.0.4", + "@semantic-release/npm": "^9.0.2", "@semantic-release/release-notes-generator": "^11.0.4", "@types/chai": "^4.2.16", "@types/chai-as-promised": "^7.1.3", @@ -302,7 +302,7 @@ "react-native-test-runner": "^5.0.0", "read-pkg-up": "^10.0.0", "rimraf": "^5.0.0", - "semantic-release": "^21.0.7", + "semantic-release": "^20.1.3", "semantic-release-monorepo": "^7.0.5", "semver": "^7.3.8", "source-map-support": "^0.5.20", diff --git a/src/release-rc.js b/src/release-rc.js index 78b83f0ec..9cc780ef1 100644 --- a/src/release-rc.js +++ b/src/release-rc.js @@ -76,11 +76,23 @@ async function releaseMonorepoRcs (commit, ctx) { await retry(async () => { console.info(`npm publish --tag ${ctx.tag} --dry-run ${!process.env.CI}`) - await execa('npm', ['publish', '--tag', ctx.tag, '--dry-run', `${!process.env.CI}`], { - stdout: 'inherit', - stderr: 'inherit', - cwd: project.dir - }) + + try { + await execa('npm', ['publish', '--tag', ctx.tag, '--dry-run', `${!process.env.CI}`], { + stdout: 'inherit', + stderr: 'inherit', + cwd: project.dir, + all: true + }) + } catch (/** @type {any} */ err) { + if (err.all?.includes('You cannot publish over the previously published versions')) { + // this appears to be a bug in npm, sometimes you publish successfully but it also + // returns an error + return + } + + throw err + } }, { retries: ctx.retries }) @@ -107,10 +119,22 @@ async function releaseRc (commit, ctx) { await retry(async () => { console.info(`npm publish --tag ${ctx.tag} --dry-run ${!process.env.CI}`) - await execa('npm', ['publish', '--tag', ctx.tag, '--dry-run', `${!process.env.CI}`], { - stdout: 'inherit', - stderr: 'inherit' - }) + + try { + await execa('npm', ['publish', '--tag', ctx.tag, '--dry-run', `${!process.env.CI}`], { + stdout: 'inherit', + stderr: 'inherit', + all: true + }) + } catch (/** @type {any} */ err) { + if (err.all?.includes('You cannot publish over the previously published versions')) { + // this appears to be a bug in npm, sometimes you publish successfully but it also + // returns an error + return + } + + throw err + } }, { retries: ctx.retries })