Skip to content

Commit 3784f2b

Browse files
committed
ci(gh-actions): add a release workflow
1 parent e242059 commit 3784f2b

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

.github/workflows/release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
prepare:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
node-version: ['14']
14+
name: "[v${{ matrix.node-version }}] check"
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v2-beta
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
# Check if cache exists, based on the hash of the lockfile
26+
- name: Cache node_modules
27+
id: cache-node_modules
28+
uses: actions/cache@v2
29+
with:
30+
path: node_modules
31+
key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }}
32+
restore-keys: |
33+
${{ runner.os }}-node-${{matrix.node-version}}-
34+
${{ runner.os }}-node-
35+
${{ runner.os }}-
36+
37+
# If there is no cache available, we run npm installation in CI mode
38+
- name: Install dependencies
39+
if: steps.cache-node_modules.outputs.cache-hit != 'true'
40+
run: npm ci
41+
42+
- name: Lint
43+
run: npm run lint
44+
45+
- name: Run tests
46+
run: npm run test
47+
48+
build-and-release:
49+
runs-on: ubuntu-latest
50+
needs: prepare
51+
strategy:
52+
matrix:
53+
node-version: ['14']
54+
name: "[v${{ matrix.node-version }}] release"
55+
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v2
59+
60+
- name: Use Node.js ${{ matrix.node-version }}
61+
uses: actions/setup-node@v2-beta
62+
with:
63+
node-version: ${{ matrix.node-version }}
64+
65+
# Check if cache exists, based on the hash of the lockfile
66+
- name: Cache node_modules
67+
id: cache-node_modules
68+
uses: actions/cache@v2
69+
with:
70+
path: node_modules
71+
key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }}
72+
restore-keys: |
73+
${{ runner.os }}-node-${{matrix.node-version}}-
74+
${{ runner.os }}-node-
75+
${{ runner.os }}-
76+
77+
# If there is no cache available, we run npm installation in CI mode
78+
- name: Install dependencies
79+
if: steps.cache-node_modules.outputs.cache-hit != 'true'
80+
run: npm ci
81+
82+
# Build and check if it builds ok.
83+
- name: Build
84+
env:
85+
BUNDLESIZE_GITHUB_TOKEN: ${{ secrets.BUNDLESIZE }}
86+
run: npm run build
87+
88+
- name: Release
89+
env:
90+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
run: npm run release

0 commit comments

Comments
 (0)