-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (100 loc) · 3.75 KB
/
ci.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
name: CI
on: [push]
jobs:
build:
name: Lint, test, and build on Node ${{ matrix.node }} and ${{ matrix.os }}
strategy:
matrix:
node: # running more than one node causes semantic release tags to be incorrectly created. Fix when you have time!
# - 14
- 16
# - 18
os:
# - macOS-latest
# - windows-latest
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2.4.0
with:
version: latest # 7.1.0 # uses version set in package.json > packageManager
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'pnpm' # Ref: https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md
- name: Install Dependencies
run: pnpm install --frozen-lockfile # verifies lockfile matches package.json
shell: bash
- name: Lint
run: pnpm lint
- name: Test
run: pnpm test -- --ci --coverage --maxWorkers=2
env:
CI: true
- name: Build
run: pnpm build
release:
name: Upload coverage report and release package as needed
needs: [build]
strategy:
matrix:
node: # ****run only one version****
# - 14
- 16
# - 18
os: # ****run only one OS****
# - macOS-latest
# - windows-latest
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2.4.0
with:
version: latest # 7.1.0 # uses version set in package.json > packageManager
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'pnpm' # Ref: https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md
- name: Install Dependencies
run: pnpm install --frozen-lockfile # verifies lockfile matches package.json
shell: bash
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
file: ./coverage/clover.xml # optional
- name: Build
run: pnpm build
# https://github.com/cycjimmy/semantic-release-action
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
id: semantic
with:
# Recommended to specify specifying version range to reduce version errors
# https://www.npmjs.com/package/semantic-release
semantic_version: 19.0.3
branch: main
# https://www.npmjs.com/package/@semantic-release/git
# https://www.npmjs.com/package/@semantic-release/changelog
extra_plugins: |
@semantic-release/git@10.0.1
@semantic-release/changelog@6.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # no need to set since its provided by github automatically
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Push updates to branch for major version
# if there is a new version published, let's say v1.2.3
# then this step will update branch "v1" to this commit
# https://github.com/cypress-io/github-action/branches
if: steps.semantic.outputs.new_release_published == 'true'
run: 'git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/v${{steps.semantic.outputs.new_release_major_version}}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}