forked from wdw21/songbook
-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (168 loc) · 7.31 KB
/
generate.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
name: Generate Songbook Artifacts
run-name: ${{ github.actor }} is generating artifacts
on:
workflow_dispatch:
inputs:
epub:
description: 'Generate epub'
required: false
type: boolean
default: true
pdf:
description: 'Generate pdf'
required: false
type: boolean
default: true
html:
description: 'Generate htmls'
required: false
type: boolean
default: true
release:
description: 'Create release'
required: false
type: boolean
default: true
workflow_call:
inputs:
epub:
description: 'Generate epub'
required: false
type: boolean
default: true
pdf:
description: 'Generate pdf'
required: false
type: boolean
default: true
html:
description: 'Generate htmls'
required: false
type: boolean
default: true
release:
description: 'Create release'
required: false
type: boolean
default: true
permissions:
contents: write
jobs:
Generate-artifacts:
runs-on: ubuntu-latest
steps:
- run: export TZ="Europe/Warsaw"
- run: echo "release_name=$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_ENV
- if: ${{ inputs.pdf }}
run: echo "Generating a songbook PDF triggered by ${{ github.event_name }} release:${{ env.release_name }}"
- if: ${{ inputs.epub }}
run: echo "Generating a songbook EPUB triggered by ${{ github.event_name }} release:${{ env.release_name }}"
- if: ${{ inputs.html }}
run: echo "Generating a ZIP with songs in html triggered by ${{ github.event_name }} release:${{ env.release_name }}"
- name: Check out repository code
uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies
- run: sudo apt-get install python3-lxml
- run: pip3 install -r ${{ github.workspace }}/requirements.txt
- run: pip install lxml
- if: ${{ inputs.pdf }}
run: sudo apt-get install texlive texlive-latex-extra texlive-lang-polish
- if: ${{ inputs.pdf }}
run: cd ${{ github.workspace }} && chmod 755 ./render_pdf.sh && ./render_pdf.sh songbook a5 "Śpiewnik $(date +'%Y-%m-%d')" songs/*.xml
- if: ${{ inputs.pdf }}
run: mv ${{ github.workspace }}/build/songs_tex/output.pdf ${{ github.workspace }}/build/songbook_${{ env.release_name }}_a5.pdf
- if: ${{ inputs.pdf }}
run: cd ${{ github.workspace }} && ./render_pdf.sh songbook a4 "Śpiewnik $(date +'%Y-%m-%d')" songs/*.xml
- if: ${{ inputs.pdf }}
run: mv ${{ github.workspace }}/build/songs_tex/output.pdf ${{ github.workspace }}/build/songbook_${{ env.release_name }}_a4.pdf
- name: Upload PDFs
if: ${{ inputs.pdf }}
uses: actions/upload-artifact@v3
with:
name: songbooks
path: ${{ github.workspace }}/build/*.pdf
- name: Create Release
id: create_release
if: ${{ inputs.release }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ env.release_name }}
draft: true
prerelease: true
- name: Upload PDF_A4 to release
if: ${{ inputs.pdf && inputs.release }}
id: upload-release-asset_pdf_a4
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ github.workspace }}/build/songbook_${{ env.release_name }}_a4.pdf
asset_name: songbook_${{ env.release_name }}_a4.pdf
asset_content_type: application/pdf
- name: Upload PDF_A5 to release
if: ${{ inputs.pdf && inputs.release }}
id: upload-release-asset_pdf_a5
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/build/songbook_${{ env.release_name }}_a5.pdf
asset_name: songbook_${{ env.release_name }}_a5.pdf
asset_content_type: application/pdf
#generating epub from here
- if: ${{ inputs.epub }}
run: cd ${{ github.workspace }} && chmod 755 ./render_epub.sh && ./render_epub.sh
- if: ${{ inputs.epub }}
run: mv ${{ github.workspace }}/build/spiewnik.epub ${{ github.workspace }}/build/songbook_${{ env.release_name }}.epub
- if: ${{ inputs.epub }}
run: sudo apt-get install epubcheck
- if: ${{ inputs.epub }}
run: epubcheck ${{ github.workspace }}/build/songbook_${{ env.release_name }}.epub
- name: Upload EPUBs
if: ${{ inputs.epub }}
uses: actions/upload-artifact@v3
with:
name: songbooks
path: ${{ github.workspace }}/build/*.epub
- name: Upload epub to release
if: ${{ inputs.epub && inputs.release }}
id: upload-release-asset_epub
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ github.workspace }}/build/songbook_${{ env.release_name }}.epub
asset_name: songbook_${{ env.release_name }}.epub
asset_content_type: application/epub+zip
#generating zip from here
- if: ${{ inputs.html }}
run: cd ${{ github.workspace }} && chmod 755 ./render_htmls.sh && ./render_htmls.sh
- if: ${{ inputs.html }}
run: mv ${{ github.workspace }}/build/songs_html.zip ${{ github.workspace }}/build/songs_html_${{ env.release_name }}.zip
- name: Upload HTMLs
if: ${{ inputs.html }}
uses: actions/upload-artifact@v3
with:
name: songbooks
path: ${{ github.workspace }}/build/*.zip
- name: Upload htmls to release
if: ${{ inputs.html && inputs.release }}
id: upload-release-asset_htmls
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ github.workspace }}/build/songs_html_${{ env.release_name }}.zip
asset_name: songbook_${{ env.release_name }}.zip
asset_content_type: application/zip
- run: echo "DONE"