diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 117cbdda8..c9bcf45d2 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -67,7 +67,7 @@ jobs: id: 'publishing' env: NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }} - - name: View output + - name: Fail if no output (publishing error) run: | echo ${{ steps.publishing.outputs.PUBLISHED_PACKAGES }} [ '${{ steps.publishing.outputs.PUBLISHED_PACKAGES }}' == '' ] && exit 1 diff --git a/publish.ts b/publish.ts index a3a6748c6..796348956 100644 --- a/publish.ts +++ b/publish.ts @@ -12,24 +12,28 @@ const FAKE_OUTPUT = ` ` // publish packages as alpha and return the list of packages published function publish() { - const snapshot = child_process.execSync('yarn cs publish --tag alpha --no-git-tag') - // const snapshot = child_process.execSync(`echo "${FAKE_OUTPUT}"`) - const arrayOfLines = snapshot - .toString() - .split('\n') - .map((line: string) => { - const matches = line.match(/info Publishing @celo.*$/) - return matches - }) + try { + const snapshot = child_process.execSync('yarn cs publish --tag alpha --no-git-tag') + // const snapshot = child_process.execSync(`echo "${FAKE_OUTPUT}"`) + const arrayOfLines = snapshot + .toString() + .split('\n') + .map((line: string) => { + const matches = line.match(/info Publishing @celo.*$/) + return matches + }) - const pkgs = arrayOfLines - .filter((line) => !!line) - .map((line) => { - if (!line) return - return line[0].replace('info Publishing ', '').replace(' at ', '@') - }) - const result = pkgs.length ? JSON.stringify(pkgs) : 'no-op' - process.stdout.write(result) + const pkgs = arrayOfLines + .filter((line) => !!line) + .map((line) => { + if (!line) return + return line[0].replace('info Publishing ', '').replace(' at ', '@') + }) + const result = pkgs.length ? JSON.stringify(pkgs) : 'no-op' + process.stdout.write(result) + } catch (err) { + process.stderr.write(err) + } } publish()