-
Notifications
You must be signed in to change notification settings - Fork 36
292 lines (237 loc) · 8.55 KB
/
github-actions.yml
File metadata and controls
292 lines (237 loc) · 8.55 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
name: Usetheform CI
on:
push:
pull_request:
workflow_dispatch:
inputs:
run_publish:
description: "Publish on NPM?"
required: false
default: "false"
env:
NODE_VERSION: 20.19.0
jobs:
tests:
name: Unit Tests 🧪 - React
runs-on: ubuntu-latest
strategy:
matrix:
react-version: ['17.0.0', '18.2.0', '19.0.0'] # Specify the React versions here
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Set up Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Install react@${{ matrix.react-version }} 📦
run: yarn add react@${{ matrix.react-version }} react-dom@${{ matrix.react-version }} -D
working-directory: workspaces/usetheform
- name: React testing-library version 📦
if: matrix.react-version == '17.0.0'
run: yarn add --dev @testing-library/react@^12 @testing-library/jest-dom@^5.16.5
working-directory: workspaces/usetheform
- name: Run Lint 🔍
run: yarn lint
- name: Run tests 🧪
run: yarn test
coveralls:
needs: [tests]
name: Coveralls 📈
runs-on: ubuntu-latest
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Set up Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Run tests 🧪
run: yarn test:cov
- name: Coveralls 📈
uses: coverallsapp/github-action@v2.3.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: workspaces/usetheform
cypress-test:
name: Automation Tests 🌐
runs-on: ubuntu-latest
strategy:
matrix:
browser: [chrome, firefox, edge, electron]
env:
TERM: xterm
CI: true
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Setup Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Start server 🚀
run: yarn cy:server &
- name: Wait for server ⏳
run: npx wait-on http://localhost:3000/index_react_16.13.0.html --timeout 120000
- name: Run Cypress Tests on ${{ matrix.browser }} 🧪
uses: cypress-io/github-action@v6
env:
CI: true
with:
browser: ${{ matrix.browser }}
command: yarn cy:run --browser ${{ matrix.browser }}
- name: Upload Cypress Artifacts 📂
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-artifacts-${{ matrix.browser }}-${{ github.run_number }}-${{ github.sha }}
path: |
cypress/videos
cypress/screenshots
build:
name: Build 🛠️
needs: [tests, cypress-test]
runs-on: ubuntu-latest
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Set up Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Build 🔨
run: yarn build
publish-alpha:
name: NPM Publish Alpha Version 🔥
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run_publish == 'true' &&
(github.ref != 'refs/heads/master' && github.ref != 'refs/heads/develop')
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Setup Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org/"
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Build 🔨
run: |
yarn build
cp README.md workspaces/usetheform/README.md
cp LICENSE.md workspaces/usetheform/LICENSE.md
- name: Extract current version 🏷️
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
working-directory: workspaces/usetheform
- name: Update version for alpha release 📦
run: npm version $VERSION-alpha.${{ github.run_number }} --no-git-tag-version
working-directory: workspaces/usetheform
- name: Publish to npm as alpha 🚀
run: npm publish --tag alpha
working-directory: workspaces/usetheform
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-stable:
name: NPM Publish Stable Version ⭐
runs-on: ubuntu-latest
needs: [tests, cypress-test]
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run_publish == 'true' &&
github.ref == 'refs/heads/master'
permissions:
contents: write
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Setup Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org/"
- name: Extract current version
id: version
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
working-directory: workspaces/usetheform
- name: 🏷️ Check if tag already exists
run: |
TAG="v${{ env.VERSION }}"
echo "Checking if tag $TAG already exists..."
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "⚠️ Tag $TAG already exists. Skipping release."
exit 0
fi
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Build 🔨
run: |
yarn build
cp README.md workspaces/usetheform/README.md
cp LICENSE.md workspaces/usetheform/LICENSE.md
- name: Publish to npm 🚀
run: npm publish
working-directory: workspaces/usetheform
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish new Tag 🚀
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git tag -a v${{ env.VERSION }} -m "Release version v${{ env.VERSION }}"
git push origin v${{ env.VERSION }}
- name: Extract Changelog for current version 📝
run: |
CHANGELOG_ENTRY=$(awk -v ver="${{ env.VERSION }}" '
/^## \[v?'${{ env.VERSION }}'\]/ {p=1;print;next}
p&&/^## \[/{p=0}
p{print}
' CHANGELOG.md)
if [ -z "$CHANGELOG_ENTRY" ]; then
echo "Error: Changelog entry not found for version ${{ env.VERSION }}"
exit 1
fi
echo "$CHANGELOG_ENTRY" > release-notes.txt
- name: Create GitHub Release 🎉
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: v${{ env.VERSION }}
body_path: release-notes.txt
generate_release_notes: false
token: ${{ secrets.GITHUB_TOKEN }}
deploy_docs:
name: Deploy Docs 📚
runs-on: ubuntu-latest
needs: [tests, cypress-test]
if: |
github.ref == 'refs/heads/master'
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Build Docs 🔨
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- run: yarn install --immutable
- run: yarn docs:build
- run: rm .gitignore
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.7.3
with:
folder: workspaces/docs/build