forked from Leaflet/Leaflet
-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (186 loc) · 5.5 KB
/
main.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: CI
on: [push, pull_request]
permissions:
contents: read
env:
NODE_VERSION: 16
jobs:
setup:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019]
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
check-latest: true
cache: npm
- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: npm ci
- name: Cache setup
uses: actions/cache@v3
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}-setup
build:
needs: setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019]
steps:
- name: Restore setup
uses: actions/cache@v3
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}-setup
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Build project
run: npm run build
env:
NODE_ENV: ${{ startsWith(github.ref, 'refs/tags/v') && 'release' || '' }}
- name: Cache build
uses: actions/cache@v3
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}-build
build-release:
needs: setup
runs-on: ubuntu-20.04
steps:
- name: Restore setup
uses: actions/cache@v3
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}-setup
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Build project
run: npm run build
env:
NODE_ENV: release
- name: Cache release build
uses: actions/cache@v3
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}-build-release
lint:
needs: setup
runs-on: ubuntu-20.04
steps:
- name: Restore setup
uses: actions/cache@v3
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}-setup
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Run lint task
run: npm run lint
bundlemon:
needs: build-release
if: github.repository_owner == 'Leaflet'
runs-on: ubuntu-20.04
steps:
- name: Restore release build
uses: actions/cache@v3
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}-build-release
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Run bundlemon task
run: npm run bundlemon
env:
BUNDLEMON_PROJECT_ID: 61e0545915f6c3000980d0ed
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
test:
needs: build
runs-on: ${{ matrix.os || 'ubuntu-20.04' }}
strategy:
fail-fast: false
matrix:
include:
- browser: Chrome1280x1024
- browser: FirefoxTouch
- browser: FirefoxNoTouch
- browser: IE
os: windows-2019
- browser: IE10
os: windows-2019
steps:
- name: Restore build
uses: actions/cache@v3
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}-build
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Run tests on ${{ matrix.browser }}
run: npm test -- --browsers ${{ matrix.browser }}
publish-artifacts:
needs: build
if: github.repository_owner == 'Leaflet' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
runs-on: ubuntu-20.04
steps:
- name: Restore build
uses: actions/cache@v3
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}-build
- name: Compress artifacts
working-directory: dist
run: zip -r leaflet.zip .
- name: Publish artifacts
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --acl public-read --delete --exact-timestamps
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: dist
DEST_DIR: content/leaflet/${{ github.ref_name }}
publish-npm:
needs: build
if: github.repository_owner == 'Leaflet' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-20.04
steps:
- name: Restore build
uses: actions/cache@v3
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}-build
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://registry.npmjs.org
- name: Publish to NPM
run: |
TAG=$(echo $GITHUB_REF_NAME | grep -oP '^v\d+\.\d+\.\d+-?\K(\w+)?')
npm publish --tag ${TAG:-latest}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}