-
Notifications
You must be signed in to change notification settings - Fork 151
341 lines (306 loc) · 10.9 KB
/
deploy.yml
File metadata and controls
341 lines (306 loc) · 10.9 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
name: Deploy
on:
push:
pull_request:
workflow_dispatch:
env:
FORM_IGNORE_DEPRECATION: 1
jobs:
# Generate the tarball distribution, e.g., "form-v4.2.1.tar.gz" for v4.2.1.
# The tarball will be tested in the following "build-bin" job.
build-src:
name: Build tarball distribution
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # ensures a reachable tag
- name: Set up build
uses: ./.github/actions/setup-build
- name: Build tarball distribution
run: |
distname="${{ env.DISTNAME }}"
echo "distname=$distname" >>"$GITHUB_ENV"
make distdir="$distname" dist-gzip
- name: Print tarball information
run: |
ls -l "$distname.tar.gz"
file "$distname.tar.gz"
tar -tf "$distname.tar.gz"
- name: Upload tarball as artifact
uses: actions/upload-artifact@v4
with:
name: src
path: '*.tar.gz'
if-no-files-found: error
# Build executables from the tarball distribution (w/o the Git repository).
# The executables must not be too optimized for the build machine and must be
# statically linked in such a way that they are suitable for binary distributions.
build-bin:
name: Build ${{ matrix.bin }} on ${{ matrix.os }}
needs: build-src
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.shell }} {0}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-24.04, shell: bash, bin: form}
- {os: ubuntu-24.04, shell: bash, bin: tform}
# To maximize compatibility, we build executables on the oldest
# platforms available.
- {os: ubuntu-24.04-arm, shell: bash, bin: form}
- {os: ubuntu-24.04-arm, shell: bash, bin: tform}
- {os: macos-15-intel, shell: bash, bin: form}
- {os: macos-15-intel, shell: bash, bin: tform}
# The macos-14 runner image is based on the arm64 architecture.
- {os: macos-14, shell: bash, bin: form}
- {os: macos-14, shell: bash, bin: tform}
# NOTE: Windows native executables may have some problems.
# Unfortunately, "allow-failure" is not available on GitHub Actions
# (https://github.com/actions/toolkit/issues/399).
# We have to use "continue-on-error", instead.
- {os: windows-2022, shell: msys2, bin: form}
- {os: windows-2022, shell: msys2, bin: tform}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
sparse-checkout-cone-mode: false
- name: Download tarball
uses: actions/download-artifact@v4
with:
name: src
- name: Set up build
uses: ./.github/actions/setup-build
with:
features: ${{ matrix.bin }} ${{ matrix.shell }} deploy
- name: Build
id: build
continue-on-error: ${{ runner.os == 'Windows' }}
run: make -j 4
- name: Test
if: steps.build.outcome == 'success' && steps.build.conclusion == 'success'
continue-on-error: ${{ runner.os == 'Windows' }}
run: make check
- name: Print executable information
id: check-portability
if: steps.build.outcome == 'success' && steps.build.conclusion == 'success'
continue-on-error: ${{ runner.os == 'Windows' }}
run: |
binname=${{ matrix.bin }}
if [ "${{ runner.os }}" == "Windows" ]; then
binname=$binname.exe
fi
ls -l "sources/$binname"
file "sources/$binname"
if [ "${{ runner.os }}" == "macOS" ]; then
otool -L "sources/$binname"
# Check if brewed/built libraries are statically linked.
if otool -L "sources/$binname" | grep -Eq '/usr/local/opt/|/opt/homebrew/opt/|/form/form/lib/'; then
echo 'Error: unexpected dependency on shared libraries' >&2
exit 1
fi
fi
if [ "${{ runner.os }}" == "Windows" ]; then
ldd "sources/$binname"
# Check if MSYS2/built DLLs are not linked.
if ldd "sources/$binname" | grep -Eq 'msys|mingw|/form/form/lib/'; then
echo 'Error: unexpected dependency on DLLs' >&2
exit 1
fi
fi
./sources/$binname -vv
- name: Upload binary as artifact
if: steps.check-portability.outcome == 'success' && steps.check-portability.conclusion == 'success'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.bin }}-${{ matrix.os }}
path: |
sources/${{ matrix.bin }}
sources/${{ matrix.bin }}.exe
if-no-files-found: error
# Generate the PDF reference manual, e.g., "form-4.2.1-manual.pdf" for v4.2.1.
build-doc-pdf:
name: Build PDF document
needs: build-src
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
sparse-checkout-cone-mode: false
- name: Download tarball
uses: actions/download-artifact@v4
with:
name: src
- name: Set up build
uses: ./.github/actions/setup-build
with:
features: latex
- name: Build PDF file
run: |
distname="${{ env.DISTNAME }}-manual"
echo "distname=$distname" >>"$GITHUB_ENV"
make pdf
mv doc/manual/manual.pdf "$distname.pdf"
- name: Print document information
run: |
ls -l "$distname.pdf"
file "$distname.pdf"
- name: Upload document as artifact
uses: actions/upload-artifact@v4
with:
name: doc-pdf
path: '*.pdf'
if-no-files-found: error
# Generate the HTML reference manual packed as, e.g.,
# "form-4.2.1-manual-html.tar.gz" for v4.2.1.
build-doc-html:
name: Build HTML document
needs: build-src
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
sparse-checkout-cone-mode: false
- name: Download tarball
uses: actions/download-artifact@v4
with:
name: src
- name: Set up build
uses: ./.github/actions/setup-build
with:
features: latex2html
- name: Build HTML files
run: |
distname="${{ env.DISTNAME }}-manual-html"
echo "distname=$distname" >>"$GITHUB_ENV"
make -C doc/manual latex2html
(
cd doc/manual/manual
rm -f images.aux images.idx images.log images.pdf images.pl images.tex internals.pl labels.pl WARNINGS
# Print generated files.
ls -A -C
# Check if there are no unexpected files.
shopt -s nullglob
for f in * .*; do
case "$f" in
index.html|manual.html|manual.css|img*.svg)
;;
*)
echo "Error: unexpected file: $f" >&2
exit 1
;;
esac
done
)
mv doc/manual/manual "$distname"
tar -c "$distname"/* | gzip -c -9 > "$distname.tar.gz"
- name: Print file information
run: |
ls -l "$distname.tar.gz"
file "$distname.tar.gz"
tar -tf "$distname.tar.gz"
- name: Upload file as artifact
uses: actions/upload-artifact@v4
with:
name: doc-html
path: '*.tar.gz'
if-no-files-found: error
# Prepare binaries to be published in GitHub Releases.
# They will be actually delivered when the commit has a tag
# starting with "v" (e.g., v4.2.1).
publish-binaries:
name: Publish binaries to GitHub Releases
needs:
- build-src
- build-bin
- build-doc-pdf
- build-doc-html
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Print all artifacts
run: ls -l -R artifacts
- name: Prepare distributions
run: |
distname=$(basename artifacts/src/*.tar.gz .tar.gz)
mkdir dist
mv artifacts/src/*.tar.gz dist/
mv artifacts/doc-html/*.tar.gz dist/
mv artifacts/doc-pdf/*.pdf dist/
make_tar_gz() {
if compgen -G "artifacts/$2" >/dev/null; then
pkgname=$distname-$1
mkdir "$pkgname"
mv artifacts/$2 "$pkgname"/
chmod +x "$pkgname"/*form*
tar -c "$pkgname"/* | gzip -c -9 >"dist/$pkgname.tar.gz"
rm -rf "$pkgname"
fi
}
make_zip() {
if compgen -G "artifacts/$2" >/dev/null; then
pkgname=$distname-$1
mkdir "$pkgname"
mv artifacts/$2 "$pkgname"/
chmod +x "$pkgname"/*form*
zip -9 "dist/$pkgname.zip" "$pkgname"/*
rm -rf "$pkgname"
fi
}
make_tar_gz x86_64-linux '*-ubuntu-24.04/*form'
make_tar_gz arm64-linux '*-ubuntu-24.04-arm/*form'
make_tar_gz x86_64-osx '*-macos-15-intel/*form'
make_tar_gz arm64-osx '*-macos-14/*form'
make_zip x86_64-windows '*-windows-2022/*form.exe'
- name: Summarize the distributions
run: |
expected_count=8
actual_count=$(find dist -type f | wc -l)
{
echo "Number of files: $actual_count"
echo
echo '| File Name | Size (bytes) |'
echo '| --- | ---: |'
find dist -type f -printf "| %f | %s |\n"
} >>"$GITHUB_STEP_SUMMARY"
if [[ $actual_count -ne $expected_count ]]; then
echo "Error: expected $expected_count files, but found $actual_count." >&2
exit 1
fi
# Upload the distributions as an artifact, regardless of whether
# the commit has a versioning tag. This makes checking and debugging easy.
- name: Upload distributions as artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: |
dist/*.tar.gz
dist/*.zip
dist/*.pdf
if-no-files-found: error
# To prevent the distribution of Windows binaries, uncomment the following lines.
# - name: Delete Windows binaries
# run: rm -fv dist/*windows*
# Publish the distributions to GitHub Releases, only if the commit has
# a versioning tag.
- name: Publish distributions
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.tar.gz
dist/*.zip
dist/*.pdf