Skip to content

wip

wip #177

name: Build and Upload Fonts
on:
push:
branches:
- main
paths:
- "sources/**"
- ".github/**"
pull_request:
branches:
- main
paths:
- "sources/**"
- ".github/**"
workflow_dispatch:
permissions:
contents: write
packages: read
jobs:
build-fonts:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
extra-conf: |
experimental-features = nix-command flakes
accept-flake-config = true
- name: Cache Nix store
uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Build fonts using Nix develop
run: |
./sources/build.sh
- name: Upload Built Fonts Artifact
uses: actions/upload-artifact@v4
with:
name: Built_Fonts
path: sources/output
if-no-files-found: error
retention-days: 90
compression-level: 0 # Use 0 for faster upload/download if needed, or 9 for max compression
overwrite: true
include-hidden-files: false
- name: Check fonts using Nix develop
run: |
./sources/scripts/check_fonts.sh "sources/output"
- name: Upload Font Check Reports Artifact
uses: actions/upload-artifact@v4
with:
name: FontBakery_Reports
path: sources/output/report.md
if-no-files-found: error # Keep this to ensure the report was generated
# Archive the output fonts
- name: Archive output fonts
run: |
mkdir -p sources/output
find output -maxdepth 1 -type d -print0 | while IFS= read -r -d $'\0' dir; do
if [ "$dir" != "output" ]; then
zip -r "sources/output/$(basename "$dir").zip" "$dir"
fi
done
# Create a tag for the release
- name: Create tag
id: create_tag
run: |
git config user.name github-actions
git config user.email github-actions@github.com
TAG_NAME="release-$(date +'%Y%m%d-%H%M%S')"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
git tag $TAG_NAME
git push origin $TAG_NAME
- name: Prepare release body with font check results
run: |
REPORT_PATH="sources/output/report.md"
REPORT_TXT="sources/output/fontbakery-report.txt"
RELEASE_NOTES="sources/output/release_notes.md"
if [ ! -f "$REPORT_PATH" ]; then
echo "Fontbakery report missing at $REPORT_PATH" > "$RELEASE_NOTES"
echo "RELEASE_BODY_PATH=$RELEASE_NOTES" >> $GITHUB_ENV
echo "REPORT_TXT=" >> $GITHUB_ENV
exit 0
fi
cp "$REPORT_PATH" "$REPORT_TXT"
echo "Fontbakery failure summary (max 1000 chars)." > "$RELEASE_NOTES"
if grep -Ei 'FAIL|❌|:x:' "$REPORT_PATH" > /tmp/fail_lines.txt; then
echo "" >> "$RELEASE_NOTES"
perl -0777 -ne 'print substr($_, 0, 1000)' /tmp/fail_lines.txt >> "$RELEASE_NOTES"
else
echo "No FAIL results reported." >> "$RELEASE_NOTES"
fi
# Ensure the entire body stays within 1000 characters
perl -0777 -i -ne 'print substr($_, 0, 1000)' "$RELEASE_NOTES"
echo "RELEASE_BODY_PATH=$RELEASE_NOTES" >> $GITHUB_ENV
echo "REPORT_TXT=$REPORT_TXT" >> $GITHUB_ENV
# Create a release and upload fonts
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: |
sources/output/*.zip
${{ env.REPORT_TXT }}
name: Font Build - ${{ github.sha }}
body_path: ${{ env.RELEASE_BODY_PATH }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.TAG_NAME }}