-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (96 loc) · 3.79 KB
/
pr-release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: pr-release
on:
pull_request:
branches: [main]
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: NPM registry authentication
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: pnpm i
- 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
- name: Publish packages
id: publish
continue-on-error: true
run: |
pnpm changeset version --snapshot dev-pr-${{ github.event.pull_request.number }}
pnpm build:packages
pnpm changeset publish --tag dev-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_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: Get @dinui/cli version
if: steps.publish.outcome == 'success'
uses: martinbeentjes/npm-get-version-action@v1.3.1
id: dinui-cli-version
with:
path: packages/cli
- 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}}
npx @dinui/cli@${{ steps.dinui-cli-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