Merge pull request #1596 from weblate/weblate-catima-catima #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate feature graphic | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- 'fastlane/**/title.txt' | |
permissions: | |
actions: none | |
checks: none | |
contents: write | |
deployments: none | |
discussions: none | |
id-token: none | |
issues: none | |
packages: none | |
pages: none | |
pull-requests: write | |
repository-projects: none | |
security-events: none | |
statuses: none | |
jobs: | |
generate-feature-graphic: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- name: Install requirements | |
run: | | |
sudo apt-get update | |
sudo apt-get install optipng mat2 | |
# Install 200 weight versions of relevant Noto (to use for languages not supported by Lexend Deca) | |
sudo apt-get install fonts-noto-extra fonts-noto-cjk-extra | |
# Custom fonts | |
mkdir "$HOME/.fonts" | |
find .scripts/generate_feature_graphic/fonts -name '*.ttf' -exec cp {} "$HOME/.fonts" \; | |
fc-cache | |
- name: Generate featureGraphic.png for each language | |
run: | | |
for lang in fastlane/metadata/android/*; do | |
pushd "$lang" | |
# Place temporary copy for editing if needed | |
cp ../../../../.scripts/generate_feature_graphic/featureGraphic.svg featureGraphic.svg | |
# Extract text after 'Catima - ' | |
export subtext="$(grep -oP '(?<=Catima \S ).*' title.txt || true)" | |
# If there is subtext, change the .svg accordingly | |
if [ -n "$subtext" ]; then | |
perl -pi -e 's/Loyalty Card Wallet/$ENV{subtext}/' featureGraphic.svg | |
# Set correct font for language if needed (Lexend Deca has limited support) | |
# We specifically need the Serif version because of the 200 weight | |
case "$(basename "$lang")" in | |
bg|el-GR|ru-RU|uk) sed -i "s/Lexend Deca/Noto Serif/" featureGraphic.svg ;; | |
ja-JP) sed -i "s/Lexend Deca/Noto Serif CJK JP/" featureGraphic.svg ;; | |
ko) sed -i "s/Lexend Deca/Noto Serif CJK KR/" featureGraphic.svg ;; | |
zh-CN) sed -i "s/Lexend Deca/Noto Serif CJK SC/" featureGraphic.svg ;; | |
zh-TW) sed -i "s/Lexend Deca/Noto Serif CJK TC/" featureGraphic.svg ;; | |
*) ;; | |
esac | |
fi | |
# Ensure images directory exists | |
mkdir -p images | |
# Generate .png | |
convert featureGraphic.svg images/featureGraphic.png | |
# Optimize .png | |
optipng images/featureGraphic.png | |
# Remove metadata (timestamps) from .png | |
mat2 --inplace images/featureGraphic.png | |
# Remove temporary .svg | |
rm featureGraphic.svg | |
popd | |
done | |
- name: Create Pull Request | |
uses: peter-evans/[email protected] | |
with: | |
title: "Update feature graphic" | |
commit-message: "Update feature graphic" | |
branch-suffix: timestamp |