2022-09-18 16:11:03 +02:00
|
|
|
name: PackSVGs
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
paths:
|
|
|
|
- 'src/svgs/*'
|
|
|
|
- 'bin/scripts/generate-original-source.py'
|
2022-09-20 14:31:30 +02:00
|
|
|
- 'bin/scripts/optimize-original-source.sh'
|
2022-09-18 16:11:03 +02:00
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
create-symbols-font:
|
2022-09-19 11:43:54 +02:00
|
|
|
runs-on: ubuntu-22.04
|
2022-09-18 16:11:03 +02:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
2022-09-19 11:43:54 +02:00
|
|
|
- name: Fetch dependencies
|
2022-09-18 16:11:03 +02:00
|
|
|
run: |
|
|
|
|
sudo apt update -y -q
|
2022-09-20 14:31:30 +02:00
|
|
|
# ttfdump comes with texlive-binaries
|
|
|
|
# We use ttfdump instead of showttf, because the later core dumps at the moment
|
|
|
|
sudo apt install python3-fontforge inkscape texlive-binaries dc -y -q
|
2022-09-19 11:43:54 +02:00
|
|
|
|
|
|
|
- name: Simplify the SVGs
|
2022-09-21 11:55:48 +02:00
|
|
|
id: optimize
|
2022-09-19 11:43:54 +02:00
|
|
|
run: |
|
|
|
|
cd bin/scripts
|
2022-09-21 11:55:48 +02:00
|
|
|
./optimize-original-source.sh doit | tee optlog.txt
|
|
|
|
changenum=$(tail -n 1 optlog.txt | sed -E 's/[^0-9]*([0-9]+).*/\1/')
|
|
|
|
echo "Script claims number of changed files: ${changenum}"
|
2022-10-13 16:28:02 +02:00
|
|
|
echo "num_of_files=${changenum}" >> $GITHUB_OUTPUT
|
2022-09-19 11:43:54 +02:00
|
|
|
|
|
|
|
- name: Commit simplified SVGs back to repo
|
2022-09-21 11:55:48 +02:00
|
|
|
if: steps.optimize.outputs.num_of_files > 0
|
2022-09-19 11:43:54 +02:00
|
|
|
uses: EndBug/add-and-commit@v9
|
|
|
|
with:
|
|
|
|
fetch: false
|
|
|
|
add: 'src/svgs'
|
|
|
|
message: "[ci] Simplify original-source source glyphs"
|
|
|
|
committer_name: GitHub Actions
|
|
|
|
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
|
2022-09-18 16:11:03 +02:00
|
|
|
|
2022-09-20 14:31:30 +02:00
|
|
|
- name: Dummy create Seti-and-original-symbols font and CHECK FOR CHANGES
|
|
|
|
id: compare_font
|
2022-09-18 16:11:03 +02:00
|
|
|
run: |
|
|
|
|
cd bin/scripts
|
2022-09-20 14:31:30 +02:00
|
|
|
echo "OLD_FONT_LS=$(ls -l ../../src/glyphs/original-source.otf)" >> $GITHUB_ENV
|
|
|
|
# First we create a 'test' font with the same timestamp as the old to see if
|
|
|
|
# there are any differences (apart from the timestamp)
|
|
|
|
export CURRENT_FONT_DATE=$(ttfdump -t head ../../src/glyphs/original-source.otf | \
|
|
|
|
grep -E '[^a-z]created:.*0x' | sed 's/.*x//' | tr 'a-f' 'A-F')
|
|
|
|
echo "Font creation date (1904): 0x${CURRENT_FONT_DATE}"
|
|
|
|
# The timestamp in the HEAD table is given in 1904 seconds, we convert that
|
|
|
|
# to 1970 (unix) seconds.
|
|
|
|
export SOURCE_DATE_EPOCH=$(dc -e "16i ${CURRENT_FONT_DATE} Ai 86400 24107 * - p")
|
|
|
|
echo "Font creation date (1970): ${SOURCE_DATE_EPOCH}"
|
|
|
|
echo "Create font with previous timestamp"
|
|
|
|
./generate-original-source.py
|
|
|
|
# Check if the new font file has changed
|
|
|
|
CHANGE=$(git diff --quiet ../../src/glyphs/original-source.otf && echo false || echo true)
|
|
|
|
echo "Change detected: ${CHANGE}"
|
2022-10-13 16:28:02 +02:00
|
|
|
echo "changed=${CHANGE}" >> $GITHUB_OUTPUT
|
2022-09-20 14:31:30 +02:00
|
|
|
|
|
|
|
- name: Create Seti-and-original-symbols font for real with current timestamp
|
|
|
|
if: steps.compare_font.outputs.changed == 'true'
|
|
|
|
run: |
|
|
|
|
cd bin/scripts
|
|
|
|
echo "Create font with current timestamp"
|
|
|
|
# We need to force creation and modification timestamp to be identical
|
|
|
|
# to make the compare_font step work next time
|
|
|
|
export SOURCE_DATE_EPOCH=$(date +%s)
|
2022-09-18 16:11:03 +02:00
|
|
|
./generate-original-source.py
|
2022-09-20 14:31:30 +02:00
|
|
|
echo "${OLD_FONT_LS}"
|
2022-09-18 16:11:03 +02:00
|
|
|
ls -l ../../src/glyphs/original-source.otf
|
2022-09-19 11:43:54 +02:00
|
|
|
|
2022-09-20 14:31:30 +02:00
|
|
|
- name: Commit created font back to repo
|
|
|
|
if: steps.compare_font.outputs.changed == 'true'
|
2022-09-18 16:11:03 +02:00
|
|
|
uses: EndBug/add-and-commit@v9
|
|
|
|
with:
|
|
|
|
fetch: false
|
|
|
|
add: 'src/glyphs/original-source.otf'
|
|
|
|
message: "[ci] Rebuild original-source font"
|
|
|
|
committer_name: GitHub Actions
|
|
|
|
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
|