-
Notifications
You must be signed in to change notification settings - Fork 88
133 lines (107 loc) · 3.74 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
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
name: Build and Deploy
on: push
env:
CI: true
NODE_VER: 20
NETLIFY_SITE_ID: 89194942-bd48-4c23-a181-7e489c17eabc
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
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@v4
- uses: actions/setup-node@v4
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@v4
with:
name: build
path: dist
- name: Upload package
uses: actions/upload-artifact@v4
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@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VER }}
- uses: bahmutov/npm-install@v1
- name: test
run: npm test
- name: download build artifact
uses: actions/download-artifact@v4
with:
name: build
path: dist
- name: test built libs
run: npm run test:dist
- name: Setup env vars
run: |
printf -v SHORT_COMMIT_MESSAGE '%q ' `git log --oneline -n 1 HEAD --format=%B`
echo "GIT_SHORT_COMMIT_MESSAGE=$SHORT_COMMIT_MESSAGE" | tee -a $GITHUB_ENV
echo "GIT_SHORT_REVISION=$(echo ${GITHUB_SHA} | cut -c1-7)" | tee -a $GITHUB_ENV
- name: Deploy visual tests to Netlify
uses: nwtgck/actions-netlify@v3
id: deploy-to-netlify
with:
publish-dir: dist/dev
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: '[${{ github.ref_name }}@${{ env.GIT_SHORT_REVISION }}] ${{ env.GIT_SHORT_COMMIT_MESSAGE }}'
enable-pull-request-comment: false
enable-commit-comment: false
enable-commit-status: false
# Use custom alias for non master branch Deploy Previews only
alias: ${{ github.ref_name != 'master' && env.RUN_NAME || '' }}
github-deployment-environment: '[${{ github.ref_name }}] visual tests'
fails-without-credentials: true
production-deploy: ${{ github.ref_name == 'master' }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ env.NETLIFY_SITE_ID }}
deploy:
runs-on: ubuntu-latest
needs: [lint, test]
if: ${{ github.ref_name == 'master' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
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@v4
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