-
Notifications
You must be signed in to change notification settings - Fork 88
107 lines (83 loc) · 2.49 KB
/
buildDeploy.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
name: Build and Deploy
on: push
env:
CI: true
NODE_VER: 19
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VER }}
- uses: bahmutov/npm-install@v1
- name: prettier
run: npx prettier '**/*.{js?(on|x),ts?(x),y?(a)ml,graphql,md,css}' --check
- name: typescript
run: npx tsc --noEmit
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VER }}
- uses: bahmutov/npm-install@v1
- name: build
run: npm run build
- name: build package
run: npm version --no-git-tag-version 0.0.0-${{ github.sha }} && npm pack
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build
path: dist
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: react-image-0.0.0-${{ github.sha }}.tgz
path: react-image-0.0.0-${{ github.sha }}.tgz
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VER }}
- uses: bahmutov/npm-install@v1
- name: test
run: npm test
- name: download build artifact
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: test built libs
run: npm run test:dist
deploy:
runs-on: ubuntu-latest
needs: [lint, test]
if: ${{ github.ref_name == 'master' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VER }}
- uses: bahmutov/npm-install@v1
- name: setup .npmrc
run: npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: download build artifact
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: check if package is newer than the published version
id: checkPublish
run: echo "::set-output name=shouldPublish::`npm run -s isNewerThanPublished`"
- name: publish release package if needed
if: steps.checkPublish.outputs.shouldPublish == 'true'
run: npm publish