| name: Canary Release |
|
|
| on: |
| workflow_call: |
| secrets: |
| CHANGESETS_PAT: |
| required: true |
| NPM_TOKEN: |
| required: true |
| pull_request: |
| types: |
| - opened |
| - synchronize |
| - reopened |
| - labeled |
|
|
| jobs: |
| release-canary: |
| name: Release Canary |
| runs-on: ubuntu-latest |
| if: contains(github.event.pull_request.labels.*.name, 'release:canary') |
| steps: |
| - name: Checkout Repo |
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 |
| with: |
| fetch-depth: 0 |
|
|
| - name: Setup Node.js |
| uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 |
| with: |
| node-version: 18.x |
|
|
| - name: Install Dependencies |
| run: npm ci |
|
|
| - name: Version |
| run: npx changeset version --snapshot canary |
| env: |
| GITHUB_TOKEN: ${{ secrets.CHANGESETS_PAT }} |
|
|
| - name: Publish Canary Packages |
| id: changesets |
| uses: changesets/action@e2f8e964d080ae97c874b19e27b12e0a8620fb6c |
| with: |
| |
| publish: npm run release:canary |
| createGithubReleases: false |
| env: |
| GITHUB_TOKEN: ${{ secrets.CHANGESETS_PAT }} |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
|
|
| - name: Compute new packages info |
| id: packagesData |
| if: success() && steps.changesets.outputs.published == 'true' |
| |
| |
| |
| run: | |
| echo "::set-output name=count::$(echo ${{toJson(steps.changesets.outputs.publishedPackages)}} | jq '. | length')" |
| echo "::set-output name=packageList::$(echo ${{toJson(steps.changesets.outputs.publishedPackages)}} | jq 'reduce .[] as $item (""; . + "#### \($item.name)@\($item.version)\n```\nnpm install \($item.name)@canary\n```\n")')" |
| |
| - name: Comment |
| uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 |
| if: success() && steps.changesets.outputs.published == 'true' |
| with: |
| header: 'canary-release' |
| message: | |
| ### :package: Canary Packages Published |
| |
| Latest commit: ${{ github.event.pull_request.head.sha }} |
|
|
| <details><summary>Published ${{ steps.packagesData.outputs.count }} packages</summary> |
|
|
| ${{ fromJSON(steps.packagesData.outputs.packageList) }} |
|
|
| </details> |
|
|