-
Notifications
You must be signed in to change notification settings - Fork 84
410 lines (408 loc) · 15.5 KB
/
build-documentation-and-executables.yaml
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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
name: build latexindent executables and documentation and upload to release page
# PURPOSE:
#
# 1. build latexindent.pdf
# 2. build latexindent.exe using PAR::Packer on Windows Perl
# 3. build latexindent-linux using PAR::Packer on Ubuntu
# 4. build latexindent-macos using PAR::Packer on macOS
# 5. create release
# 6. upload latexindent.zip to ctan
#
# Note: this action only runs on *each release*, i.e. when tags are pushed
#
on:
push:
tags:
- '*'
jobs:
#-------------------------------------------------------------------------
#
# 1. latexindent.pdf
#
build-latexindent-doc-pdf:
name: 'documentation latexindent.pdf creation'
runs-on: ubuntu-latest
steps:
- name: load the "base actions/checkout" so as to access latexindent.pl
uses: actions/checkout@v4
- name: installing texlive full
uses: xu-cheng/texlive-action@v2
with:
scheme: full
run: |
github_sha_short=$(echo $GITHUB_SHA | cut -c1-7)
github_branch="main"
github_release=$(echo ${{ github.ref }}|cut -d'/' -f 3)
sed -i.bak s/\\\\gitAbbrevHash/$github_sha_short/ documentation/latexindent.tex
sed -i.bak s/\\\\gitBranch/main/ documentation/latexindent.tex
sed -i.bak s/\\\\gitRel/$github_release/ documentation/*.tex
sed -i.bak "s|\\\\gitAuthorDate|$(date +'%Y-%m-%d')|g" documentation/latexindent.tex
cd documentation
pdflatex latexindent
makeindex -s latexindent.ist -t latexindent.ilg latexindent.idx -o latexindent.ind
bibtex latexindent
pdflatex --interaction=batchmode latexindent
pdflatex --interaction=batchmode latexindent
pdflatex --interaction=batchmode latexindent
cd ..
mkdir -p target/release
mv documentation/latexindent.pdf target/release
#
# https://stackoverflow.com/questions/57498605/github-actions-share-workspace-artifacts-between-jobs
#
- name: upload latexindent.pdf as artifact for zipping
uses: actions/upload-artifact@master
with:
name: latexindent.pdf
path: target/release
#-------------------------------------------------------------------------
#
# 2. latexindent.exe
#
build-windows-exe:
name: 'create Windows executable latexindent.exe using Windows Perl (latest) on Windows'
runs-on: 'windows-latest'
steps:
#
# checkout github.com/cmhughes/latexindent.pl
# https://github.com/actions/checkout
#
- name: load the "base actions/checkout" so as to access latexindent.pl
uses: actions/checkout@v4
#
# https://github.com/marketplace/actions/setup-perl-environment
#
- name: install Perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: 'latest'
- name: install Perl modules using cpan
run: |
wmic os get osarchitecture
cpanm -f PAR::Packer
cpanm YAML::Tiny
cpanm File::HomeDir
cpanm Unicode::GCString
cpanm --force Win32::Unicode::File
cpanm --force Win32::API
- name: preparations for PAR packer
run: |
sed -i'.bak' -r 's,eval\s\"use\sUnicode::GCString\"\sif\s\$switches\{GCString\},use Unicode::GCString,' latexindent.pl
#
# https://metacpan.org/pod/pp
# https://github.com/plk/biber/blob/dev/dist/MSWIN64/build.bat
#
- name: create latexindent.exe using PAR Packer
shell: cmd
run: |
set PAR_VERBATIM=1
pp -T -M Win32::Unicode --addfile="defaultSettings.yaml;lib/LatexIndent/defaultSettings.yaml" --cachedeps=scancache --output latexindent.exe latexindent.pl
- name: move latexindent.exe to release directory
run: |
mkdir -p target/release
mv latexindent.exe target/release
- name: tiny test of latexindent.exe from release directory
run: |
cd target/release
./latexindent.exe --help
./latexindent.exe ../../test-cases/environments/environments-simple-nested.tex
#
# https://stackoverflow.com/questions/57498605/github-actions-share-workspace-artifacts-between-jobs
#
- name: upload latexindent.exe as artifact for zipping
uses: actions/upload-artifact@master
with:
name: latexindent.exe
path: target/release
#-------------------------------------------------------------------------
#
# 3. Linux latexindent
#
build-linux-executable:
name: 'create Linux executable latexindent'
runs-on: 'ubuntu-latest'
steps:
#
# checkout github.com/cmhughes/latexindent.pl
# https://github.com/actions/checkout
#
- name: load the "base actions/checkout" so as to access latexindent.pl
uses: actions/checkout@v4
#
# https://github.com/marketplace/actions/setup-perl-environment
#
- name: install Perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: 'latest'
- name: install Perl modules using cpan
run: |
cpanm -f PAR::Packer
cpanm YAML::Tiny
cpanm File::HomeDir
cpanm Unicode::GCString
- name: preparations for PAR packer
run: |
sed -i'.bak' -r 's,eval\s\"use\sUnicode::GCString\"\sif\s\$switches\{GCString\},use Unicode::GCString,' latexindent.pl
#
# https://metacpan.org/pod/pp
# https://github.com/plk/biber/blob/dev/dist/linux-musl_x86_64/build.sh
#
- name: create Linux executable latexindent using PAR Packer
run: |
export PAR_VERBATIM=1
pp --addfile="defaultSettings.yaml;lib/LatexIndent/defaultSettings.yaml" --cachedeps=scancache --output latexindent-linux latexindent.pl
- name: move Linux latexindent to release directory
run: |
mkdir -p target/release
mv latexindent-linux target/release
- name: tiny test of latexindent from release directory
run: |
cd target/release
./latexindent-linux --help
./latexindent-linux ../../test-cases/environments/environments-simple-nested.tex
#
# https://stackoverflow.com/questions/57498605/github-actions-share-workspace-artifacts-between-jobs
#
- name: upload latexindent-linux as artifact for zipping
uses: actions/upload-artifact@master
with:
name: latexindent-linux
path: target/release
#-------------------------------------------------------------------------
#
# 4. MacOS latexindent
#
build-macos-executable:
name: 'create MacOS executable latexindent'
runs-on: 'macos-latest'
steps:
#
# checkout github.com/cmhughes/latexindent.pl
# https://github.com/actions/checkout
#
- name: load the "base actions/checkout" so as to access latexindent.pl
uses: actions/checkout@v4
#
# https://github.com/marketplace/actions/setup-perl-environment
#
- name: install Perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: 'latest'
- name: install Perl modules using cpan
run: |
cpanm -f PAR::Packer
cpanm YAML::Tiny
cpanm -f File::HomeDir
cpanm Unicode::GCString
- name: preparations for PAR packer
run: |
sed -i'.bak' -r 's,eval\s\"use\sUnicode::GCString\"\sif\s\$switches\{GCString\},use Unicode::GCString,' latexindent.pl
#
# https://metacpan.org/pod/pp
# https://github.com/plk/biber/blob/dev/dist/linux-musl_x86_64/build.sh
#
- name: create MacOS executable latexindent using PAR Packer
run: |
export PAR_VERBATIM=1
pp --addfile="defaultSettings.yaml;lib/LatexIndent/defaultSettings.yaml" --cachedeps=scancache --output latexindent-macos latexindent.pl
- name: move MacOS latexindent to release directory
run: |
mkdir -p target/release
mv latexindent-macos target/release
- name: tiny test of latexindent from release directory
run: |
cd target/release
./latexindent-macos --help
./latexindent-macos ../../test-cases/environments/environments-simple-nested.tex
#
# https://stackoverflow.com/questions/57498605/github-actions-share-workspace-artifacts-between-jobs
#
- name: upload latexindent-macos as artifact for zipping
uses: actions/upload-artifact@master
with:
name: latexindent-macos
path: target/release
#=========================================================================
#
# latexindent.zip
#
zip-files:
name: 'create latexindent.zip'
needs: [build-latexindent-doc-pdf, build-windows-exe, build-linux-executable, build-macos-executable]
runs-on: ubuntu-latest
steps:
- name: Loading the "base actions/checkout" so as to access the repository latexindent.pl
uses: actions/checkout@v4
- name: copy source files from repository into temporary folder
run: |
mkdir latexindent
cp latexindent.pl latexindent/
cp defaultSettings.yaml latexindent/
mkdir latexindent/LatexIndent/
cp LatexIndent/*.pm latexindent/LatexIndent/
cp helper-scripts/latexindent-module-installer.pl latexindent/
mkdir latexindent/bin/
mkdir latexindent/bin/windows
mkdir latexindent/bin/linux
mkdir latexindent/bin/macos
- name: copy documentation files from repository into temporary folder
run: |
mkdir latexindent/documentation/
cp documentation/*.png latexindent/documentation/
cp documentation/readme.txt latexindent/README
cp documentation/*.json latexindent/documentation/
cp documentation/*.bib latexindent/documentation/
cd documentation
egrep -i --color=auto '\\input' latexindent.tex > tmp.log
sed -i'.bak' -e 's/\\input{//' tmp.log
sed -i'.bak' -e 's/}//' tmp.log
awk '/sec-introduction/,EOF' tmp.log> tmp1.log
mapfile -t filesToUpdate < tmp1.log
sed -i.bak '/\\begin{document}/,$d' latexindent.tex
echo '\begin{document}' >> latexindent.tex
for file in "${filesToUpdate[@]}"; do cat ${file}.tex>>latexindent.tex; done
echo '\end{document}' >> latexindent.tex
cd ..
cp documentation/latexindent.tex latexindent/documentation/
#
# download artifacts
#
- name: download Windows executable latexindent.exe
uses: actions/download-artifact@master
with:
name: latexindent.exe
path: latexindent/bin/windows
- name: download Linux executable latexindent
uses: actions/download-artifact@master
with:
name: latexindent-linux
path: latexindent/bin/linux
- name: download MacOS executable latexindent
uses: actions/download-artifact@master
with:
name: latexindent-macos
path: latexindent/bin/macos
- name: download documentation file latexindent.pdf
uses: actions/download-artifact@master
with:
name: latexindent.pdf
path: latexindent/documentation/
#
# zip file creation and upload
#
- name: create latexindent.zip
run: |
mv latexindent/bin/linux/latexindent-linux latexindent/bin/linux/latexindent
mv latexindent/bin/macos/latexindent-macos latexindent/bin/macos/latexindent
zip -r latexindent.zip latexindent/
mkdir -p target/release
cp latexindent.zip target/release
- name: graphical representation of latexindent directory
run: |
find latexindent -print | sed -e 's;[^/]*/;|-- ;g;s;-- |; |;g'
- name: upload latexindent.zip as artifact
uses: actions/upload-artifact@master
with:
name: latexindent.zip
path: target/release
#=========================================================================
#
# 5. create release
#
create-release:
name: 'latexindent create release'
runs-on: ubuntu-latest
needs: [zip-files]
steps:
- name: Checkout
uses: actions/checkout@v4
#
# download artifacts
#
- name: download Windows executable latexindent.exe
uses: actions/download-artifact@master
with:
name: latexindent.exe
path: for-release
- name: download Linux executable latexindent
uses: actions/download-artifact@master
with:
name: latexindent-linux
path: for-release
- name: download MacOS executable latexindent
uses: actions/download-artifact@master
with:
name: latexindent-macos
path: for-release
- name: download documentation file latexindent.zip
uses: actions/download-artifact@master
with:
name: latexindent.zip
path: for-release
#
# body of release is read from documentation/changelog.md
#
- name: get changelog.md information
run: |
csplit documentation/changelog.md '/^\#\#/' '{*}' -f cmh # split changelog at '##'
sed -i.bak s/\#\#.*\// cmh01 #
mv cmh01 latexindent-release.md
cat latexindent-release.md
- name: latexindent.pl release
uses: softprops/action-gh-release@v2
with:
body_path: latexindent-release.md
files: |
for-release/latexindent.zip
for-release/latexindent.exe
for-release/latexindent-linux
for-release/latexindent-macos
#=========================================================================
#
# 6. ctan latexindent.zip upload
#
ctan-upload:
name: 'upload latexindent.zip to ctan'
runs-on: ubuntu-latest
needs: [zip-files]
steps:
- name: get latexindent version number
id: labeller
run: |
echo "version=$(echo ${{ github.ref }}|cut -d'/' -f 3)" >> $GITHUB_OUTPUT
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Loading the "base actions/checkout" so as to access the repository latexindent.pl
uses: actions/checkout@v4
- name: get latexindent announcement text from changelog.md
id: announcement
run: |
egrep -i --color=auto '<!-- announcement:' documentation/changelog.md > tmp.log
sed -i.bak s/\<\!\-\-\ announcement:\ // tmp.log
sed -i.bak s/-\-\>// tmp.log
echo "announcementtext=$(cat tmp.log)" >> $GITHUB_OUTPUT
- name: download latexindent.zip
uses: actions/download-artifact@master
with:
name: latexindent.zip
path: for-ctan
#
# https://github.com/paolobrasolin/ctan-submit-action
#
- name: CTAN submit UPLOAD
uses: paolobrasolin/ctan-submit-action@v1
with:
# IMPORTANT, options are:
# action: validate
# action: upload
action: upload
file_path: for-ctan/latexindent.zip
fields: |
update: "true"
pkg: latexindent
version: "${{ steps.labeller.outputs.version }} ${{ steps.labeller.outputs.date }}"
author: Chris Hughes
email: [email protected]
uploader: Chris Hughes
announcement: "${{ steps.announcement.outputs.announcementtext}}, full details at https://github.com/cmhughes/latexindent.pl/releases/tag/${{ steps.labeller.outputs.version }}"