Skip to content

Commit f90b12b

Browse files
authored
Merge pull request #892 from Finii/improve-ci
Improve CI process for releases With merge request to have the complete overhaul in a closed context.
2 parents d08f993 + 1d6aa17 commit f90b12b

10 files changed

+189
-155
lines changed

Diff for: .dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Keep this in line with .github/workflows/docker-release.yml
12
**
23
!src/glyphs
34
!font-patcher

Diff for: .github/workflows/docker-release.yml

+3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ on:
55
branches:
66
- master
77
paths:
8+
# Keep this in line with .dockerignore
89
- bin/scripts/docker-entrypoint.sh
10+
- bin/scripts/name_parser/Fontname*.py
911
- src/glyphs/**
1012
- .dockerignore
1113
- Dockerfile
@@ -15,6 +17,7 @@ jobs:
1517
publish-image:
1618
name: Publish image
1719
runs-on: ubuntu-latest
20+
if: ${{ secrets.DOCKER_USER }}
1821
steps:
1922
- uses: actions/checkout@v3
2023
- name: Build image

Diff for: .github/workflows/release.yml

+151-41
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ on:
1616
- 'install.ps1'
1717
- 'install.sh'
1818
- 'LICENSE'
19-
- 'package**'
2019

2120
# Allows you to run this workflow manually from the Actions tab
2221
workflow_dispatch:
@@ -27,18 +26,72 @@ jobs:
2726
runs-on: ubuntu-latest
2827

2928
steps:
30-
- uses: actions/checkout@v3
31-
-
29+
# Faster version instead of - uses: actions/checkout@v3
30+
- uses: Bhacaz/checkout-files@v2
31+
with:
32+
files: package.json bin/scripts/get-font-names-from-json.sh bin/scripts/lib/fonts.json
33+
branch: ${{ github.head_ref || github.ref_name }}
34+
35+
- name: Determine font matrix
3236
id: set-matrix
3337
run: |
3438
cd -- $GITHUB_WORKSPACE/bin/scripts/
39+
chmod u+x get-font-names-from-json.sh
3540
fontNames=$(./get-font-names-from-json.sh)
3641
echo "${fontNames}"
3742
echo "::set-output name=matrix::${fontNames}"
3843
echo ${{ steps.set-matrix.outputs.matrix }}
3944
45+
- name: Fetch release version
46+
id: rel_ver
47+
run: |
48+
cd -- "$GITHUB_WORKSPACE"
49+
echo "Contents of package.json:"
50+
cat package.json
51+
RELEASE_VERSION=$(jq '.version' package.json | sed 's/[ ",]//g')
52+
echo "::set-output name=val::$RELEASE_VERSION"
53+
54+
- name: Determine candidate status
55+
id: rel_can
56+
run: |
57+
[[ "${{ steps.rel_ver.outputs.val }}" == *"-RC"* ]] && echo "::set-output name=val::true" || echo "::set-output name=val::false"
58+
59+
- name: Determine new release or re-release
60+
# If the tag exists it is obviously a re-release
61+
62+
# This would need a complete checkout, that we want to avoid
63+
# uses: mukunku/[email protected]
64+
# with:
65+
# tag: "v${{ steps.rel_ver.outputs.val }}"
66+
# env:
67+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
id: rel_pre_existing
69+
run: |
70+
curl -v "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/tags" | jq '.[].name' | grep '^"v${{ steps.rel_ver.outputs.val }}"$' \
71+
&& echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
72+
echo "Tag exists: ${{ steps.rel_pre_existing.outputs.exists }}"
73+
74+
- name: Upload release only on first trigger for release and always on release candidate
75+
id: upload
76+
# Upload release when:
77+
# * This is a new (previously untagged) release
78+
# * This is a release candidate
79+
run: |
80+
[[ "${{ steps.rel_can.outputs.val }}" == "true" || "${{ steps.rel_pre_existing.outputs.exists }}" == "false" ]] && echo "::set-output name=val::true" || echo "::set-output name=val::false"
81+
82+
- name: Show outputs
83+
run: |
84+
echo "rel_version: ${{ steps.rel_ver.outputs.val }}"
85+
echo "rel_candidate: ${{ steps.rel_can.outputs.val }}"
86+
echo "rel_pre_existing: ${{ steps.rel_pre_existing.outputs.exists }}"
87+
echo "rel_upload: ${{ steps.upload.outputs.val }}"
88+
4089
outputs:
4190
matrix: ${{ steps.set-matrix.outputs.matrix }}
91+
rel_version: ${{ steps.rel_ver.outputs.val }}
92+
rel_candidate: ${{ steps.rel_can.outputs.val }}
93+
rel_pre_existing: ${{ steps.rel_pre_existing.outputs.exists }}
94+
rel_upload: ${{ steps.upload.outputs.val }}
4295

4396
# Workflow to build and install dependencies
4497
build:
@@ -50,6 +103,8 @@ jobs:
50103
env:
51104
GITHUB_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
52105
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
RELEASE_VERSION: ${{ needs.setup-fonts-matrix.outputs.rel_version }}
107+
RELEASE_CANDIDATE: ${{ needs.setup-fonts-matrix.outputs.rel_candidate }}
53108

54109
strategy:
55110
matrix:
@@ -58,17 +113,11 @@ jobs:
58113
steps:
59114
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
60115
- uses: actions/checkout@v3
61-
- name: Set release variables
116+
- name: Check release variables
62117
run: |
63-
cd -- "$GITHUB_WORKSPACE"
64-
cat package.json
65-
RELEASE_TAG_VERSION=$(cat package.json \
66-
| grep version \
67-
| head -1 \
68-
| awk -F: '{ print $2 }' \
69-
| sed 's/[",]//g')
70-
echo "RELEASE_TAG_VERSION=$RELEASE_TAG_VERSION" >> $GITHUB_ENV
71-
[[ "$RELEASE_TAG_VERSION" == *"-RC"* ]] && echo "RELEASE_CANDIDATE=true" || echo "RELEASE_CANDIDATE=false" >> $GITHUB_ENV
118+
echo "$RELEASE_VERSION"
119+
echo "Candidate: $RELEASE_CANDIDATE"
120+
echo "Publish/refresh release: ${{ needs.setup-fonts-matrix.outputs.rel_upload }}"
72121
73122
# Install and setup Dependencies
74123
# @TODO cache the next 4 steps with actions/cache or upload
@@ -92,11 +141,15 @@ jobs:
92141
echo Try appimage with path
93142
fontforge --version
94143
144+
# It is unclear what this has been needed for
95145
- name: Setup additional dependencies
146+
if: false
96147
run: |
97148
pip install fonttools --quiet
98149
150+
# It is unclear what this has been needed for
99151
- name: Build FreeType from source
152+
if: false
100153
run: |
101154
wget http://downloads.sourceforge.net/project/freetype/freetype2/2.7/freetype-2.7.tar.gz --quiet
102155
tar -zxf freetype-2.7.tar.gz
@@ -105,7 +158,9 @@ jobs:
105158
make --quiet
106159
sudo make install --quiet
107160
161+
# It is unclear what this has been needed for
108162
- name: Build Harfbuzz from source
163+
if: false
109164
run: |
110165
wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.3.4.tar.bz2 --quiet
111166
tar -xjf harfbuzz-1.3.4.tar.bz2
@@ -119,12 +174,10 @@ jobs:
119174
fontforge --version
120175
fontforge --version 2>&1 | grep libfontforge | awk '{print $NF}'
121176
122-
- name: Bump version for source files once
123-
# @todo fixme - put in a separate job with the release env setup and output the release info
124-
if: ${{ matrix.font == '3270' }}
177+
- name: Bump version for source files
125178
run: |
126179
cd -- "$GITHUB_WORKSPACE/bin/scripts"
127-
./version-bump.sh "$RELEASE_TAG_VERSION"
180+
./version-bump.sh "$RELEASE_VERSION"
128181
129182
- name: Standardize the readme files
130183
run: |
@@ -137,17 +190,25 @@ jobs:
137190
fontforge --script `pwd`/../../font-patcher --version
138191
./gotta-patch-em-all-font-patcher\!.sh "/${{ matrix.font }}"
139192
140-
- name: Generate fontconfig and casks
193+
- name: Archive font package zip files
141194
run: |
142195
cd -- "$GITHUB_WORKSPACE/bin/scripts"
143-
./generate-fontconfig.sh
144-
./generate-casks.sh "${{ matrix.font }}"
196+
./archive-fonts.sh "${{ matrix.font }}"
145197
146-
- name: Archive font package zip files and upload for release
198+
- name: Generate cask
199+
# The casks are not used at the moment, but probably Ryan
200+
# wanted to push them out somewhere
147201
run: |
148202
cd -- "$GITHUB_WORKSPACE/bin/scripts"
149-
./archive-fonts.sh "${{ matrix.font }}"
150-
GITHUB_TOKEN=$GITHUB_TOKEN PRERELEASE=$RELEASE_CANDIDATE ./upload-archives.sh $RELEASE_TAG_VERSION "${{ matrix.font }}"
203+
./generate-casks.sh "${{ matrix.font }}"
204+
205+
- name: Upload zip file archive for release
206+
uses: softprops/[email protected]
207+
if: needs.setup-fonts-matrix.outputs.rel_upload == 'true'
208+
with:
209+
prerelease: ${{ env.RELEASE_CANDIDATE != 'false' }}
210+
tag_name: "v${{ env.RELEASE_VERSION }}"
211+
files: archives/*
151212

152213
- name: Upload patched fonts as artifacts
153214
uses: actions/upload-artifact@v2
@@ -159,42 +220,50 @@ jobs:
159220
patched-fonts/${{ matrix.font }}
160221
LICENSE
161222
223+
- name: Upload casks as artifacts
224+
uses: actions/upload-artifact@v2
225+
with:
226+
name: casks
227+
# adding multiple paths (i.e. LICENSE) is a workaround to get a least common ancestor
228+
# of the root directory for artifact path purposes
229+
path: |
230+
casks/${{ matrix.font }}
231+
LICENSE
232+
162233
release-font-patcher:
163234
name: Archive font patcher and add to release
164-
needs: build
235+
needs: [ setup-fonts-matrix, build ]
165236

166237
env:
167238
GITHUB_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
168239
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
240+
RELEASE_VERSION: ${{ needs.setup-fonts-matrix.outputs.rel_version }}
241+
RELEASE_CANDIDATE: ${{ needs.setup-fonts-matrix.outputs.rel_candidate }}
169242

170243
runs-on: ubuntu-latest
171244
steps:
172245
- uses: actions/checkout@v3
173-
- name: Set release variables
246+
- name: Bump version for source files
174247
run: |
175-
cd -- "$GITHUB_WORKSPACE"
176-
cat package.json
177-
RELEASE_TAG_VERSION=$(cat package.json \
178-
| grep version \
179-
| head -1 \
180-
| awk -F: '{ print $2 }' \
181-
| sed 's/[",]//g')
182-
echo "RELEASE_TAG_VERSION=$RELEASE_TAG_VERSION" >> $GITHUB_ENV
183-
[[ "$RELEASE_TAG_VERSION" == *"-RC"* ]] && echo "RELEASE_CANDIDATE=true" || echo "RELEASE_CANDIDATE=false" >> $GITHUB_ENV
248+
cd -- "$GITHUB_WORKSPACE/bin/scripts"
249+
./version-bump.sh "$RELEASE_VERSION"
184250
185251
- name: Archive font-patcher script for release
186252
run: |
187253
cd -- "$GITHUB_WORKSPACE/bin/scripts"
188254
./archive-font-patcher.sh
189255
190-
- name: Archive font package zip files and upload for release
191-
run: |
192-
cd -- "$GITHUB_WORKSPACE/bin/scripts"
193-
GITHUB_TOKEN=$GITHUB_TOKEN PRERELEASE=$RELEASE_CANDIDATE ./upload-archives.sh $RELEASE_TAG_VERSION "FontPatcher"
256+
- name: Upload font-patcher archive for release
257+
uses: softprops/[email protected]
258+
if: needs.setup-fonts-matrix.outputs.rel_upload == 'true'
259+
with:
260+
prerelease: ${{ env.RELEASE_CANDIDATE != 'false' }}
261+
tag_name: "v${{ env.RELEASE_VERSION }}"
262+
files: archives/*
194263

195264
commit:
196265
name: Commit and push patched fonts to the repo
197-
needs: build
266+
needs: [ setup-fonts-matrix, build ]
198267
runs-on: ubuntu-latest
199268
steps:
200269
- uses: actions/checkout@v3
@@ -210,9 +279,50 @@ jobs:
210279
name: patched-fonts
211280
path: .
212281

213-
- uses: EndBug/add-and-commit@v9
282+
- name: Bump version for source files
283+
env:
284+
RELEASE_VERSION: ${{ needs.setup-fonts-matrix.outputs.rel_version }}
285+
RELEASE_CANDIDATE: ${{ needs.setup-fonts-matrix.outputs.rel_candidate }}
286+
run: |
287+
cd -- "$GITHUB_WORKSPACE/bin/scripts"
288+
./version-bump.sh "$RELEASE_VERSION"
289+
290+
- name: Commit version bump changes
291+
# If there are no changes (i.e. we already have that bump commit from a previous run)
292+
# the git commit will fail as empty commit (that we do not explicitely allow here),
293+
# and the action fails silently (i.e. without stopping the job).
294+
# This means there will be only one commit in the repo for each version tag change,
295+
# regardless of how often we run the release CI.
296+
uses: EndBug/add-and-commit@v9
297+
with:
298+
add: "['font-patcher', 'bin/scripts']"
299+
message: "[ci] Bump release version"
300+
committer_name: GitHub Actions
301+
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
302+
303+
- name: Commit patched fonts back to repo
304+
uses: EndBug/add-and-commit@v9
214305
with:
215306
add: 'patched-fonts'
216-
message: Rebuilds patched fonts
307+
message: "[ci] Rebuilds patched fonts"
308+
committer_name: GitHub Actions
309+
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
310+
311+
- name: Generate fontconfig
312+
run: |
313+
cd -- "$GITHUB_WORKSPACE/bin/scripts"
314+
./generate-fontconfig.sh
315+
316+
- name: Commit fontconfig back to repo
317+
uses: EndBug/add-and-commit@v9
318+
with:
319+
add: '10-nerd-font-symbols.conf'
320+
message: "[ci] Regenerate fontconfig"
217321
committer_name: GitHub Actions
218322
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
323+
324+
- name: Adjust release tag to include previous commit
325+
uses: EndBug/[email protected]
326+
if: needs.setup-fonts-matrix.outputs.rel_upload == 'true'
327+
with:
328+
ref: "v${{ needs.setup-fonts-matrix.outputs.rel_version }}"

Diff for: bin/scripts/archive-fonts.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
# Nerd Fonts Version: 2.1.0
3-
# Script Version: 1.1.1
3+
# Script Version: 1.1.2
44
# Iterates over all patched fonts directories
55
# to generate ruby cask files for homebrew-fonts (https://github.com/caskroom/homebrew-fonts)
66
# adds Windows versions of the fonts as well (casks files just won't download them)
@@ -48,7 +48,7 @@ find "${outputdir:?}" -name "$search_pattern" -type f -delete
4848
#find ./ProFont -maxdepth 0 -type d | # uncomment to test 1 font
4949
# find ./IBMPlexMono -maxdepth 0 -type d | # uncomment to test 1 font
5050
# uncomment to test all fonts:
51-
find -- * -maxdepth 0 -iregex "$pattern" -type d |
51+
find . -maxdepth 1 -iregex "\./$pattern" -type d |
5252
while read -r filename
5353
do
5454

@@ -71,14 +71,14 @@ do
7171
# we can copy the font files without full paths but not necessarily the license files:
7272
# add license files separately:
7373
# zip -9 "$outputdir/$basename" -rj "$searchdir" -i '*license*' -i '*LICENSE*'
74-
# work around to copy duplicate license files (only the last duplicate found)
74+
# work around to copy duplicate license files (only the last duplicate found)
7575
# so we don't have to copy entire paths and can still use the junk option (-j)
7676
find "$searchdir" -type f -iname "*license*" | awk -F/ '{a[$NF]=$0}END{for(i in a)print a[i]}' | zip -9 -j "$outputdir/$basename" -@
7777
fi;
7878

7979
# add mini readme file
8080
zip -9 "$outputdir/$basename" -rj "$mini_readme" -q
81-
rm -f "$mini_readme"
8281
done
82+
rm -f "$mini_readme"
8383

84-
ls -al "$outputdir"
84+
ls -al "$outputdir"

0 commit comments

Comments
 (0)