diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 98672449f1..28278f4413 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -969,4 +969,6 @@ jobs: run: | REF="${{ github.event.inputs.ref || github.ref }}" VERSION="${REF#refs/tags/v}" - node common/scripts/bump.js "$VERSION" --publish + VERSION="${VERSION#v}" + node common/scripts/bump.js "$VERSION" + node common/scripts/safe-publish.js diff --git a/common/scripts/safe-publish.js b/common/scripts/safe-publish.js index 82a6fcad3e..2f0b0368bc 100755 --- a/common/scripts/safe-publish.js +++ b/common/scripts/safe-publish.js @@ -43,8 +43,24 @@ function checkPackageExists(packageName, version) { */ function getPublishablePackages(includePattern) { try { - const output = execSync('rush list -p --json', { encoding: 'utf-8' }) - const config = JSON.parse(output) + const repoRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf-8' }).trim() + const output = execSync('node common/scripts/install-run-rush.js list -p --json', { + encoding: 'utf-8', + cwd: repoRoot + }) + const lines = output.split('\n') + let jsonStart = -1 + for (let i = 0; i < lines.length; i++) { + if (lines[i].trim().startsWith('{')) { + jsonStart = i + break + } + } + if (jsonStart === -1) { + console.error('Could not find JSON output from rush list') + return [] + } + const config = JSON.parse(lines.slice(jsonStart).join('\n')) return config.projects.filter((project) => { // Check if package should be published according to rush.json