-
Notifications
You must be signed in to change notification settings - Fork 15
219 lines (185 loc) · 6.1 KB
/
Copy pathpr.yaml
File metadata and controls
219 lines (185 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: PR
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
packages: write
env:
REGISTRY: ghcr.io
IMAGE: ghcr.io/${{ github.repository }}
FONT_NAME: afio
jobs:
rc-checks:
if: startsWith(github.head_ref, 'v') && endsWith(github.head_ref, '-rc')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Validate VERSION matches branch
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
BRANCH="${{ github.head_ref }}"
EXPECTED="v${VERSION}-rc"
if [ "$BRANCH" != "$EXPECTED" ]; then
echo "::error::VERSION file (${VERSION}) does not match branch ${BRANCH} (expected ${EXPECTED})"
exit 1
fi
- name: Check release notes in PR description
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
if [ -z "$PR_BODY" ]; then
echo "::error::PR description is required for RC branches (used as release notes)"
exit 1
fi
build-image:
runs-on: ubuntu-latest
outputs:
image-ref: ${{ steps.refs.outputs.image_ref }}
short-sha: ${{ steps.sha.outputs.short }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: sha
run: |
SHA="${{ github.event.pull_request.head.sha }}"
echo "short=${SHA::7}" >> "$GITHUB_OUTPUT"
- id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE }}
tags: |
type=raw,value=sha-${{ steps.sha.outputs.short }}
- uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
- id: refs
run: echo "image_ref=${{ env.IMAGE }}:sha-${{ steps.sha.outputs.short }}" >> "$GITHUB_OUTPUT"
build-font:
needs: build-image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Restore verda cache
uses: actions/cache@v5
with:
path: .verda-cache
key: verda-${{ hashFiles('VERSION') }}-${{ hashFiles('private-build-plans.toml') }}
restore-keys: |
verda-${{ hashFiles('VERSION') }}-
- name: Build font
env:
IMAGE_REF: ${{ needs.build-image.outputs.image-ref }}
VERDA_CACHE: .verda-cache
run: ./build.sh
- uses: actions/upload-artifact@v7
with:
name: font-build
path: _output/${{ env.FONT_NAME }}-*.zip
visual-check:
needs: build-font
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
with:
name: font-build
path: _output
- name: Extract fonts
run: |
mkdir -p _fonts
unzip _output/${FONT_NAME}-*.zip -d _fonts/
- name: Generate showcase PNGs
run: python3 src/generate_showcase_matrix.py --font-dir _fonts --output-dir _generated
- name: Install imagemagick
run: sudo apt-get update -yqq && sudo apt-get install -yqq imagemagick
- name: Pixel diff with reference
run: |
DIFF_FOUND=0
mkdir -p _diffs
for ref in docs/imgs/generated/*.png; do
name=$(basename "$ref")
gen="_generated/$name"
if [ ! -f "$gen" ]; then
echo "::error::Missing generated file: $name"
DIFF_FOUND=1
continue
fi
PIXELS=$(compare -metric AE "$ref" "$gen" "_diffs/$name" 2>&1 || true)
if [ "$PIXELS" != "0" ]; then
echo "::warning::$name: $PIXELS pixels differ"
DIFF_FOUND=1
else
rm -f "_diffs/$name"
fi
done
if [ "$DIFF_FOUND" -eq 1 ]; then
echo "::error::Visual regression detected"
exit 1
fi
- uses: actions/upload-artifact@v7
if: failure()
with:
name: visual-diffs
path: _diffs/
- uses: actions/upload-artifact@v7
if: failure()
with:
name: visual-generated
path: _generated/*.png
prerelease:
if: startsWith(github.head_ref, 'v') && endsWith(github.head_ref, '-rc')
needs: [rc-checks, visual-check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Extract version
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
- name: Download font artifact
uses: actions/download-artifact@v8
with:
name: font-build
path: _output
- name: Create pre-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ github.event.pull_request.head.sha }}
PR_BODY: ${{ github.event.pull_request.body }}
run: |
RC_TAG="v${VERSION}-rc.${{ github.run_number }}"
mv _output/${FONT_NAME}-*.zip "_output/${FONT_NAME}-${RC_TAG}.zip"
gh api "repos/${{ github.repository }}/git/refs" \
-f ref="refs/tags/${RC_TAG}" \
-f sha="${SHA}"
gh release create "$RC_TAG" \
"_output/${FONT_NAME}-${RC_TAG}.zip" \
-R "${{ github.repository }}" \
--prerelease \
--title "$RC_TAG" \
--notes "$PR_BODY"