-
Notifications
You must be signed in to change notification settings - Fork 140
396 lines (358 loc) · 13.7 KB
/
deploy.yml
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
name: Deploy
on:
push:
pull_request:
workflow_dispatch:
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: Determine distname
run: |
echo "distname=form-$(./scripts/git-version-gen.sh -r | sed '2q;d' | sed 's/^v//')" >> $GITHUB_ENV
- name: Build tarball distribution
run: |
autoreconf -i
./configure --disable-dependency-tracking --disable-scalar --disable-threaded --disable-native --without-gmp --without-zlib
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:
# To maximize compatibility, we build executables on the oldest
# platforms available.
- {os: ubuntu-20.04, shell: bash, bin: form}
- {os: ubuntu-20.04, shell: bash, bin: tform}
- {os: macos-12, shell: bash, bin: form}
- {os: macos-12, 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 have too many problems.
# We include them in artifacts but not in releases.
# 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-2019, shell: msys2, bin: form}
- {os: windows-2019, shell: msys2, bin: tform}
steps:
- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: libmpfr-dev
version: 1.0
- name: Install dependencies (Windows)
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
make
mingw-w64-x86_64-gcc
mingw-w64-x86_64-gmp
mingw-w64-x86_64-mpfr
mingw-w64-x86_64-zlib
ruby
- name: Download tarball
uses: actions/download-artifact@v4
with:
name: src
- name: Uncompress tarball
run: |
tar -xf *.tar.gz --strip-components 1
rm *.tar.gz
- name: Configure
run: |
opts='--disable-dependency-tracking --disable-scalar --disable-threaded --disable-native --enable-static-link --with-gmp --with-zlib'
case ${{ matrix.bin }} in
form) opts="$opts --enable-scalar";;
tform) opts="$opts --enable-threaded";;
esac
# --static fails on macOS but we want to statically link
# the brewed gmp. The linker supports neither -Wl,-static nor
# -l:libgmp.a to make partial static links possible.
# As a workaround, we make a library directory with libgmp.a
# but without libgmp.dylib so that the linker has to link libgmp.a.
# Note that the Homebrew installation path for Apple Silicon (arm64)
# differs from the one on macOS Intel (x86-64).
mkdir static-lib
if [ "$RUNNER_OS" == "macOS" ]; then
if [ "$RUNNER_ARCH" == "ARM64" ]; then
ln -s /opt/homebrew/opt/gmp/lib/libgmp.a static-lib/libgmp.a
ln -s /opt/homebrew/opt/mpfr/lib/libmpfr.a static-lib/libmpfr.a
# The GMP and MPFR include directories, not located in the usual places,
# must be explicitly appended to the include paths.
export CPATH="/opt/homebrew/opt/gmp/include:/opt/homebrew/opt/mpfr/include:${CPATH:-}"
else
ln -s /usr/local/opt/gmp/lib/libgmp.a static-lib/libgmp.a
ln -s /usr/local/opt/mpfr/lib/libmpfr.a static-lib/libmpfr.a
fi
export LIBRARY_PATH="$(pwd)/static-lib:${LIBRARY_PATH:-}"
opts="$opts --disable-static-link"
fi
if [ "$RUNNER_OS" == "Windows" ]; then
opts="$opts --with-api=windows"
fi
./configure $opts
- name: Build
id: build
continue-on-error: ${{ runner.os == 'Windows' }}
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
if [ "$RUNNER_ARCH" == "ARM64" ]; then
export CPATH="/opt/homebrew/opt/gmp/include:/opt/homebrew/opt/mpfr/include:${CPATH:-}"
fi
export LIBRARY_PATH="$(pwd)/static-lib:${LIBRARY_PATH:-}"
fi
make -j 4
# NOTE: Currently, many tests on Windows miserably fail.
- 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 libraries are statically linked.
if otool -L sources/$binname | grep -q '/usr/local/opt'; then
echo 'Error: failed to statically link brewed libraries' >&2
exit 1
fi
fi
if [ "$RUNNER_OS" == "Windows" ]; then
ldd sources/$binname
# Check if MSYS2 DLLs are not linked.
if ldd sources/$binname | grep -q 'msys'; then
echo 'Error: failed to avoid to link with MSYS2 DLLs' >&2
exit 1
fi
fi
- 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: Download tarball
uses: actions/download-artifact@v4
with:
name: src
- name: Determine distname
run: |
echo "distname=$(basename *.tar.gz .tar.gz)-manual" >> $GITHUB_ENV
- name: Uncompress tarball
run: |
tar -xf *.tar.gz --strip-components 1
rm *.tar.gz
# Currently, cache-apt-pkgs-action doesn't work for LaTeX.
# https://github.com/awalsh128/cache-apt-pkgs-action/issues/57
# - name: Install LaTeX2HTML
# uses: awalsh128/cache-apt-pkgs-action@v1
# with:
# packages: latex2html # shares the same cache with build-doc-html
# version: 1.0
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install texlive-latex-extra
- name: Build PDF file
run: |
autoreconf -i
./configure --disable-dependency-tracking --disable-scalar --disable-threaded --disable-native --without-gmp --without-zlib
make pdf
cp 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: Download tarball
uses: actions/download-artifact@v4
with:
name: src
- name: Determine distname
run: |
echo "distname=$(basename *.tar.gz .tar.gz)-manual-html" >> $GITHUB_ENV
- name: Uncompress tarball
run: |
tar -xf *.tar.gz --strip-components 1
rm *.tar.gz
# Currently, cache-apt-pkgs-action doesn't work for LaTeX.
# https://github.com/awalsh128/cache-apt-pkgs-action/issues/57
# - name: Install LaTeX2HTML
# uses: awalsh128/cache-apt-pkgs-action@v1
# with:
# packages: latex2html # shares the same cache with build-doc-pdf
# version: 1.0
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install latex2html
- name: Build HTML files
run: |
autoreconf -i
./configure --disable-dependency-tracking --disable-scalar --disable-threaded --disable-native --without-gmp --without-zlib
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
)
cp -r 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: Determine distname
run: |
echo "distname=$(basename artifacts/src/*.tar.gz .tar.gz)" >> $GITHUB_ENV
- name: Print all artifacts
run: ls -l -R artifacts
- name: Prepare distributions
run: |
mkdir dist
mv artifacts/src/*.tar.gz dist
mv artifacts/doc-html/*.tar.gz dist
mv artifacts/doc-pdf/*.pdf dist
if ls artifacts/*-ubuntu-*/*form >/dev/null 2>&1; then
pkgname=$distname-x86_64-linux
mkdir $pkgname
mv artifacts/*-ubuntu-*/*form $pkgname
chmod +x $pkgname/*form
tar -c $pkgname/* | gzip -c -9 >dist/$pkgname.tar.gz
rm -rf $pkgname
fi
if ls artifacts/*-macos-12/*form >/dev/null 2>&1; then
pkgname=$distname-x86_64-osx
mkdir $pkgname
mv artifacts/*-macos-12/*form $pkgname
chmod +x $pkgname/*form
tar -c $pkgname/* | gzip -c -9 >dist/$pkgname.tar.gz
rm -rf $pkgname
fi
if ls artifacts/*-macos-14/*form >/dev/null 2>&1; then
pkgname=$distname-arm64-osx
mkdir $pkgname
mv artifacts/*-macos-14/*form $pkgname
chmod +x $pkgname/*form
tar -c $pkgname/* | gzip -c -9 >dist/$pkgname.tar.gz
rm -rf $pkgname
fi
# Do not include Windows binaries into the distribution, for now.
#
# if ls artifacts/*-windows-*/*form.exe >/dev/null 2>&1; then
# pkgname=$distname-x86_64-windows
# mkdir $pkgname
# mv artifacts/*-windows-*/*form.exe $pkgname
# chmod +x $pkgname/*form.exe
# # Zip may be more popular than tar.gz for Windows(?)
# # tar -c $pkgname/* | gzip -c -9 >dist/$pkgname.tar.gz
# zip -9 dist/$pkgname.zip $pkgname/*
# rm -rf $pkgname
# fi
- name: Print distributions
run: ls -l dist
# 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@v1
with:
files: |
dist/*.tar.gz
dist/*.zip
dist/*.pdf
# 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