Skip to content

ci: seprate next and stable release #29

ci: seprate next and stable release

ci: seprate next and stable release #29

Workflow file for this run

name: pr-release
on:
pull_request:
branches: [main]
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
- name: Context vars
id: vars
run: |
echo "short_sha=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" >> $GITHUB_OUTPUT
- name: Find pr-release comment
uses: peter-evans/find-comment@v3
id: pr-fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!--pr-release-->'
- name: Create or update pr-release comment with in process status
uses: peter-evans/create-or-update-comment@v4
id: pr-couc
with:
comment-id: ${{ steps.pr-fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!--pr-release-->
## PR-release for testing
Latest commit: `${{ steps.vars.outputs.short_sha }}`
Status: 👷 In process...
[View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
edit-mode: replace
- uses: pnpm/action-setup@v2
- name: Publish packages
id: publish
continue-on-error: true
run: |
pnpm i
pnpm changeset version --snapshot dev-pr-${{ github.event.pull_request.number }}
pnpm build:packages
pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
pnpm changeset publish --tag dev-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Update pr-release comment with failed status
if: steps.publish.outcome != 'success'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.pr-couc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!--pr-release-->
## PR-release for testing
Latest commit: `${{ steps.vars.outputs.short_sha }}`
Status: ❌ Failed
[View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
edit-mode: replace
- name: Get @dinui/react version
if: steps.publish.outcome == 'success'
uses: martinbeentjes/npm-get-version-action@v1.3.1
id: dinui-react-version
with:
path: packages/react-ui
- name: Update pr-release comment with published status
if: steps.publish.outcome == 'success'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.pr-couc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!--pr-release-->
## PR-release for testing
Latest commit: `${{ steps.vars.outputs.short_sha }}`
Status: ✅ Published
```bash
npm install @dinui/react@${{ steps.dinui-react-version.outputs.current-version}}
```
[View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }})
edit-mode: replace
- name: Exit with failed status
if: steps.publish.outcome != 'success'
run: exit 1