move-check.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. # This script copies the latest builds to the google fonts dir in order to run QA checks and prep for a PR
  3. #
  4. # USAGE:
  5. # Install requirements with `pip install -U -r googlefonts-qa/requirements.txt`
  6. #
  7. # call this script from the root of your fira code repo, with the absolute path to your local google/fonts repo
  8. # `move-check <your_username>/<path>/fonts`
  9. set -ex
  10. source venv/bin/activate
  11. gFontsDir=$1
  12. if [[ -z "$gFontsDir" || $gFontsDir = "--help" ]] ; then
  13. echo 'Add absolute path to your Google Fonts Git directory, like:'
  14. echo 'googlefonts-qa/scripts/move-check.sh /Users/your-username/type-repos/google-font-repos/fonts'
  15. exit 2
  16. fi
  17. firaCodeDir=$(pwd)
  18. firaCodeQADir=$firaCodeDir/googlefonts-qa
  19. firaCodeVF=$firaCodeDir/distr/variable_ttf/FiraCode-VF.ttf
  20. # -------------------------------------------------------------------
  21. # get latest version ------------------------------------------------
  22. ttx -t head $firaCodeVF
  23. fontVersion=v$(xml sel -t --match "//*/fontRevision" -v "@value" ${firaCodeVF/".ttf"/".ttx"})
  24. rm ${firaCodeVF/".ttf"/".ttx"}
  25. # -------------------------------------------------------------------
  26. # navigate to google/fonts repo, then fira code branch --------------
  27. cd $gFontsDir
  28. git checkout master
  29. git pull upstream master
  30. git reset --hard
  31. git checkout -B firacode
  32. git clean -f -d
  33. # -------------------------------------------------------------------
  34. # move fonts --------------------------------------------------------
  35. mkdir -p ofl/firacode
  36. cp $firaCodeVF "ofl/firacode/FiraCode-Light.ttf"
  37. mkdir -p ofl/firacode/static
  38. statics=$(ls $firaCodeDir/distr/ttf/*.ttf)
  39. for ttf in $statics
  40. do
  41. cp $ttf ofl/firacode/static/$(basename $ttf)
  42. done
  43. # -------------------------------------------------------------------
  44. # make or move basic metadata ---------------------------------------
  45. cp $firaCodeDir/googlefonts-qa/METADATA.pb ofl/firacode/METADATA.pb
  46. cp $firaCodeDir/LICENSE ofl/firacode/OFL.txt
  47. cp $firaCodeQADir/gfonts-description.html ofl/firacode/DESCRIPTION.en_us.html
  48. # -------------------------------------------------------------------
  49. # run checks, saving to firacode/googlefonts-qa/checks ------------
  50. set +e # otherwise, the script stops after the first fontbakery check output
  51. mkdir -p $firaCodeQADir/checks/static
  52. cd ofl/firacode
  53. ttfs=$(ls -R */*.ttf && ls *.ttf) # use this to statics and VFs
  54. # ttfs=$(ls *.ttf) # use this to check only the VFs
  55. # ttfs=$(ls -R */*.ttf ) # use this to check only statics
  56. for ttf in $ttfs
  57. do
  58. echo $ttf
  59. fontbakery check-googlefonts $ttf --ghmarkdown $firaCodeQADir/checks/${ttf/".ttf"/".checks.md"}
  60. done
  61. git add .
  62. git commit -m "fira code: $fontVersion added."
  63. git push --force upstream firacode