-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
107 lines (106 loc) · 2.95 KB
/
action.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
---
name: 'Build ebooks'
description: 'Generic workflow for Sasanarakkha digital books'
inputs:
verbose_latex:
description: 'When true print LaTeX output to log'
required: true
default: false
build_pdf:
required: true
default: true
build_epub:
required: true
default: true
build_azw3:
required: true
default: true
build_mobi:
required: true
default: true
validate_epub:
required: true
default: true
optimize_epub:
required: true
default: true
upload_artifacts:
required: true
default: true
outputs:
release_tag:
value: ${{ steps.tag.release_tag }}
release_name:
value: ${{ steps.tag.release_name }}
runs:
using: "composite"
steps:
- name: Sets env vars for release
run: echo "VERBOSE_LATEX=true" >> $GITHUB_ENV
shell: bash
if: always() && FromJSON(inputs.verbose_latex) # FromJSON to cast string to bool
- name: Actions checkout
uses: actions/checkout@v3
if: always()
- name: Check ref
run: |
ls --directory .git/
cat ".git/${GITHUB_REF}"
shell: bash
if: always()
- name: Build PDF
run: |
if [ -n "$VERBOSE_LATEX" ]; then
make pdf2x
else
make pdf2x > /dev/null
fi
shell: bash
if: always() && FromJSON(inputs.build_pdf)
- name: Build EPUB
run: make epub
shell: bash
if: always() && FromJSON(inputs.build_epub)
- name: Validate EPUB
run: make validate
shell: bash
if: always() && FromJSON(inputs.validate_epub)
- name: Optimize EPUB
run: make optimize
shell: bash
if: always() && FromJSON(inputs.optimize_epub)
- name: Build Mobipocket
run: make mobi
shell: bash
if: always() && FromJSON(inputs.build_mobi)
- name: Build AZW3
run: make azw3
shell: bash
if: always() && FromJSON(inputs.build_azw3)
- name: Normalize filenames
run: |
for f in build/*; do
dst="$(python3 -m unidecode -c "$f")"
[[ "$f" != "$dst" ]] && mv "$f" "$dst"
done
rename --verbose --filename 's/\\//g' build/*
rename --verbose --filename 's/\s/_/g' build/*
shell: bash
if: always()
- name: Generate release tag
id: tag
run: |
echo "release_tag=build_$(date +'%d.%m.%Y_%H-%M' --utc)" >> $GITHUB_OUTPUT
echo "release_name=Build $(date +'%d.%m.%Y %H:%M' --utc) UTC" >> $GITHUB_OUTPUT
shell: bash
if: always() && FromJSON(inputs.upload_artifacts)
- name: Upload release assets
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag.outputs.release_tag }}
name: ${{ steps.tag.outputs.release_name }}
body: Automatically built documents
artifacts: "build/*.pdf,build/*.epub,build/*.mobi,build/*.azw3"
removeArtifacts: true
artifactErrorsFailBuild: true
if: always() && FromJSON(inputs.upload_artifacts)