Skip to content

Commit 06f3ddd

Browse files
authored
update release flow (#12)
1 parent 745c478 commit 06f3ddd

2 files changed

Lines changed: 110 additions & 37 deletions

File tree

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,65 @@
1-
name: Reusable Release Export
1+
name: Release (Export + Cover)
22

33
on:
4-
workflow_call:
5-
inputs:
6-
content_dir:
7-
required: true
8-
type: string
9-
summary_path:
10-
required: true
11-
type: string
12-
output_basename:
13-
required: false
14-
type: string
15-
default: documentation
4+
release:
5+
types: [published]
6+
workflow_dispatch:
167

178
permissions:
189
contents: write
1910

2011
jobs:
2112
export:
13+
uses: International-Data-Spaces-Association/.github/.github/workflows/reusable-release-export.yml@main
14+
with:
15+
summary_path: summary.md
16+
output_basename: knowledge-base
17+
papersize: a4
18+
margin: 2.5cm
19+
fontsize: 11pt
20+
mainfont: Noto Sans
21+
sansfont: Noto Sans
22+
monofont: Fira Code
23+
# optionally override:
24+
# pandoc_image: ghcr.io/<ORG>/pandoc-latex-fonts:3.9
25+
26+
add-cover-and-publish:
27+
needs: export
2228
runs-on: ubuntu-latest
29+
2330
steps:
24-
- uses: actions/checkout@v4
25-
- uses: actions/checkout@v4
31+
- name: Checkout repository (to access assets/cover.pdf)
32+
uses: actions/checkout@v4
33+
34+
- name: Download export artifacts
35+
uses: actions/download-artifact@v4
2636
with:
27-
repository: International-Data-Spaces-Association/.github
28-
path: _shared
29-
- name: Install Pandoc + TeX
30-
run: |
31-
sudo apt-get update
32-
sudo apt-get install -y pandoc texlive-xetex texlive-fonts-recommended texlive-latex-extra
33-
- name: Assemble
34-
run: |
35-
python3 _shared/scripts/assemble_from_summary.py --summary "${{ inputs.summary_path }}" --out combined.md --fail-on-missing
36-
- name: Build
37+
name: release-export
38+
path: exports
39+
40+
- name: Merge cover + body PDF (create additional artefact)
3741
run: |
38-
TAG="${{ github.event.release.tag_name }}"
39-
BASENAME="${{ inputs.output_basename }}"
40-
pandoc combined.md --from gfm --resource-path=.:"${{ inputs.content_dir }}" --reference-doc=_shared/assets/reference.docx -o "${BASENAME}-${TAG}.docx"
41-
pandoc combined.md --from gfm --resource-path=.:"${{ inputs.content_dir }}" --pdf-engine=xelatex -o "${BASENAME}-${TAG}.pdf"
42-
- name: Upload
42+
python -m pip install --upgrade pip
43+
python -m pip install pypdf
44+
python - <<'PY'
45+
from pypdf import PdfWriter
46+
47+
cover = "assets/cover.pdf"
48+
body = "exports/knowledge-base.pdf"
49+
out = "exports/knowledge-base-with-cover.pdf"
50+
51+
writer = PdfWriter()
52+
writer.append(cover) # cover can be 1 or multiple pages
53+
writer.append(body)
54+
writer.write(out)
55+
print(f"Created {out}")
56+
PY
57+
# pypdf supports merging by appending PDFs via PdfWriter.append() and writing the output. [2](https://bing.com/search?q=material+for+mkdocs+custom+404+page+setup)[3](https://squidfunk.github.io/mkdocs-material/customization/)
58+
59+
- name: Upload release assets (keep ALL artefacts)
4360
uses: softprops/action-gh-release@v2
4461
with:
4562
files: |
46-
${{ inputs.output_basename }}-${{ github.event.release.tag_name }}.pdf
47-
${{ inputs.output_basename }}-${{ github.event.release.tag_name }}.docx
63+
exports/knowledge-base.pdf
64+
exports/knowledge-base-with-cover.pdf
65+
exports/knowledge-base.docx
Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,68 @@
1-
name: Release export
1+
name: Release (Export + Cover)
2+
23
on:
34
release:
4-
types: [ published ]
5+
types: [published]
6+
workflow_dispatch:
7+
58
permissions:
69
contents: write
10+
11+
env:
12+
BASENAME: documentation # <-- this is the directory/basename you mean
13+
EXPORT_DIR: dist # where we download artifacts to
14+
715
jobs:
816
export:
917
uses: International-Data-Spaces-Association/.github/.github/workflows/reusable-release-export.yml@main
1018
with:
11-
content_dir: ${{ vars.CONTENT_DIR }}
12-
summary_path: ${{ vars.SUMMARY_PATH }}
13-
output_basename: ${{ github.event.repository.name }}
19+
summary_path: summary.md
20+
output_basename: documentation # must match BASENAME above
21+
22+
add-cover-and-publish:
23+
needs: export
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout repository (for assets/cover.pdf)
28+
uses: actions/checkout@v4
29+
30+
- name: Download export artifacts
31+
uses: actions/download-artifact@v4
32+
with:
33+
name: release-export
34+
path: ${{ env.EXPORT_DIR }}
35+
36+
- name: Verify expected files exist
37+
run: |
38+
ls -la "${{ env.EXPORT_DIR }}"
39+
test -f "assets/cover.pdf"
40+
test -f "${{ env.EXPORT_DIR }}/${{ env.BASENAME }}.pdf"
41+
test -f "${{ env.EXPORT_DIR }}/${{ env.BASENAME }}.docx"
42+
43+
- name: Merge cover + body PDF (create additional artifact)
44+
run: |
45+
python -m pip install --upgrade pip
46+
python -m pip install pypdf
47+
python - <<'PY'
48+
from pypdf import PdfWriter
49+
50+
cover = "assets/cover.pdf"
51+
body = "${{ env.EXPORT_DIR }}/${{ env.BASENAME }}.pdf"
52+
out = "${{ env.EXPORT_DIR }}/${{ env.BASENAME }}-with-cover.pdf"
53+
54+
writer = PdfWriter()
55+
writer.append(cover) # cover can be 1 or multiple pages
56+
writer.append(body)
57+
writer.write(out)
58+
print(f"Created {out}")
59+
PY
60+
# pypdf merges PDFs by appending inputs with PdfWriter.append() and writing output. [2](https://bing.com/search?q=material+for+mkdocs+custom+404+page+setup)
61+
62+
- name: Upload release assets (keep ALL artifacts)
63+
uses: softprops/action-gh-release@v2
64+
with:
65+
files: |
66+
${{ env.EXPORT_DIR }}/${{ env.BASENAME }}.pdf
67+
${{ env.EXPORT_DIR }}/${{ env.BASENAME }}-with-cover.pdf
68+
${{ env.EXPORT_DIR }}/${{ env.BASENAME }}.docx

0 commit comments

Comments
 (0)