diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50123e8..1188b51 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,3 @@ -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Build on: [push, pull_request] @@ -9,15 +7,58 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Unshallow + run: git fetch --prune --unshallow --tags --force - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install -r requirements.txt - name: Build + run: make -B PYTHON=python + - name: Dist + run: make dist PYTHON=python + - name: Upload artifacts + if: github.ref_type == 'tag' + uses: actions/upload-artifact@v4.4.0 + with: + name: dist + path: Qahiri-*.zip + if-no-files-found: error + + deploy: + if: github.ref_type == 'tag' + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v4.1.7 + with: + path: dist + + - name: Extract release notes from annotated tag message run: | - make + # GH checkout action doesn't preserve tag annotations, we must fetch them + # https://github.com/actions/checkout/issues/290 + git fetch --tags --force + echo "$(git tag -l --format='%(contents:body)' ${{ github.ref_name }})" > "${{ runner.temp }}/release_body.md" + echo "release_name=$(git tag -l --format='%(contents:subject)' ${{ github.ref_name }})" >> $GITHUB_ENV + + - name: Publish + uses: softprops/action-gh-release@v1 + with: + name: ${{ env.release_name }} + body_path: ${{ runner.temp }}/release_body.md + fail_on_unmatched_files: true + files: | + dist/*/* diff --git a/Makefile b/Makefile index 9985ac2..e5d64f6 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,9 @@ NAME = Qahiri -MAKEFLAGS := -sr SHELL = bash - -CONFIG = docs/_config.yml -VERSION = $(shell grep "version:" $(CONFIG) | sed -e 's/.*.: "\(.*.\)".*/\1/') -DIST = $(NAME)-$(VERSION) +MAKEFLAGS := -sr +PYTHON := venv/bin/python3 SOURCEDIR = sources SCRIPTDIR = scripts @@ -28,31 +25,34 @@ FONTDIR = fonts TESTDIR = tests BUILDDIR = build -FONTS = $(FONTDIR)/$(NAME)-Regular.ttf -WOFF2 = $(FONTDIR)/$(NAME)-Regular.woff2 +FONT = ${FONTDIR}/${NAME}-Regular.ttf + +GLYPHSFILE = ${SOURCEDIR}/${NAME}.glyphspackage + +export SOURCE_DATE_EPOCH ?= $(shell stat -c "%Y" ${GLYPHSFILE}) + +TAG = $(shell git describe --tags --abbrev=0) +VERSION = ${TAG:v%=%} +DIST = ${NAME}-${VERSION} + .SECONDARY: .ONESHELL: -.PHONY: all dist - -all: ttf web -ttf: $(FONTS) +.PHONY: all clean dist ttf -web: $(WOFF2) - cp $(WOFF2) docs/assets/fonts/ - cp $(FONTS) docs/app/assets/fonts/ +all: ttf +ttf: ${FONT} -%.ttf: $(SOURCEDIR)/$(NAME).glyphspackage $(CONFIG) - $(info   BUILD $(@F)) - python $(SCRIPTDIR)/build.py $< $(VERSION) $@ +${FONT}: ${GLYPHSFILE} + $(info   BUILD ${@F}) + ${PYTHON} ${SCRIPTDIR}/build.py $< ${VERSION} $@ -%.woff2: %.ttf - $(info   WOFF2 $(@F)) - python $(SCRIPTDIR)/buildwoff2.py $< $@ +dist: ${FONT} + $(info   DIST ${DIST}.zip) + install -Dm644 -t ${DIST} ${FONT} + install -Dm644 -t ${DIST} {README,README-Arabic}.txt + install -Dm644 -t ${DIST} OFL.txt + zip -rq ${DIST}.zip ${DIST} -dist: all - $(info   DIST $(DIST).zip) - install -Dm644 -t $(DIST) $(FONTS) - install -Dm644 -t $(DIST) {README,README-Arabic}.txt - install -Dm644 -t $(DIST) OFL.txt - zip -rq $(DIST).zip $(DIST) +clean: + rm -rf ${BUILDDIR} ${FONT} ${SVG} ${DIST} ${DIST}.zip diff --git a/scripts/buildwoff2.py b/scripts/buildwoff2.py deleted file mode 100644 index 6007ba0..0000000 --- a/scripts/buildwoff2.py +++ /dev/null @@ -1,31 +0,0 @@ -from fontTools.ttLib import TTFont -from fontTools.ttLib.woff2 import WOFF2FlavorData - - -def compress(args): - font = TTFont(args.input, recalcBBoxes=False, recalcTimestamp=False) - font.flavor = "woff2" - - if "SVG " in font: - del font["SVG "] - - font.flavorData = WOFF2FlavorData( - data=font.flavorData, transformedTables=["glyf", "loca"] - ) - - font.save(args.output, reorderTables=False) - - -def main(): - import argparse - from pathlib import Path - - parser = argparse.ArgumentParser(description="Build Raqq WOFF2 font.") - parser.add_argument("input", help="input TTF file", type=Path) - parser.add_argument("output", help="output WOFF2 file", type=Path) - args = parser.parse_args() - - compress(args) - - -main()