Skip to content

Commit

Permalink
fail with grace
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmgdr committed Oct 26, 2023
1 parent 26615b4 commit 4e185da
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 21 additions & 17 deletions publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 35 in publish.ts

View workflow job for this annotation

GitHub Actions / Snapshot Release

No overload matches this call.
}
}

publish()

0 comments on commit 4e185da

Please sign in to comment.