name: Build, QA, release on: workflow_call: secrets: USER_GITHUB_TOKEN: description: "A github token representing the Google Fonts onboarder's account" required: false SSH_KEY: description: "An SSH key for the Google Fonts onboarder" required: false env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: build-all: runs-on: ubuntu-latest name: Build main TTFs steps: - uses: actions/checkout@v4 - name: Set up latest harfbuzz uses: notofonts/install-harfbuzz-action@main - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Do first-run script if necessary run: make .init.stamp if: github.repository != 'notofonts/noto-project-template' - uses: stefanzweifel/git-auto-commit-action@v5 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" - name: Build fonts run: make build - name: Archive artifacts uses: actions/upload-artifact@v4 with: name: fontbuild path: fonts fontspector-googlefonts: name: Check with fontspector runs-on: ubuntu-latest needs: build-all steps: - uses: actions/checkout@v4 - name: Download font build zip uses: actions/download-artifact@v4 with: name: fontbuild path: fonts - name: Set up Fontspector uses: fonttools/setup-fontspector@main env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Make directories run: mkdir -p out/fontspector out/badges continue-on-error: true - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Check with fontspector run: | . venv/bin/activate ; python3 -m notoqa continue-on-error: true - name: Archive artifacts uses: actions/upload-artifact@v4 with: name: fontspector-googlefonts path: out proof: name: Create proof documents runs-on: ubuntu-latest needs: build-all steps: - uses: actions/checkout@v4 - name: Download font build zip uses: actions/download-artifact@v4 with: name: fontbuild path: fonts - name: Install xml2/xslt/cairo dev run: sudo apt-get install libxml2-dev libxslt1-dev libcairo2-dev - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Make proof run: | . 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 - name: Archive artifacts uses: actions/upload-artifact@v4 with: name: proof path: out regression: name: Regression test runs-on: ubuntu-latest needs: build-all steps: - uses: actions/checkout@v4 - name: Download font build zip uses: actions/download-artifact@v4 with: name: fontbuild path: fonts - name: Set up diffenator3 uses: notofonts/install-diffenator3-action@main - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install xml2/xslt/cairo dev run: sudo apt-get install libxml2-dev libxslt1-dev libcairo2-dev - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Regression test run: . venv/bin/activate; python3 -m notoqa.regression env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Archive artifacts uses: actions/upload-artifact@v4 with: name: regression path: out report: name: Rebuild website if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest needs: - fontspector-googlefonts - proof - regression steps: - uses: actions/checkout@v4 - name: Download font zip uses: actions/download-artifact@v4 with: name: fontbuild path: fonts - name: Download fontspector-googlefonts zip uses: actions/download-artifact@v4 with: name: fontspector-googlefonts path: out - name: Download proof zip uses: actions/download-artifact@v4 with: name: proof path: out continue-on-error: true - name: Download regression test zip uses: actions/download-artifact@v4 with: name: regression path: out continue-on-error: true - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install xml2/xslt/cairo dev run: sudo apt-get install libxml2-dev libxslt1-dev libcairo2-dev - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Rebuild website run: . venv/bin/activate; python3 -m notobuilder.ghpages - name: Copy fonts to gh-pages dir run: cp -r fonts out - name: Deploy uses: actions/upload-pages-artifact@v3.0.1 if: ${{ github.ref == 'refs/heads/main' }} with: path: ./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@v4 with: name: ${{ env.ZIP_NAME }} path: out deploy: name: Deploy website to GitHub Pages needs: report runs-on: ubuntu-latest permissions: pages: write id-token: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 create_release: if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') needs: - build-all runs-on: ubuntu-latest name: Create release outputs: url: ${{ steps.upload.outputs.browser_download_url }} config_file: ${{ steps.check_tag.outputs.config_file }} family: ${{ steps.check_tag.outputs.family }} steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - run: pip3 install 'git+https://github.com/googlefonts/gftools' - name: Download font zip uses: actions/download-artifact@v4 with: name: fontbuild path: fonts - name: Install the latest version of uv uses: eifinger/setup-uv@v1 with: enable-cache: true - name: Install Python deps run: | uv venv venv; . venv/bin/activate ; uv pip install -r requirements.txt touch venv/touchfile - name: Check for appropriate tag id: check_tag run: . venv/bin/activate; python3 scripts/check-tag.py ${{ github.ref_name }} - name: Set release body from tag run: | echo 'RELEASE_NOTES<> "$GITHUB_ENV" git show -s --format=%B ${{ github.ref_name }} | tail -n +4 >> "$GITHUB_ENV" echo 'EOF' >> "$GITHUB_ENV" - 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 }} body: ${{ env.RELEASE_NOTES }} - name: Tell user about release run: | echo '::warning file=sources/config.yaml,title=A new release ${{ github.ref_name }} has been created' git show -s --format=%B ${{ github.ref_name }} | tail -n +4 echo "$RELEASE_NOTES" - name: Find a DESCRIPTION.en_us.html run: cp documentation/${{ steps.check_tag.outputs.family}}.html fonts/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 fonts/ARTICLE.en_us.html continue-on-error: true - name: Create release bundle 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 - 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: ${{ env.RELEASE_NOTES }} google_fonts_pr: runs-on: ubuntu-latest environment: googlefonts name: Submit PR to Google Fonts needs: create_release 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@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - run: pip3 install 'git+https://github.com/googlefonts/gftools#egg=gftools' - uses: actions/checkout@v4 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 `echo ${{needs.create_release.outputs.family}} | tr 'A-Z' 'a-z'` googlefonts --latest-release -p --show-tracebacks env: GH_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }}