-
Notifications
You must be signed in to change notification settings - Fork 303
323 lines (270 loc) · 9.57 KB
/
integration.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
name: integration
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch: {}
jobs:
# Build bundle, doc and check linter
build:
name: Build bundle, check Linter and generate documentation
runs-on: ubuntu-latest
steps:
# Use specific Node.js version
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
# Install packages
- name: Install packages
run: npm ci
# Prepare before build
- name: Prepare
run: npm run prepare
# Check linter
- name: Linter
run: npm run lint -- --max-warnings=0
# Build bundle
- name: Build bundle
if: ${{ success() }}
run: npm run build
# Build documentation
- name: Build documentation
if: ${{ success() && github.ref == 'refs/heads/master' }}
run: npm run doc -- -d buildDocs
# Prepare archive for deploying
- name: Archive production artifacts
if: ${{ success() }}
uses: actions/upload-artifact@v4
with:
name: dist-itowns
path: |
dist/**/*.js
examples
buildDocs
# Check commits messages
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Check Commit Type
uses: gsactions/commit-message-checker@v2
with:
pattern: '^(feat|feature|features|fix|perf|revert|doc|docs|refactor|refacto|refactoring|test|tests|chore|rename|workflow|example|examples|others)(\([\w\-\.]+\))?: ([\w ])+([\s\S]*)|release v\d+.\d+.\d+'
error: 'One or several of the pushed commits do not match the conventional commit convention. Please read CONTRIBUTING.md.'
excludeDescription: true
excludeTitle: true
checkAllCommitMessages: true
accessToken: ${{ secrets.GITHUB_TOKEN }}
# Unit and coverage tests
unit-and-coverage-tests:
name: Unit and coverage tests
needs: build
runs-on: ubuntu-latest
steps:
# Use specific Node.js version
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
# Install packages
- name: Install packages
run: npm ci
- name: Run unit tests
run: npm run test-with-coverage_lcov
# Code coverage
- name: Coveralls
if: ${{ success() }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Functional tests
functional-tests:
name: Functional tests
needs: build
runs-on: ubuntu-latest
steps:
# Use specific Node.js version
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
# Install packages
- name: Install packages
run: npm ci
# Download artifact from build
- name: Download itowns bundle
uses: actions/download-artifact@v4
with:
name: dist-itowns
- name: Run functional tests
run: npm run test-functional
# Publish NPM package
publish:
name: Publish NPM package
if: ${{ github.ref == 'refs/heads/master' }}
needs: [unit-and-coverage-tests, functional-tests, check-commit-message]
runs-on: ubuntu-latest
permissions:
# id-token: write permission is required for npm provenance:
# https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions
id-token: write
# contents: write is required for git push
contents: write
steps:
- uses: actions/checkout@v4
with:
# fetch all branches
fetch-depth: 0
# Configure git user for later command induced commits
- uses: fregante/setup-git-user@v1
- uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run prepare
- name: publish itowns@latest npm package
if: ${{ startsWith(github.event.head_commit.message, 'release v' ) }}
run: npm run publish-latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: publish itowns@next npm package (following a release)
if: ${{ startsWith(github.event.head_commit.message, 'release v' ) }}
run: |
git checkout next
git reset --hard master
npm run publish-next
git push -f
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: publish itowns@next npm package
if: ${{ !startsWith(github.event.head_commit.message, 'release v' ) }}
run: |
git checkout next
git merge master
npm run publish-next
git push
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Deploy on itowns.github.io website
deploy:
name: Deploy to itowns.github.io
if: ${{ github.ref == 'refs/heads/master' }}
needs: [unit-and-coverage-tests, functional-tests, check-commit-message]
runs-on: ubuntu-latest
steps:
# Download artifact from build
- name: Download itowns bundle
uses: actions/download-artifact@v4
with:
name: dist-itowns
# Copy files for deployment
- name: build site
run: |
mkdir -p itowns/dist
mkdir -p itowns/potree/build
mkdir -p itowns/potree/libs
cp -R dist/*.js itowns/dist/
cp -R examples itowns/
cp -R buildDocs itowns/docs
# When deploying a release, we copy itowns bundles in dev folder to be published on
# iTowns/itowns.github.io. This is because we can't publish both a release version
# (in itowns/ folder) and a @next version (in itowns/dev folder) at the same time.
- name: add dev bundle if release
if: ${{ startsWith(github.event.head_commit.message, 'release v' ) }}
run: |
cp -R itowns dev
mv dev itowns/
# Deploy to itowns.github.io LTS
- name: Deploy LTS to itowns.github.io
if: ${{ startsWith(github.event.head_commit.message, 'release v' ) }}
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: iTowns/itowns.github.io
publish_dir: ./itowns
destination_dir: ./itowns
publish_branch: master
enable_jekyll: true
# Deploy to itowns.github.io Dev
- name: Deploy Dev to itowns.github.io
# Prevent deploying @next version when a release is done. Doing so would cause an issue,
# since it is not possible to use the same deploy key to simultaneously deploy two different
# folders on iTowns/itowns.github.io (the release bundle on previous step and this one.
if: ${{ !startsWith(github.event.head_commit.message, 'release v' ) }}
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: iTowns/itowns.github.io
publish_dir: ./itowns
destination_dir: ./itowns/dev
publish_branch: master
enable_jekyll: true
# Create GitHub release
release:
name: Release GitHub
if: ${{ github.ref == 'refs/heads/master' && startsWith( github.event.head_commit.message, 'release v' ) }}
needs: [unit-and-coverage-tests, functional-tests, check-commit-message]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Message commit
run: echo "is RELEASE => ${{ github.event.head_commit.message }} !!"
- name: Get release version
run: echo ::set-output name=VERSION::$(node -e "console.log(require('./package.json').version);")
id: npm_pack
- name: itowns Version
run: echo "The iTowns release version is ${{ steps.npm_pack.outputs.VERSION }}"
# Add tag
- name: Tag branch
run: |
git config user.name github-actions
git config user.email [email protected]
git tag -a v${{ steps.npm_pack.outputs.VERSION }} -m "release v${{ steps.npm_pack.outputs.VERSION }}."
git push --follow-tags
# Download artifact from build
- name: Download itowns bundle
uses: actions/download-artifact@v4
with:
name: dist-itowns
# Create release
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.npm_pack.outputs.VERSION }}
release_name: Release ${{ steps.npm_pack.outputs.VERSION }}
body_path: ./changelog.md
draft: false
prerelease: false
# Zip assets into bundle
- name: Zip assets
run: |
zip --junk-paths bundles ./dist/*.js ./dist/*.map
# Upload release asset
- name: upload release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bundles.zip
asset_name: bundles.zip
asset_content_type: application/zip