-
Notifications
You must be signed in to change notification settings - Fork 33
300 lines (253 loc) · 9.49 KB
/
release-itowns.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
name: Create Itowns Release ...
on:
push:
tags:
- 'itowns-*'
env:
LIBRARY: Itowns
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use nodejs
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install dependencies
run: npm install
- name: Install Libs Perl
run: |
sudo apt-get install perl-base libjson-perl
# FIXME commiter into develop branch ?
- name: Build & Package
run: |
cd ./build/scripts/release/
chmod 755 build-pack.sh
./build-pack.sh -i
- name: Create Zip
if: github.event_name == 'push' && contains(github.ref, '/tags/') # Only for tags !
run: |
zip --junk-paths bundles dist/itowns/*
- name: Upload JSDoc artifacts
if: github.event_name == 'push' && contains(github.ref, '/tags/') # Only for tags !
uses: actions/upload-artifact@v2
with:
name: jsdoc
path: jsdoc/itowns
- name: Upload Binary artifacts
if: github.event_name == 'push' && contains(github.ref, '/tags/') # Only for tags !
uses: actions/upload-artifact@v2
with:
name: dist
path: dist/itowns
# FIXME artifacts bundles and binary are the same !?
- name: Upload Bundles artifacts
if: github.event_name == 'push' && contains(github.ref, '/tags/') # Only for tags !
uses: actions/upload-artifact@v2
with:
name: bundles
path: bundles.zip
- name: Upload Package artifacts
uses: actions/upload-artifact@v2
with:
name: package
path: build/scripts/release/geoportal-extensions-itowns
publish_gh-pages:
if: github.event_name == 'push' && contains(github.ref, '/tags/') # Only for tags !
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: IGNF/geoportal-extensions
ref: gh-pages
- name: Get the tagname
id: get_tagname
run: echo ::set-output name=TAGNAME::$(echo ${GITHUB_REF##*/})
- name: Initialize
run: |
mkdir -p tmp/jsdoc/itowns/
mkdir -p tmp/dist/itowns/
mkdir -p ${{ steps.get_tagname.outputs.TAGNAME }}/jsdoc/
mkdir -p ${{ steps.get_tagname.outputs.TAGNAME }}/dist/
- name: Download JSDoc artifacts
uses: actions/download-artifact@v2
with:
name: jsdoc
path: tmp/jsdoc/itowns
- name: Build jsdoc
run: |
cp -r tmp/jsdoc current
cp -r tmp/jsdoc/itowns/* ${{ steps.get_tagname.outputs.TAGNAME }}/jsdoc/
- name: Download Binary artifacts
uses: actions/download-artifact@v2
with:
name: dist
path: tmp/dist/itowns
- name: Build bundles
run: |
cp -r tmp/dist current
cp -r tmp/dist/itowns/* ${{ steps.get_tagname.outputs.TAGNAME }}/dist/
- name: Link versions
run: |
rm itowns-latest
ln -s ${{ steps.get_tagname.outputs.TAGNAME }} itowns-latest
- name: Clean and publish
run: |
rm -rf tmp/
git config user.name github-actions
git config user.email [email protected]
git add -A
git commit -m "update jsdoc / bundles to release ${{ env.LIBRARY }} : ${{ steps.get_tagname.outputs.TAGNAME }}"
git push
create_release:
if: github.event_name == 'push' && contains(github.ref, '/tags/') # Only for tags !
needs: build
runs-on: ubuntu-latest
steps:
- name: Install Perl
run: |
sudo apt-get install perl-base libjson-perl
- name: Checkout # checkout repository to get DRAFT_CHANGELOG.md !
uses: actions/checkout@v2
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::$(echo v${GITHUB_REF##*/} | cut -d - -f 2-)
- name: Get Package.json value
id: get_package_value
run: |
echo ::set-output name=VERSION::$(cat package.json | perl -MJSON -0ne 'my $DS = decode_json $_; my $field = 'itownsExtVersion'; print $DS->{$field};')
echo ::set-output name=DATE::$(cat package.json | perl -MJSON -0ne 'my $DS = decode_json $_; my $field = 'date'; print $DS->{$field};' | sed -e 's/\//\\\//g')
- name: Create ChangeLog
run: | # cf. http://fahdshariff.blogspot.com/2012/12/sed-mutli-line-replacement-between-two.html
cat DRAFT_CHANGELOG.md | perl -ne '(/# Extension Geoportail Itowns/../---/) && print' > DRAFT_CHANGELOG_${{ env.LIBRARY }}.md
sed -i 's/__VERSION__/${{ steps.get_package_value.outputs.VERSION }}/g' DRAFT_CHANGELOG_${{ env.LIBRARY }}.md
sed -i 's/__DATE__/${{ steps.get_package_value.outputs.DATE }}/g' DRAFT_CHANGELOG_${{ env.LIBRARY }}.md
- name: Upload ChangeLog artifacts
if: github.event_name == 'push' && contains(github.ref, '/tags/') # Only for tags !
uses: actions/upload-artifact@v2
with:
name: changelog
path: DRAFT_CHANGELOG_${{ env.LIBRARY }}.md
- 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_${{ env.LIBRARY }}.md
draft: false
prerelease: false
- name: Download bundles artifacts
uses: actions/download-artifact@v2
with:
name: bundles
- name: 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: GpPlugin${{ env.LIBRARY }}-${{ steps.get_version.outputs.VERSION }}.zip
asset_content_type: application/zip
publish_package:
if: github.event_name == 'push' && contains(github.ref, '/tags/') # Only for tags !
needs: create_release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Initialize
run: |
mkdir -p package
- name: Use nodejs
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Use registry npm
uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
# scope: '@ignf-geoportal'
- name: Download Package artifacts
uses: actions/download-artifact@v2
with:
name: package
path: package
- name: Publish on npm
run: |
cd ./package
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_GEOPORTAL_TOKEN }}
changelog:
if: github.event_name == 'push' && contains(github.ref, '/tags/') # Only for tags !
needs: [create_release, publish_package]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: IGNF/geoportal-extensions
ref: develop
token: ${{ secrets.ADMIN_GEOPORTAL_TOKEN }}
- name: Download ChangeLog artifacts
uses: actions/download-artifact@v2
with:
name: changelog
- name: Install Libs
run: |
npm install markdown-toc
# cf. https://www.grymoire.com/Unix/Sed.html
# cf. http://fahdshariff.blogspot.com/2012/12/sed-mutli-line-replacement-between-two.html
- name: Reset draft changelog
run: |
sed -i -e '/# Extension Geoportail Itowns/{:a; N; /---/!ba; r .github/CHANGELOG_TEMPLATE.md' -e 'd;}' DRAFT_CHANGELOG.md
sed -i '0,/__UP_LIBRARY__/s/__UP_LIBRARY__/Itowns/' DRAFT_CHANGELOG.md
sed -i '0,/__LO_LIBRARY__/s/__LO_LIBRARY__/itowns/' DRAFT_CHANGELOG.md
- name: Archive changelog
run: |
cat DRAFT_CHANGELOG_${{ env.LIBRARY }}.md >> doc/CHANGELOG-itowns.md
./node_modules/.bin/markdown-toc -i doc/CHANGELOG-itowns.md
- name: Clean and publish
run: |
rm DRAFT_CHANGELOG_${{ env.LIBRARY }}.md
git config user.name github-actions
git config user.email [email protected]
git add -A
git commit -m "update CHANGELOG for ${{ env.LIBRARY }}"
git push --force
# TODO not yet implemented !
rollback:
if: false # always skip job !
# if: failure()
# if: github.event_name == 'push' && contains(github.ref, '/tags/') # Only for tags !
needs: [create_release, publish_package, changelog]
runs-on: ubuntu-latest
steps:
- name: Get the tagname
id: get_tagname
run: echo ::set-output name=TAGNAME::$(echo ${GITHUB_REF##*/})
- name: Rollback jsdoc (gh-pages)
run: |
echo "not yet implemented !"
- name: Rollback changelog (develop)
run: |
echo "not yet implemented !"
- name: Rollback Release
if: job.create_release.steps.create_release.outputs.id != ''
uses: author/action-rollback@stable
with:
# Using a known release ID
id: ${{ job.create_release.steps.create_release.id }}
# Using a tag name
tag: ${{ steps.get_tagname.outputs.TAGNAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}