-
-
Notifications
You must be signed in to change notification settings - Fork 17
140 lines (114 loc) · 4.72 KB
/
canary.yml
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Canary
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
pull-requests: write
env:
FORCE_COLOR: 3
OPENAI_API_KEY: "sk-xyz"
jobs:
canary:
runs-on: ubuntu-latest
timeout-minutes: 14
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.CHANGESET_GITHUB_TOKEN }}
- name: Create git branch
run: |
# Create a git branch from the detached HEAD.
# We need this for some integration tests.
# This branch is not pushed, it's just local to the workflow environment.
git checkout -b test-branch-${{ github.sha }}
- uses: ./.github/shared
- name: Set build version
run: echo "TAG=0.0.0-${{ github.ref_name == 'changeset-release/main' && 'beta' || 'alpha' }}.v$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
id: version
- name: Check secrets exist
run: echo "exist=${{ secrets.GITHUB_TOKEN != '' && 'true' || 'false' }}" >> $GITHUB_OUTPUT
id: secrets
- name: Find Comment
uses: peter-evans/find-comment@v1
if: ${{ github.repository == 'llm-ui-kit/llm-ui' && github.event_name == 'pull_request' }}
id: find-comment-1
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Your pull request has been published to npm
- name: Update existing comment with stale state of npm release
uses: peter-evans/create-or-update-comment@v1
id: update-existing
if: ${{ github.repository == 'llm-ui-kit/llm-ui' && github.event_name == 'pull_request' && steps.find-comment-1.outputs.comment-id != '' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.find-comment-1.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
Your pull request has been published to npm.
You can install @llm-ui/react by running:
```
npm install @llm-ui/react@${{ steps.version.outputs.TAG }}
```
[Pull request has been updated, please wait for latest changes to be pushed to npm...]
- name: Build
run: pnpm build
- name: Configure npm registry token
if: ${{ steps.secrets.outputs.exist == 'true' }}
run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Exit pre-mode if set
continue-on-error: true
run: npx changeset pre exit
- name: Publish build
if: ${{ steps.secrets.outputs.exist == 'true' && github.event_name == 'pull_request' }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.CHANGESET_GITHUB_TOKEN }}
run: |
cat << EOF > .changeset/force-canary-build.md
---
'@llm-ui/json': patch
'@llm-ui/csv': patch
'@llm-ui/code': patch
'@llm-ui/markdown': patch
'@llm-ui/react': patch
'@llm-ui/shared': patch
'create-llm-ui': patch
---
Force canary build
EOF
npx changeset version --snapshot ${{ github.ref_name == 'changeset-release/main' && 'beta' || 'alpha' }}
npx changeset publish --tag ${{ github.ref_name == 'changeset-release/main' && 'dev' || 'canary' }} --no-git-tag
- name: Find Comment
uses: peter-evans/find-comment@v1
if: ${{ steps.secrets.outputs.exist == 'true' && github.event_name == 'pull_request' }}
id: find-comment-2
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Your pull request has been published to npm
- name: Create or update comment of npm release
uses: peter-evans/create-or-update-comment@v1
if: ${{ steps.secrets.outputs.exist == 'true' && github.event_name == 'pull_request' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.find-comment-2.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
Your pull request has been published to npm.
You can install @llm-ui/react by running:
```
npm install @llm-ui/react@${{ steps.version.outputs.TAG }}
```
[Pull request has been updated, please wait for latest changes to be pushed to npm...]