Skip to content

Commit

Permalink
capture output
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmgdr committed Oct 20, 2023
1 parent d636cab commit 793d67a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,17 @@ jobs:
# when there are version changes "All files have been updated. Review them and commit at your leisure"
# when there are no version changes "No unreleased changesets found, exiting"
- name: Publish packages
run: yarn cs publish --tag alpha --no-git-tag --dry-run
run: '"PUBLISHED_PACKAGES=$(yarn ts-node publish.ts)" >> "$GITHUB_OUTPUT"'
# Publishing "@celo/phone-number-privacy-common" at "3.0.4-alpha-964a99345"
# id like to take all lines like the above and create an array of packages with form
# ["@celo/[email protected]"]
outputs:
# output array of packages like ["@celo/[email protected]"]
packages: ${{ steps.versioning.outputs }}
status: no-op | success
packages: ${{ steps.versioning.outputs.PUBLISHED_PACKAGES }}
install:
name: Install Snapshot Releases
needs: ['release']
# if any packages where published install them else report success
# if: ${{needs.release.outputs.status == 'success'}}
runs-on: ['self-hosted', 'org', 'npm-publish']
steps:
# for each package call npm install package@version
Expand Down
32 changes: 32 additions & 0 deletions publish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as child_process from 'child_process'

const FAKE_OUTPUT = `
🦋 info npm info @celo/phone-number-privacy-common
🦋 info npm info @celo/encrypted-backup
🦋 info npm info @celo/identity
🦋 info @celo/phone-number-privacy-common is being published because our local version (3.0.4-alpha-964a99345) has not been published on npm
🦋 warn @celo/encrypted-backup is not being published because version 5.0.4 is already published on npm
🦋 warn @celo/identity is not being published because version 5.0.4 is already published on npm
🦋 info Publishing "@celo/phone-number-privacy-common" at "3.0.4-alpha-964a99345"
🦋 info Publishing "@celo/identity-common" at "3.0.4-alpha-964a99345"
`
// 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
})


const pkgs = arrayOfLines.filter(line => !!line).map((line) => {
if (!line) return
return line[0].replace('info Publishing ', '').replace(' at ', '@')
}).join(',')

console.log(pkgs)
return pkgs
}

publish()

0 comments on commit 793d67a

Please sign in to comment.