-
Notifications
You must be signed in to change notification settings - Fork 22
156 lines (126 loc) · 3.71 KB
/
publish.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Publish packages
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
linters:
name: Linting checks
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Get node version
id: node
run: |
echo "::set-output name=version::$(node -v)"
- name: Get node_modules cache
uses: actions/cache@v3.0.2
id: node_modules
with:
path: |
**/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.lock') }}-${{ steps.node.outputs.version }}
- name: Install dependencies
run: npm install
- name: Run linters
run: npm run lint
tests:
name: Test checks
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Get node version
id: node
run: |
echo "::set-output name=version::$(node -v)"
- name: Get node_modules cache
uses: actions/cache@v3.0.2
id: node_modules
with:
path: |
**/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.lock') }}-${{ steps.node.outputs.version }}
- name: Install dependencies
run: npm ci
- name: Install playwright browsers
run: npx playwright install --with-deps
- name: Build
run: npm run build
- name: Run tests
run: npm run test
bump-monorepo:
name: Bump monorepo
runs-on: ubuntu-latest
needs:
- linters
- tests
steps:
- uses: actions/checkout@v3
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Remove 'v' from RELEASE_VERSION
run: |
echo "Original RELEASE_VERSION: $RELEASE_VERSION"
RELEASE_VERSION=$(echo "$RELEASE_VERSION" | sed 's/^v//')
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
shell: bash
- name: Install SSH Client
uses: webfactory/ssh-agent@v0.7.0
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
- name: Checkout
uses: actions/checkout@v3
with:
ref: main
- name: Git user config
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Update version
run: npm version $RELEASE_VERSION --no-git-tag-version
- name: Commit version
run: |
git add .
git commit -m "bump: v$RELEASE_VERSION"
- name: Push changes
uses: ad-m/github-push-action@master
with:
force-with-lease: true
ssh: true
branch: main
publish:
name: Publish on npm
runs-on: ubuntu-latest
needs: bump-monorepo
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Login to npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Install Dependencies
run: npm ci
- name: Build Packages
run: npm run build
- name: Publish to npm
run: npm run release