Skip to content

Use the built-in AggregateError when possible #44

Use the built-in AggregateError when possible

Use the built-in AggregateError when possible #44

Workflow file for this run

name: Publish Preview Release
on:
issue_comment:
types: [created]
jobs:
publish-preview:
if: ${{ github.event.issue.pull_request && github.event.comment.user.id == github.event.issue.user.id && startsWith(github.event.comment.body, '/publish') }}
runs-on: ubuntu-latest
steps:
- name: Notify PR owner
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.issue.number }}
comment-id: ${{ github.event.comment.id }}
body: |
 
[Your preview release is being published.](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) :hourglass:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
- uses: actions/checkout@v4
if: success()
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
node-version: '22.x'
cache: pnpm
- run: pnpm install
- run: pnpm build
- name: Calculate version
id: get-version
run: echo "::set-output name=version::$(node -p "require('./package.json').version")-pr${{ github.event.issue.number }}.$(git rev-parse --short HEAD)"
- name: Update package version
run: npm version ${{ steps.get-version.outputs.version }} --no-git-tag-version
- name: Publish to NPM
run: npm publish --tag pr${{ github.event.issue.number }} --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Notify PR owner
uses: peter-evans/create-or-update-comment@v4
if: success()
with:
issue-number: ${{ github.event.issue.number }}
comment-id: ${{ github.event.comment.id }}
body: |
 
Congrats! Your preview release is ready. :rocket:
```sh
pnpm add radashi@pr${{ github.event.issue.number }}
# or
pnpm add radashi@${{ steps.get-version.outputs.version }}
```
token: ${{ secrets.GITHUB_TOKEN }}
- name: Failure
uses: peter-evans/create-or-update-comment@v4
if: failure()
with:
issue-number: ${{ github.event.issue.number }}
comment-id: ${{ github.event.comment.id }}
body: |
 
Oops! Your preview release failed to publish. :x:
token: ${{ secrets.GITHUB_TOKEN }}