-
Notifications
You must be signed in to change notification settings - Fork 0
385 lines (370 loc) · 12.6 KB
/
build.yaml
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
name: Build, QA, release
on:
workflow_call:
secrets:
USER_GITHUB_TOKEN:
required: true
SSH_KEY:
required: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
first-run:
name: Set up environment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Do first-run script if necessary
run: make .init.stamp
if: github.repository != 'notofonts/noto-project-template'
- uses: stefanzweifel/git-auto-commit-action@v4
name: First-run setup
if: github.repository != 'notofonts/noto-project-template'
with:
file_pattern: .init.stamp README.md requirements.txt OFL.txt
commit_message: "Personalize for this repo"
build-ttf:
runs-on: ubuntu-latest
name: Build main TTFs
needs: first-run
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: actions/cache@v2
with:
path: ./subset-files
key: subsets
- name: Build fonts
run: make build
- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: fontbuild-ttf
path: fonts
build-otf:
runs-on: ubuntu-latest
name: Build OTFs (release only)
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: first-run
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: actions/cache@v2
with:
path: ./subset-files
key: subsets
- name: Install dependencies
run: make venv
- name: Build fonts
run: |
(for config in sources/config*.yaml; do . venv/bin/activate; python3 -m notobuilder --otfs $config || ! break; done) && touch build.stamp
- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: fontbuild-otf
path: fonts
build-googlefonts:
name: Build Google Fonts instances
needs: first-run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: actions/cache@v2
with:
path: ./subset-files
key: subsets
- name: Install dependencies
run: make venv
- name: Build fonts
run: |
(for config in sources/config*.yaml; do . venv/bin/activate; python3 -m notobuilder --googlefonts $config || ! break; done) && touch build.stamp
- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: fontbuild-googlefonts
path: fonts
fontbakery-googlefonts:
name: Check with Fontbakery
runs-on: ubuntu-latest
needs: build-googlefonts
steps:
- uses: actions/checkout@v2
- name: Download font build zip
uses: actions/download-artifact@v3
with:
name: fontbuild-googlefonts
path: fonts
- name: Test
run: find .
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Make directories
run: mkdir -p out/fontbakery out/badges
continue-on-error: true
- name: Install dependencies
run: make venv
- name: Check with fontbakery
run: |
for family_path in fonts/*; do
family=`basename $family_path`
. venv/bin/activate ; fontbakery check-googlefonts --configuration fontbakery.yml -l WARN --succinct --badges out/badges --html out/fontbakery/googlefonts-$family-report.html --ghmarkdown out/fontbakery/googlefonts-$family-report.md $family_path/googlefonts/*ttf/*ttf || true
done
continue-on-error: true
- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: fontbakery-googlefonts
path: out
proof:
name: Create proof documents
runs-on: ubuntu-latest
needs: build-ttf
steps:
- uses: actions/checkout@v2
- name: Download font build zip
uses: actions/download-artifact@v3
with:
name: fontbuild-ttf
path: fonts
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: make venv
- name: Make proof
run: |
. venv/bin/activate; mkdir -p out/ out/proof; gftools gen-html proof $(find fonts/*/unhinted/ttf -type f) -o out/proof
- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: proof
path: out
regression:
name: Regression test
runs-on: ubuntu-latest
needs: build-ttf
steps:
- uses: actions/checkout@v2
- name: Download font build zip
uses: actions/download-artifact@v3
with:
name: fontbuild-ttf
path: fonts
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: make venv
- name: Regression test
run: . venv/bin/activate; python3 -m notoqa.regression
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: regression
path: out
report:
name: Rebuild website
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- fontbakery-googlefonts
- proof
- regression
steps:
- uses: actions/checkout@v2
- name: Download font zip
uses: actions/download-artifact@v3
with:
name: fontbuild-ttf
path: fonts
- name: Download font zip
uses: actions/download-artifact@v3
with:
name: fontbuild-googlefonts
path: fonts
- name: Download font zip
uses: actions/download-artifact@v3
with:
name: fontbuild-otf
path: fonts
continue-on-error: true
- name: Download fontbakery-googlefonts zip
uses: actions/download-artifact@v3
with:
name: fontbakery-googlefonts
path: out
- name: Download proof zip
uses: actions/download-artifact@v3
with:
name: proof
path: out
continue-on-error: true
- name: Download regression test zip
uses: actions/download-artifact@v3
with:
name: regression
path: out
continue-on-error: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: make venv
- name: Rebuild website
run: . venv/bin/activate; python3 scripts/template.py
- name: Copy fonts to gh-pages dir
run: cp -r fonts out
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
- name: gen zip file name
id: zip-name
shell: bash
# Set the archive name to repo name + "-assets" e.g "MavenPro-assets"
run: echo "ZIP_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')-fonts" >> $GITHUB_ENV
- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.ZIP_NAME }}
path: out
create_release:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs:
- build-ttf
- build-otf
- build-googlefonts
runs-on: ubuntu-latest
name: Create release
outputs:
url: ${{ steps.upload.outputs.browser_download_url }}
config_file: ${{ steps.check_tag.outputs.config_file }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: make venv
- run: pip3 install 'git+https://github.com/googlefonts/gftools@noto#egg=gftools'
- name: Download font zip
uses: actions/download-artifact@v3
with:
name: fontbuild-ttf
path: fonts
- name: Download font zip
uses: actions/download-artifact@v3
with:
name: fontbuild-otf
path: fonts
- name: Download font zip
uses: actions/download-artifact@v3
with:
name: fontbuild-googlefonts
path: fonts
- name: Check for appropriate tag
id: check_tag
run: . venv/bin/activate; python3 scripts/check-tag.py ${{ github.ref_name }}
- name: Create release
id: release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
- name: Tell user about release
run: echo '::warning file=sources/config.yaml,title=A new release ${{ github.ref_name }} has been created'
- name: Find a DESCRIPTION.en_us.html
run: cp documentation/${{ steps.check_tag.outputs.family}}.html DESCRIPTION.en_us.html
continue-on-error: true
- name: Find an ARTICLE.en_us.html
run: cp documentation/${{ steps.check_tag.outputs.family}}.article.html ARTICLE.en_us.html
continue-on-error: true
- name: Create release bundle
run: cd fonts; zip -x requirements.txt -r ../${{ github.ref_name }}.zip ${{ steps.check_tag.outputs.family}}/ ../*.txt ../DESCRIPTION.en_us.html ../ARTICLE.en_us.html
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
id: upload
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ github.ref_name }}.zip
asset_name: ${{ github.ref_name }}.zip
tag: ${{ github.ref_name }}
overwrite: true
body: "Production ready fonts"
google_fonts_pr:
runs-on: ubuntu-latest
environment: googlefonts
name: Submit PR to Google Fonts
needs: create_release
if: needs.create_release.outputs.url
steps:
- name: Check SSH_KEY is set
run: |
if [[ "${{ secrets.SSH_KEY }}" == "" ]];
then
echo "::error file=sources/config.yaml,title=SSH_KEY was not set in repository secrets::Generate an SSH key (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key), add the public key to your GitHub account (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) and add the private key to an environment secret called SSH_KEY in an environment called 'googlefonts' by going to $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/settings/secrets/actions";
exit 1
fi
- name: Check USER_GITHUB_TOKEN is set
run: |
if [[ "${{ secrets.USER_GITHUB_TOKEN }}" == "" ]];
then
echo "::error file=sources/config.yaml,title=USER_GITHUB_TOKEN was not set in repository secrets::Generate a personal access token with a repo scope by visiting https://github.com/settings/tokens/new and add it to an environment secret called USER_GITHUB_TOKEN in an environment called 'googlefonts' by going to $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/settings/secrets/actions";
exit 1
fi
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: pip3 install 'git+https://github.com/googlefonts/gftools#egg=gftools'
- name: Generate / update upstream.yaml
run: python3 -m gftools.actions.updateupstream ${{ needs.create_release.outputs.url }} --config "${{ needs.create_release.outputs.config_file }}"
- uses: actions/checkout@v2
name: Check out Google Fonts repository
with:
fetch-depth: 0
repository: google/fonts
path: "googlefonts"
ssh-key: ${{ secrets.SSH_KEY }}
- name: Set git username and email
run: |
git config --global user.email "${GH_USERNAME}@users.noreply.github.com"
git config --global user.name "${GH_USERNAME}"
env:
GH_USERNAME: ${{ github.actor }}
- name: Do SSH magic
run: cd googlefonts; git remote add googlefonts git@github.com:google/fonts.git ; cd ..
- name: Test fetch
run: cd googlefonts; git fetch googlefonts main ; cd ..
- name: Run the packager
run: gftools packager upstream.yaml googlefonts -p -y
env:
GH_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }}