Skip to content

Commit 116b6eb

Browse files
committed
added github actions
1 parent 1b1d390 commit 116b6eb

2 files changed

Lines changed: 165 additions & 0 deletions

File tree

.github/workflows/build.yaml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Build font and specimen
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
tags:
10+
- '*'
11+
12+
permissions: write-all
13+
14+
jobs:
15+
build:
16+
name: Build and test
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v6
20+
- name: Set up Python 3.11
21+
uses: actions/setup-python@v6
22+
with:
23+
python-version: "3.11"
24+
- name: Setup fontspector
25+
uses: fonttools/setup-fontspector@main
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
- name: Install toolset
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install ttfautohint libcairo2-dev python3-cairo-dev pkg-config python3-dev
32+
sudo snap install yq
33+
- uses: actions/cache@v4
34+
with:
35+
path: ./venv/
36+
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements*.txt') }}
37+
restore-keys: |
38+
${{ runner.os }}-venv-
39+
- name: Set artifact file name
40+
id: zip-name
41+
shell: bash
42+
# Set the archive name to repo name + "-fonts" e.g "radiocanadafonts-fonts.zip"
43+
run: echo "ZIP_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')-fonts" >> $GITHUB_ENV
44+
45+
# If a new release is cut, use the release tag to auto-bump the source files
46+
# - name: Bump release
47+
# if: github.event_name == 'release'
48+
# run: |
49+
# . venv/bin/activate
50+
# SRCS=$(yq e ".sources[]" sources/config.yaml)
51+
# TAG_NAME=${GITHUB_REF/refs\/tags\//}
52+
# echo "Bumping $SRCS to $TAG_NAME"
53+
# for src in $SRCS
54+
# do
55+
# bumpfontversion sources/$src --new-version $TAG_NAME;
56+
# done
57+
58+
- name: Build font
59+
run: make build
60+
61+
- name: Generate specimen images
62+
run: |
63+
source venv/bin/activate
64+
python3 documentation/image1.py --output documentation/image1.png
65+
python3 documentation/image2.py --output documentation/image2.png
66+
67+
- name: Check with fontspector
68+
run: make test
69+
continue-on-error: true
70+
- name: Generate proofs
71+
run: make proof
72+
- name: Set up test result site
73+
run: cp scripts/index.html out/index.html
74+
- name: Collect deployment assets
75+
if: ${{ github.ref == 'refs/heads/main' }}
76+
uses: actions/upload-pages-artifact@v4
77+
with:
78+
path: ./out
79+
- name: Archive artifacts
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: ${{ env.ZIP_NAME }}
83+
path: |
84+
fonts
85+
out
86+
documentation/image1.png
87+
documentation/image2.png
88+
outputs:
89+
zip_name: ${{ env.ZIP_NAME }}
90+
91+
deploy:
92+
name: Deploy results to GitHub Pages
93+
if: ${{ github.ref == 'refs/heads/main' }}
94+
needs: build
95+
runs-on: ubuntu-latest
96+
permissions:
97+
pages: write
98+
id-token: write
99+
environment:
100+
name: github-pages
101+
url: ${{ steps.deployment.outputs.page_url }}
102+
steps:
103+
- name: Deploy to GitHub Pages
104+
id: deployment
105+
uses: actions/deploy-pages@v4
106+
107+
# There are two ways a release can be created: either by pushing a tag, or by
108+
# creating a release from the GitHub UI. Pushing a tag does not automatically
109+
# create a release, so we have to do that ourselves. However, creating a
110+
# release from the GitHub UI *does* push a tag, and we don't want to create
111+
# a new release in that case because one already exists!
112+
113+
release:
114+
name: Release bundle
115+
if: contains(github.ref, 'refs/tags/')
116+
needs: build
117+
runs-on: ubuntu-latest
118+
env:
119+
ZIP_NAME: ${{ needs.build.outputs.zip_name }}
120+
GH_TOKEN: ${{ github.token }}
121+
steps:
122+
- uses: actions/checkout@v6
123+
- name: Use font artifacts from CI
124+
uses: actions/download-artifact@v5
125+
with:
126+
name: ${{ env.ZIP_NAME }}
127+
path: ${{ env.ZIP_NAME }}
128+
- name: Copy ARTICLE.en_us.html to release directory
129+
run: cp documentation/ARTICLE.en_us.html ${{ env.ZIP_NAME }}/ARTICLE.en_us.html
130+
continue-on-error: true
131+
- name: Copy OFL.txt to release directory
132+
run: cp OFL.txt ${{ env.ZIP_NAME }}/OFL.txt
133+
- name: Remove proof/test outputs from release
134+
run: rm -rf ${{ env.ZIP_NAME }}/out
135+
- name: Set release file name
136+
shell: bash
137+
run: echo "RELEASE_ZIP_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')-${{github.ref_name}}" >> $GITHUB_ENV
138+
- name: Create release bundle
139+
run: mv ${{ env.ZIP_NAME }} ${{ env.RELEASE_ZIP_NAME }}; zip -r ${{ env.RELEASE_ZIP_NAME }}.zip ${{ env.RELEASE_ZIP_NAME }}
140+
- name: Check for release
141+
id: create_release
142+
run: |
143+
if ! gh release view ${{ github.ref_name }}; then
144+
git show -s --format=%B ${{ github.ref_name }} | tail -n +4 | gh release create ${{ github.ref_name }} -t ${{ github.ref_name }} -F -
145+
fi
146+
- name: Populate release
147+
run: |
148+
gh release upload ${{ github.ref_name }} ${{ env.RELEASE_ZIP_NAME }}.zip --clobber
149+
- name: Set release live
150+
run: |
151+
gh release edit ${{ github.ref_name }} --draft=false

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*~
2+
venv
3+
build.stamp
4+
proof
5+
6+
# OS generated files #
7+
######################
8+
.DS_Store
9+
.DS_Store?
10+
._*
11+
.Spotlight-V100
12+
.Trashes
13+
ehthumbs.db
14+
Thumbs.db

0 commit comments

Comments
 (0)