1
- name : CI/CD
1
+ name : CI/CD Pipeline
2
2
3
3
on :
4
4
push :
5
- branches : [ master ]
5
+ branches : [ master, develop ]
6
+ tags : ['v*']
6
7
pull_request :
7
- branches : [ master ]
8
+ branches : [ master, develop ]
8
9
release :
9
10
types : [created]
10
11
12
+ permissions :
13
+ contents : write
14
+ packages : write
15
+
11
16
jobs :
12
17
test :
13
18
runs-on : ubuntu-latest
19
+ permissions :
20
+ contents : write
21
+ packages : write
14
22
strategy :
15
23
matrix :
16
24
node-version : [16.x, 18.x, 20.x]
@@ -23,78 +31,90 @@ jobs:
23
31
with :
24
32
node-version : ${{ matrix.node-version }}
25
33
cache : ' npm'
26
-
27
- - name : Clean install dependencies
28
- run : |
29
- rm -f package-lock.json
30
- npm install
31
-
32
- - name : Run linter
34
+
35
+ - name : Install dependencies
36
+ run : npm ci
37
+
38
+ - name : Run linting
33
39
run : npm run lint
34
-
35
- - name : Run tests
36
- run : npm test
37
-
38
- - name : Build
39
- run : npm run build
40
+
41
+ - name : Run tests with coverage
42
+ run : npm run test:coverage
43
+
44
+ - name : Upload coverage to Codecov
45
+ uses : codecov/codecov-action@v3
46
+ with :
47
+ token : ${{ secrets.CODECOV_TOKEN }}
48
+ files : ./coverage/lcov.info
49
+ flags : unittests
50
+ name : codecov-umbrella
51
+ fail_ci_if_error : false
52
+ verbose : true
40
53
41
- test-integration :
54
+ build :
42
55
needs : test
43
56
runs-on : ubuntu-latest
44
- strategy :
45
- matrix :
46
- test-project : [webpack-test, rollup-test, vite-test]
47
-
57
+ if : github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/v'))
58
+
48
59
steps :
49
60
- uses : actions/checkout@v3
50
61
51
- - name : Use Node.js 18
62
+ - name : Use Node.js
52
63
uses : actions/setup-node@v3
53
64
with :
54
- node-version : ' 18'
65
+ node-version : ' 18.x '
55
66
cache : ' npm'
56
-
57
- - name : Install package dependencies
58
- run : |
59
- rm -f package-lock.json
60
- npm install
61
-
67
+
68
+ - name : Install dependencies
69
+ run : npm ci
70
+
62
71
- name : Build package
63
72
run : npm run build
64
-
65
- - name : Install test project dependencies
66
- working-directory : test-projects/${{ matrix.test-project }}
67
- run : |
68
- rm -f package-lock.json
69
- npm install
70
-
71
- - name : Build test project
72
- working-directory : test-projects/${{ matrix.test-project }}
73
- run : npm run build
73
+
74
+ - name : Upload build artifacts
75
+ uses : actions/upload-artifact@v3
76
+ with :
77
+ name : dist
78
+ path : dist/
79
+ retention-days : 5
74
80
75
81
publish :
76
- needs : [test, test-integration ]
82
+ needs : [test, build ]
77
83
runs-on : ubuntu-latest
78
- if : github.event_name == 'release' && github.event.action == 'created'
79
-
84
+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
85
+ permissions :
86
+ contents : write
87
+ packages : write
88
+
80
89
steps :
81
90
- uses : actions/checkout@v3
82
91
83
- - name : Use Node.js 18
92
+ - name : Use Node.js
84
93
uses : actions/setup-node@v3
85
94
with :
86
- node-version : ' 18'
95
+ node-version : ' 18.x '
87
96
registry-url : ' https://registry.npmjs.org'
88
-
97
+
98
+ - name : Download build artifacts
99
+ uses : actions/download-artifact@v3
100
+ with :
101
+ name : dist
102
+ path : dist/
103
+
89
104
- name : Install dependencies
90
- run : |
91
- rm -f package-lock.json
92
- npm install
93
-
94
- - name : Build
95
- run : npm run build
96
-
97
- - name : Publish to npm
105
+ run : npm ci
106
+
107
+ - name : Publish to NPM
98
108
run : npm publish --access public
99
109
env :
100
110
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
111
+
112
+ - name : Create GitHub Release
113
+ uses : softprops/action-gh-release@v1
114
+ with :
115
+ files : |
116
+ dist/*
117
+ README.md
118
+ LICENSE
119
+ env :
120
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments