-
Notifications
You must be signed in to change notification settings - Fork 1
330 lines (283 loc) · 9.15 KB
/
release.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
324
325
326
327
328
329
name: Creation de la release
on:
push:
tags:
- '*'
env:
MODULE_NAME: modules
BUNDLE_NAME: bundle
PACKAGE_NAME: package
jobs:
# - checkout master ou main
# - build des binaires
# - build package des sources
# - build jsdoc
# - zip & upload artifacts :
# - jsdoc
# - dist
# - package.zip
# - modules.zip
# - bundle.zip
build: # Only for tags !
if: github.event_name == 'push' && contains(github.ref, '/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use nodejs
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install dependencies
run: npm install
- name: Build bundles & modules
run: npm run build
- name: Build package
run: npm run publish -- --version=${{ github.ref_name }}
- name: Create Zip Modules
run: |
zip --junk-paths ${{env.MODULE_NAME}} dist/${{env.MODULE_NAME}}/*
- name: Create Zip Bundle
run: |
zip --junk-paths ${{env.BUNDLE_NAME}} dist/${{env.BUNDLE_NAME}}/*
- name: Create Zip Package
run: |
cd dist/package/
zip -r ../../${{env.PACKAGE_NAME}}.zip * -x "*.tgz"
- name: Upload JSDoc artifacts
uses: actions/upload-artifact@v4
with:
name: jsdoc
path: jsdoc
- name: Upload Binaries artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- name: Upload Package artifacts
uses: actions/upload-artifact@v4
with:
name: package
path: ${{env.PACKAGE_NAME}}.zip
- name: Upload Bundle artifacts
uses: actions/upload-artifact@v4
with:
name: bundle
path: ${{env.BUNDLE_NAME}}.zip
- name: Upload Modules artifacts
uses: actions/upload-artifact@v4
with:
name: modules
path: ${{env.MODULE_NAME}}.zip
# - checkout gh-pages
# - download des artifacts : build & jsdoc
# - commit & push
# warning: ceci risque de declencher un deploy automatique !
# > CUSTOMISER LE DEPLOY ET METTRE UNE CONDITION D'EXECUTION !
deploy: # Only for tags !
if: github.event_name == 'push' && contains(github.ref, '/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: gh-pages
- name: Download Binaries artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Download JSDoc artifacts
uses: actions/download-artifact@v4
with:
name: jsdoc
path: jsdoc
- name: Build 404
run: |
cp index.html 404.html
- name: Publish
run: |
git config user.name github-actions
git config user.email [email protected]
git add -A
git commit -m "[github-actions] deploy project gh-pages"
git push
# - checkout master or main
# - get date from package.json
# - get version from package.json
# - create changelog, then upload artifact changelog (also use by publish npm)
# - create release github
# - download binaries (from build)
# - upload artifacts for release github assets :
# - bundle.zip
# - modules.zip
# - package.zip
release: # Only for tags !
if: github.event_name == 'push' && contains(github.ref, '/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Package info
id: package
uses: idev-coder/[email protected]
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Create ChangeLog
run: |
echo "version package internal : ${{ steps.package.outputs.version }}"
sed -i 's/__VERSION__/${{ github.ref_name }}/g' DRAFT_CHANGELOG.md
sed -i 's/__DATE__/${{ steps.date.outputs.date }}/g' DRAFT_CHANGELOG.md
- name: Upload ChangeLog artifacts
uses: actions/upload-artifact@v4
with:
name: changelog
path: DRAFT_CHANGELOG.md
- name: Download Bundle artifacts
uses: actions/download-artifact@v4
with:
name: ${{env.BUNDLE_NAME}}
path: ./
- name: Download Module artifacts
uses: actions/download-artifact@v4
with:
name: ${{env.MODULE_NAME}}
path: ./
- name: Download Package artifacts
uses: actions/download-artifact@v4
with:
name: ${{env.PACKAGE_NAME}}
path: ./
- name: Create Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: DRAFT_CHANGELOG.md
draft: false
prerelease: false
- name: Upload Release Asset Bundles
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{env.BUNDLE_NAME}}.zip
asset_name: ${{env.BUNDLE_NAME}}.zip
asset_content_type: application/zip
- name: Upload Release Asset Modules
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{env.MODULE_NAME}}.zip
asset_name: ${{env.MODULE_NAME}}.zip
asset_content_type: application/zip
- name: Upload Release Asset Package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{env.PACKAGE_NAME}}.zip
asset_name: ${{env.PACKAGE_NAME}}.zip
asset_content_type: application/zip
# - checkout master or main
# - download changelog (from release)
# - download package (from build)
# - then simply publish repo
publish: # Only for tags !
if: github.event_name == 'push' && contains(github.ref, '/tags/')
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Binaries artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Download ChangeLog artifacts
uses: actions/download-artifact@v4
with:
name: changelog
path: ./dist/package/CHANGELOG.md
- name: Use registry npm
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Publish on npm
run: |
cd ./dist/package
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_GEOPORTAL_TOKEN }}
# - checkout master or main
# - download changelog (from release)
# - archive changelog
# - update toc
# - reset draft changelog
# - commit & push
# warning: ceci risque de relancer un job de build et deploy du build.yaml !
# on positionne une condition sur le message du commit afin d'éviter de reexecuter les jobs
changelog: # Only for tags !
if: github.event_name == 'push' && contains(github.ref, '/tags/')
needs: [release, publish]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: main
token: ${{ secrets.ADMIN_GEOPORTAL_TOKEN }}
- name: Download ChangeLog artifacts
uses: actions/download-artifact@v4
with:
name: changelog
- name: Install Libs
run: |
npm install markdown-toc
- name: Archive changelog
run: |
cat DRAFT_CHANGELOG.md >> CHANGELOG.md
./node_modules/.bin/markdown-toc -i CHANGELOG.md
- name: Reset draft changelog
run: |
cp .github/CHANGELOG_TEMPLATE.md DRAFT_CHANGELOG.md
- name: Commit and push
run: |
git config user.name github-actions
git config user.email [email protected]
git add -A
git commit -m "[github-actions] update CHANGELOG"
git push --force
# not yet implemented !
# - checkout master or main
# - simply update package.json with new version
# - commit & push
samples:
if: false
runs-on: ubuntu-latest
steps:
- name: ras
run: |
echo "not yet implemented !"
# not yet implemented !
rollback:
if: false
runs-on: ubuntu-latest
steps:
- name: ras
run: |
echo "not yet implemented !"