Skip to content

Commit

Permalink
Merge pull request #2 from Radically/generate-locale-cjk-combo
Browse files Browse the repository at this point in the history
Tested multiple jobs, multiple branches strategy, create release workflow
  • Loading branch information
Transfusion authored Mar 29, 2021
2 parents a984b71 + 4294566 commit 154d13e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 15 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/generate-woff2-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ on:
jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
cjk: [1, 0]
locale: ["g", "t", "h", "j", "k", "v"]
include:
- cjk: 1
branch-cjk: cjk
- cjk: 0
branch-cjk: single
- locale: g
locale-suffix: SC
- locale: t
locale-suffix: TC
- locale: h
locale-suffix: HK
- locale: j
locale-suffix: JP
- locale: k
locale-suffix: KR
- locale: v
locale-suffix: VN

container:
image: transfusion/font-splitter
steps:
Expand Down Expand Up @@ -55,13 +79,11 @@ jobs:
run: uname -a && cat /etc/issue

- name: Generate woff2
run: poetry run driver /font-splitter/bin/font-splitter
# env:
# TEST_RUN: true
run: poetry run driver /font-splitter/bin/font-splitter ${{ matrix.locale }} ${{ matrix.cjk }}

- uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: built
branch: built-${{ matrix.branch-cjk }}-${{ matrix.locale-suffix }}

- name: Release
uses: softprops/action-gh-release@v1
Expand Down
28 changes: 26 additions & 2 deletions .github/workflows/generate-woff2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ on:
jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
cjk: [1, 0]
locale: ["g", "t", "h", "j", "k", "v"]
include:
- cjk: 1
branch-cjk: cjk
- cjk: 0
branch-cjk: single
- locale: g
locale-suffix: SC
- locale: t
locale-suffix: TC
- locale: h
locale-suffix: HK
- locale: j
locale-suffix: JP
- locale: k
locale-suffix: KR
- locale: v
locale-suffix: VN

container:
image: transfusion/font-splitter
steps:
Expand Down Expand Up @@ -55,13 +79,13 @@ jobs:
run: uname -a && cat /etc/issue

- name: Generate woff2
run: poetry run driver /font-splitter/bin/font-splitter
run: poetry run driver /font-splitter/bin/font-splitter ${{ matrix.locale }} ${{ matrix.cjk }}
env:
TEST_RUN: true

- uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: built
branch: built-${{ matrix.branch-cjk }}-${{ matrix.locale-suffix }}-testing

- name: Release
uses: softprops/action-gh-release@v1
Expand Down
23 changes: 14 additions & 9 deletions hanazono_lite_webfont_gen/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

parser = argparse.ArgumentParser()
parser.add_argument("font_splitter", help="Path to font-splitter binary")
# parser.add_argument("locale", help="g, t, h, j, k, or v")
parser.add_argument("locale", help="g, t, h, j, k, or v")
parser.add_argument("cjk", help="1 for CJK, 0 for single language")

rls = None
program_args = None
Expand Down Expand Up @@ -54,9 +55,14 @@ def remove_downloaded_otf():
subprocess.Popen("rm *.otf", shell=True)


def generate_woff2(locale: str, is_mincho: bool, cjk):
def generate_woff2(is_mincho: bool):
font_splitter = program_args.font_splitter
dirname = f"{'Mincho' if is_mincho else 'Gothic'}/{LOCALES[locale]['suffix']}/{'CJK' if cjk else 'single'}"
locale = program_args.locale
cjk = program_args.cjk == "1"

# Generate Mincho and Gothic

dirname = f"{'Mincho' if is_mincho else 'Gothic'}"
family_name = (
f"Hanazono {'Mincho' if is_mincho else 'Gothic'} Lite{' CJK' if cjk else ''}"
)
Expand Down Expand Up @@ -113,16 +119,15 @@ def generate_woff2(locale: str, is_mincho: bool, cjk):
)
f.close()

subprocess.run(["npm", "pack", dirname])
subprocess.run(["npm", "pack", f"./{dirname}"])


def cli(args=None):
global program_args
program_args = parser.parse_args()
print(program_args.font_splitter)
for (is_mincho, cjk) in [(x, y) for x in [True, False] for y in [True, False]]:
for locale in ["g", "t", "h", "j", "k", "v"]:
generate_woff2(locale, is_mincho, cjk)

# break
for is_mincho in [True, False]:
generate_woff2(is_mincho)

# break
# finally at the end, commit back to repo (after this script has ended)

0 comments on commit 154d13e

Please sign in to comment.