Skip to content

Commit

Permalink
More logging for npm publish (#7327)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed May 24, 2023
1 parent 7110588 commit 4c492e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
options:
- master
- v8
verbose:
description: 'Enable verbose logging'
type: boolean
default: false

jobs:
deploy:
Expand Down Expand Up @@ -107,6 +111,7 @@ jobs:
NPM_TOKEN_APP_CHECK_COMPAT: ${{ secrets.NPM_TOKEN_APP_CHECK_COMPAT }}
NPM_TOKEN_API_DOCUMENTER: ${{ secrets.NPM_TOKEN_API_DOCUMENTER }}
CI: true
VERBOSE_NPM_LOGGING: ${{github.event.inputs.verbose}}
- name: Get release version
id: get-version
# STAGING_VERSION = version with staging hash, e.g. 1.2.3-20430523
Expand Down
18 changes: 15 additions & 3 deletions scripts/release/utils/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ async function publishPackageInCI(
npmTag: string,
dryRun: boolean
) {
let stdoutText = '';
let stderrText = '';
try {
const path = await mapPkgNameToPkgPath(pkg);

Expand All @@ -128,24 +130,34 @@ async function publishPackageInCI(
args.push('--dry-run');
}

if (process.env.VERBOSE_NPM_LOGGING === 'true') {
args.push('--verbose');
}

// Write proxy registry token for this package to .npmrc.
await exec(
`echo "//wombat-dressing-room.appspot.com/:_authToken=${
process.env[getEnvTokenKey(pkg)]
}" >> ~/.npmrc`
);

const spawnPromise = spawn('npm', args, { cwd: path });
const childProcess = spawnPromise.childProcess;
// These logs can be very verbose. Only print them if there's
// an error.
childProcess.stdout?.on('data', function (data) {
console.log(`[publishing ${pkg}] stdout: `, data.toString());
stdoutText += data.toString();
});
childProcess.stderr?.on('data', function (data) {
console.log(`[publishing ${pkg}] stderr: `, data.toString());
stderrText += data.toString();
});
await spawnPromise;
return spawnPromise;
} catch (err) {
console.log(`Error publishing ${pkg}`);
console.log(`stdout for ${pkg} publish:`);
console.log(stdoutText);
console.log(`stderr for ${pkg} publish:`);
console.error(stderrText);
throw err;
}
}
Expand Down

0 comments on commit 4c492e0

Please sign in to comment.