| 1 |
name: Build, QA, release |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_call: |
| 5 |
secrets: |
| 6 |
USER_GITHUB_TOKEN: |
| 7 |
description: "A github token representing the Google Fonts onboarder's account" |
| 8 |
required: false |
| 9 |
SSH_KEY: |
| 10 |
description: "An SSH key for the Google Fonts onboarder" |
| 11 |
required: false |
| 12 |
|
| 13 |
env: |
| 14 |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 15 |
|
| 16 |
jobs: |
| 17 |
build-all: |
| 18 |
runs-on: ubuntu-latest |
| 19 |
name: Build main TTFs |
| 20 |
steps: |
| 21 |
- uses: actions/checkout@v4 |
| 22 |
- name: Set up latest harfbuzz |
| 23 |
uses: notofonts/install-harfbuzz-action@main |
| 24 |
- name: Set up Python |
| 25 |
uses: actions/setup-python@v5 |
| 26 |
with: |
| 27 |
python-version: "3.11" |
| 28 |
- name: Install the latest version of uv |
| 29 |
uses: eifinger/setup-uv@v1 |
| 30 |
with: |
| 31 |
enable-cache: true |
| 32 |
- name: Install Python deps |
| 33 |
run: | |
| 34 |
uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt |
| 35 |
touch venv/touchfile |
| 36 |
- name: Do first-run script if necessary |
| 37 |
run: make .init.stamp |
| 38 |
if: github.repository != 'notofonts/noto-project-template' |
| 39 |
- uses: stefanzweifel/git-auto-commit-action@v5 |
| 40 |
name: First-run setup |
| 41 |
if: github.repository != 'notofonts/noto-project-template' |
| 42 |
with: |
| 43 |
file_pattern: .init.stamp README.md requirements.txt OFL.txt |
| 44 |
commit_message: "Personalize for this repo" |
| 45 |
- name: Build fonts |
| 46 |
run: make build |
| 47 |
- name: Archive artifacts |
| 48 |
uses: actions/upload-artifact@v4 |
| 49 |
with: |
| 50 |
name: fontbuild |
| 51 |
path: fonts |
| 52 |
|
| 53 |
fontspector-googlefonts: |
| 54 |
name: Check with fontspector |
| 55 |
runs-on: ubuntu-latest |
| 56 |
needs: build-all |
| 57 |
steps: |
| 58 |
- uses: actions/checkout@v4 |
| 59 |
- name: Download font build zip |
| 60 |
uses: actions/download-artifact@v4 |
| 61 |
with: |
| 62 |
name: fontbuild |
| 63 |
path: fonts |
| 64 |
- name: Set up Fontspector |
| 65 |
uses: fonttools/setup-fontspector@main |
| 66 |
env: |
| 67 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 68 |
- name: Make directories |
| 69 |
run: mkdir -p out/fontspector out/badges |
| 70 |
continue-on-error: true |
| 71 |
- name: Install the latest version of uv |
| 72 |
uses: eifinger/setup-uv@v1 |
| 73 |
with: |
| 74 |
enable-cache: true |
| 75 |
- name: Install Python deps |
| 76 |
run: | |
| 77 |
uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt |
| 78 |
touch venv/touchfile |
| 79 |
- name: Check with fontspector |
| 80 |
run: | |
| 81 |
. venv/bin/activate ; python3 -m notoqa |
| 82 |
continue-on-error: true |
| 83 |
- name: Archive artifacts |
| 84 |
uses: actions/upload-artifact@v4 |
| 85 |
with: |
| 86 |
name: fontspector-googlefonts |
| 87 |
path: out |
| 88 |
|
| 89 |
proof: |
| 90 |
name: Create proof documents |
| 91 |
runs-on: ubuntu-latest |
| 92 |
needs: build-all |
| 93 |
steps: |
| 94 |
- uses: actions/checkout@v4 |
| 95 |
- name: Download font build zip |
| 96 |
uses: actions/download-artifact@v4 |
| 97 |
with: |
| 98 |
name: fontbuild |
| 99 |
path: fonts |
| 100 |
- name: Install xml2/xslt/cairo dev |
| 101 |
run: sudo apt-get install libxml2-dev libxslt1-dev libcairo2-dev |
| 102 |
- name: Set up Python |
| 103 |
uses: actions/setup-python@v5 |
| 104 |
with: |
| 105 |
python-version: "3.11" |
| 106 |
- name: Install the latest version of uv |
| 107 |
uses: eifinger/setup-uv@v1 |
| 108 |
with: |
| 109 |
enable-cache: true |
| 110 |
- name: Install Python deps |
| 111 |
run: | |
| 112 |
uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt |
| 113 |
touch venv/touchfile |
| 114 |
- name: Make proof |
| 115 |
run: | |
| 116 |
. venv/bin/activate; mkdir -p out/ out/proof; for i in fonts/* ; do family=`basename $i`; diffenator2 proof $(find fonts/$family/unhinted/ttf -type f) -o out/proof/$family; done |
| 117 |
- name: Archive artifacts |
| 118 |
uses: actions/upload-artifact@v4 |
| 119 |
with: |
| 120 |
name: proof |
| 121 |
path: out |
| 122 |
|
| 123 |
regression: |
| 124 |
name: Regression test |
| 125 |
runs-on: ubuntu-latest |
| 126 |
needs: build-all |
| 127 |
steps: |
| 128 |
- uses: actions/checkout@v4 |
| 129 |
- name: Download font build zip |
| 130 |
uses: actions/download-artifact@v4 |
| 131 |
with: |
| 132 |
name: fontbuild |
| 133 |
path: fonts |
| 134 |
- name: Set up diffenator3 |
| 135 |
uses: notofonts/install-diffenator3-action@main |
| 136 |
- name: Set up Python |
| 137 |
uses: actions/setup-python@v5 |
| 138 |
with: |
| 139 |
python-version: "3.11" |
| 140 |
- name: Install the latest version of uv |
| 141 |
uses: eifinger/setup-uv@v1 |
| 142 |
with: |
| 143 |
enable-cache: true |
| 144 |
- name: Install xml2/xslt/cairo dev |
| 145 |
run: sudo apt-get install libxml2-dev libxslt1-dev libcairo2-dev |
| 146 |
- name: Install Python deps |
| 147 |
run: | |
| 148 |
uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt |
| 149 |
touch venv/touchfile |
| 150 |
- name: Regression test |
| 151 |
run: . venv/bin/activate; python3 -m notoqa.regression |
| 152 |
env: |
| 153 |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 154 |
- name: Archive artifacts |
| 155 |
uses: actions/upload-artifact@v4 |
| 156 |
with: |
| 157 |
name: regression |
| 158 |
path: out |
| 159 |
|
| 160 |
report: |
| 161 |
name: Rebuild website |
| 162 |
if: github.ref == 'refs/heads/main' |
| 163 |
runs-on: ubuntu-latest |
| 164 |
needs: |
| 165 |
- fontspector-googlefonts |
| 166 |
- proof |
| 167 |
- regression |
| 168 |
steps: |
| 169 |
- uses: actions/checkout@v4 |
| 170 |
- name: Download font zip |
| 171 |
uses: actions/download-artifact@v4 |
| 172 |
with: |
| 173 |
name: fontbuild |
| 174 |
path: fonts |
| 175 |
- name: Download fontspector-googlefonts zip |
| 176 |
uses: actions/download-artifact@v4 |
| 177 |
with: |
| 178 |
name: fontspector-googlefonts |
| 179 |
path: out |
| 180 |
- name: Download proof zip |
| 181 |
uses: actions/download-artifact@v4 |
| 182 |
with: |
| 183 |
name: proof |
| 184 |
path: out |
| 185 |
continue-on-error: true |
| 186 |
- name: Download regression test zip |
| 187 |
uses: actions/download-artifact@v4 |
| 188 |
with: |
| 189 |
name: regression |
| 190 |
path: out |
| 191 |
continue-on-error: true |
| 192 |
- name: Set up Python |
| 193 |
uses: actions/setup-python@v5 |
| 194 |
with: |
| 195 |
python-version: "3.11" |
| 196 |
- name: Install the latest version of uv |
| 197 |
uses: eifinger/setup-uv@v1 |
| 198 |
with: |
| 199 |
enable-cache: true |
| 200 |
- name: Install xml2/xslt/cairo dev |
| 201 |
run: sudo apt-get install libxml2-dev libxslt1-dev libcairo2-dev |
| 202 |
- name: Install Python deps |
| 203 |
run: | |
| 204 |
uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt |
| 205 |
touch venv/touchfile |
| 206 |
- name: Rebuild website |
| 207 |
run: . venv/bin/activate; python3 -m notobuilder.ghpages |
| 208 |
- name: Copy fonts to gh-pages dir |
| 209 |
run: cp -r fonts out |
| 210 |
- name: Deploy |
| 211 |
uses: actions/[email protected] |
| 212 |
if: ${{ github.ref == 'refs/heads/main' }} |
| 213 |
with: |
| 214 |
path: ./out |
| 215 |
- name: gen zip file name |
| 216 |
id: zip-name |
| 217 |
shell: bash |
| 218 |
|
| 219 |
run: echo "ZIP_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')-fonts" >> $GITHUB_ENV |
| 220 |
- name: Archive artifacts |
| 221 |
uses: actions/upload-artifact@v4 |
| 222 |
with: |
| 223 |
name: ${{ env.ZIP_NAME }} |
| 224 |
path: out |
| 225 |
|
| 226 |
deploy: |
| 227 |
name: Deploy website to GitHub Pages |
| 228 |
needs: report |
| 229 |
runs-on: ubuntu-latest |
| 230 |
permissions: |
| 231 |
pages: write |
| 232 |
id-token: write |
| 233 |
environment: |
| 234 |
name: github-pages |
| 235 |
url: ${{ steps.deployment.outputs.page_url }} |
| 236 |
steps: |
| 237 |
- name: Deploy to GitHub Pages |
| 238 |
id: deployment |
| 239 |
uses: actions/deploy-pages@v4 |
| 240 |
|
| 241 |
create_release: |
| 242 |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 243 |
needs: |
| 244 |
- build-all |
| 245 |
runs-on: ubuntu-latest |
| 246 |
name: Create release |
| 247 |
outputs: |
| 248 |
url: ${{ steps.upload.outputs.browser_download_url }} |
| 249 |
config_file: ${{ steps.check_tag.outputs.config_file }} |
| 250 |
family: ${{ steps.check_tag.outputs.family }} |
| 251 |
steps: |
| 252 |
- uses: actions/checkout@v4 |
| 253 |
- name: Set up Python |
| 254 |
uses: actions/setup-python@v5 |
| 255 |
with: |
| 256 |
python-version: "3.11" |
| 257 |
- run: pip3 install 'git+https://github.com/googlefonts/gftools' |
| 258 |
- name: Download font zip |
| 259 |
uses: actions/download-artifact@v4 |
| 260 |
with: |
| 261 |
name: fontbuild |
| 262 |
path: fonts |
| 263 |
- name: Install the latest version of uv |
| 264 |
uses: eifinger/setup-uv@v1 |
| 265 |
with: |
| 266 |
enable-cache: true |
| 267 |
- name: Install Python deps |
| 268 |
run: | |
| 269 |
uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt |
| 270 |
touch venv/touchfile |
| 271 |
- name: Check for appropriate tag |
| 272 |
id: check_tag |
| 273 |
run: . venv/bin/activate; python3 scripts/check-tag.py ${{ github.ref_name }} |
| 274 |
- name: Set release body from tag |
| 275 |
run: | |
| 276 |
echo 'RELEASE_NOTES<<EOF' >> "$GITHUB_ENV" |
| 277 |
git show -s --format=%B ${{ github.ref_name }} | tail -n +4 >> "$GITHUB_ENV" |
| 278 |
echo 'EOF' >> "$GITHUB_ENV" |
| 279 |
- name: Create release |
| 280 |
id: release |
| 281 |
uses: actions/create-release@latest |
| 282 |
env: |
| 283 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 284 |
with: |
| 285 |
tag_name: ${{ github.ref_name }} |
| 286 |
release_name: ${{ github.ref_name }} |
| 287 |
body: ${{ env.RELEASE_NOTES }} |
| 288 |
- name: Tell user about release |
| 289 |
run: | |
| 290 |
echo '::warning file=sources/config.yaml,title=A new release ${{ github.ref_name }} has been created' |
| 291 |
git show -s --format=%B ${{ github.ref_name }} | tail -n +4 |
| 292 |
echo "$RELEASE_NOTES" |
| 293 |
- name: Find a DESCRIPTION.en_us.html |
| 294 |
run: cp documentation/${{ steps.check_tag.outputs.family}}.html fonts/DESCRIPTION.en_us.html |
| 295 |
continue-on-error: true |
| 296 |
- name: Find an ARTICLE.en_us.html |
| 297 |
run: cp documentation/${{ steps.check_tag.outputs.family}}.article.html fonts/ARTICLE.en_us.html |
| 298 |
continue-on-error: true |
| 299 |
- name: Create release bundle |
| 300 |
run: cd fonts; cp ../*.txt . ; zip -x requirements.txt -r ../${{ github.ref_name }}.zip ${{ steps.check_tag.outputs.family}}/ *.txt DESCRIPTION.en_us.html ARTICLE.en_us.html |
| 301 |
- name: Upload binaries to release |
| 302 |
uses: svenstaro/upload-release-action@v2 |
| 303 |
id: upload |
| 304 |
with: |
| 305 |
repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 306 |
file: ${{ github.ref_name }}.zip |
| 307 |
asset_name: ${{ github.ref_name }}.zip |
| 308 |
tag: ${{ github.ref_name }} |
| 309 |
overwrite: true |
| 310 |
body: ${{ env.RELEASE_NOTES }} |
| 311 |
google_fonts_pr: |
| 312 |
runs-on: ubuntu-latest |
| 313 |
environment: googlefonts |
| 314 |
name: Submit PR to Google Fonts |
| 315 |
needs: create_release |
| 316 |
steps: |
| 317 |
- name: Check SSH_KEY is set |
| 318 |
run: | |
| 319 |
if [[ "${{ secrets.SSH_KEY }}" == "" ]]; |
| 320 |
then |
| 321 |
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"; |
| 322 |
exit 1 |
| 323 |
fi |
| 324 |
- name: Check USER_GITHUB_TOKEN is set |
| 325 |
run: | |
| 326 |
if [[ "${{ secrets.USER_GITHUB_TOKEN }}" == "" ]]; |
| 327 |
then |
| 328 |
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"; |
| 329 |
exit 1 |
| 330 |
fi |
| 331 |
- uses: actions/checkout@v4 |
| 332 |
- name: Set up Python |
| 333 |
uses: actions/setup-python@v5 |
| 334 |
with: |
| 335 |
python-version: "3.11" |
| 336 |
- run: pip3 install 'git+https://github.com/googlefonts/gftools#egg=gftools' |
| 337 |
- uses: actions/checkout@v4 |
| 338 |
name: Check out Google Fonts repository |
| 339 |
with: |
| 340 |
fetch-depth: 0 |
| 341 |
repository: google/fonts |
| 342 |
path: "googlefonts" |
| 343 |
ssh-key: ${{ secrets.SSH_KEY }} |
| 344 |
- name: Set git username and email |
| 345 |
run: | |
| 346 |
git config --global user.email "${GH_USERNAME}@users.noreply.github.com" |
| 347 |
git config --global user.name "${GH_USERNAME}" |
| 348 |
env: |
| 349 |
GH_USERNAME: ${{ github.actor }} |
| 350 |
- name: Do SSH magic |
| 351 |
run: cd googlefonts; git remote add googlefonts [email protected]:google/fonts.git ; cd .. |
| 352 |
- name: Test fetch |
| 353 |
run: cd googlefonts; git fetch googlefonts main ; cd .. |
| 354 |
- name: Run the packager |
| 355 |
run: gftools-packager `echo ${{needs.create_release.outputs.family}} | tr 'A-Z' 'a-z'` googlefonts --latest-release -p --show-tracebacks |
| 356 |
env: |
| 357 |
GH_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }} |
| 358 |
GITHUB_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }} |