Skip to content

Commit 140e229

Browse files
committed
Add complete EPUB generation system with GitHub Actions
- Add automated EPUB build and publish workflow - Include all 21 chapters covering complete documentation - Add dynamic cover generation with SVG to PNG conversion - Support for cross-platform builds (Ubuntu, macOS, Windows) - Automated releases with proper versioning and changelog - Comprehensive documentation and implementation guides - Local build scripts with Pandoc integration - PDF generation support alongside EPUB format
1 parent 686c942 commit 140e229

31 files changed

+9278
-0
lines changed
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
name: Build and Publish EPUB
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
branches: [ main, master ]
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: 'Version override (optional)'
14+
required: false
15+
type: string
16+
17+
jobs:
18+
build-epub:
19+
name: Build EPUB Documentation
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0 # Get full history for version info
27+
28+
- name: Setup Pandoc
29+
uses: pandoc/actions/setup@v1
30+
with:
31+
version: '3.5' # Use specific version for consistency
32+
33+
- name: Cache Pandoc packages
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.cabal/packages
37+
key: ${{ runner.os }}-pandoc-${{ hashFiles('**/cabal.project') }}
38+
restore-keys: |
39+
${{ runner.os }}-pandoc-
40+
41+
- name: Install additional dependencies
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y \
45+
texlive-latex-base \
46+
texlive-fonts-recommended \
47+
texlive-latex-extra \
48+
texlive-xetex \
49+
librsvg2-bin \
50+
libcairo2-dev \
51+
libpango1.0-dev \
52+
libgdk-pixbuf2.0-dev \
53+
libffi-dev \
54+
libxml2-dev
55+
56+
- name: Determine version
57+
id: version
58+
run: |
59+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.version }}" ]]; then
60+
VERSION="${{ github.event.inputs.version }}"
61+
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
62+
VERSION="${{ github.ref_name }}"
63+
else
64+
VERSION="$(date +%Y%m%d)-$(git rev-parse --short HEAD)"
65+
fi
66+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
67+
echo "Building version: $VERSION"
68+
69+
- name: Make scripts executable
70+
run: chmod +x scripts/*.sh
71+
72+
- name: Generate EPUB content
73+
run: |
74+
./scripts/generate-epub-content.sh "${{ steps.version.outputs.VERSION }}"
75+
76+
- name: Build EPUB
77+
run: |
78+
./scripts/build-epub.sh "${{ steps.version.outputs.VERSION }}"
79+
80+
- name: Verify EPUB
81+
run: |
82+
# Check if EPUB was created
83+
if [ ! -f "open-code-agents-${{ steps.version.outputs.VERSION }}.epub" ]; then
84+
echo "❌ EPUB file not found"
85+
exit 1
86+
fi
87+
88+
# Check EPUB file size
89+
EPUB_SIZE=$(stat -c%s "open-code-agents-${{ steps.version.outputs.VERSION }}.epub")
90+
echo "📊 EPUB size: $EPUB_SIZE bytes"
91+
92+
# Validate EPUB structure (basic check)
93+
if command -v zipinfo &> /dev/null; then
94+
echo "📋 EPUB contents:"
95+
zipinfo -1 "open-code-agents-${{ steps.version.outputs.VERSION }}.epub" | head -20
96+
fi
97+
98+
- name: Upload build artifacts
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: epub-artifacts
102+
path: |
103+
*.epub
104+
*.pdf
105+
retention-days: 30
106+
if-no-files-found: warn
107+
108+
- name: Generate release notes
109+
if: startsWith(github.ref, 'refs/tags/')
110+
id: release-notes
111+
run: |
112+
# Generate changelog from git commits since last tag
113+
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
114+
115+
if [ -n "$LAST_TAG" ]; then
116+
echo "## Changes since $LAST_TAG" > release_notes.md
117+
echo "" >> release_notes.md
118+
git log --pretty=format:"- %s (%h)" $LAST_TAG..HEAD >> release_notes.md
119+
else
120+
echo "## Initial Release" > release_notes.md
121+
echo "" >> release_notes.md
122+
echo "First release of Open Code Agents documentation." >> release_notes.md
123+
fi
124+
125+
echo "📚 EPUB documentation for Open Code Agents" >> release_notes.md
126+
echo "" >> release_notes.md
127+
echo "### Features:" >> release_notes.md
128+
echo "- Complete guide to AI-powered development workflows" >> release_notes.md
129+
echo "- Detailed agent documentation" >> release_notes.md
130+
echo "- Installation and setup instructions" >> release_notes.md
131+
echo "- Best practices and troubleshooting" >> release_notes.md
132+
133+
# Add file info
134+
echo "" >> release_notes.md
135+
echo "### Files:" >> release_notes.md
136+
echo "- \`open-code-agents-${{ steps.version.outputs.VERSION }}.epub\` - EPUB format for e-readers" >> release_notes.md
137+
138+
if [ -f "open-code-agents-${{ steps.version.outputs.VERSION }}.pdf" ]; then
139+
echo "- \`open-code-agents-${{ steps.version.outputs.VERSION }}.pdf\` - PDF format for reading" >> release_notes.md
140+
fi
141+
142+
cat release_notes.md
143+
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
144+
cat release_notes.md >> $GITHUB_OUTPUT
145+
echo "EOF" >> $GITHUB_OUTPUT
146+
147+
- name: Create Release
148+
if: startsWith(github.ref, 'refs/tags/')
149+
uses: softprops/action-gh-release@v2
150+
with:
151+
files: |
152+
open-code-agents-${{ steps.version.outputs.VERSION }}.epub
153+
open-code-agents-latest.epub
154+
open-code-agents-${{ steps.version.outputs.VERSION }}.pdf
155+
name: Open Code Agents Documentation ${{ steps.version.outputs.VERSION }}
156+
body: ${{ steps.release-notes.outputs.RELEASE_NOTES }}
157+
draft: false
158+
prerelease: contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc')
159+
generate_release_notes: true
160+
make_latest: true
161+
env:
162+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163+
164+
- name: Update GitHub Pages
165+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
166+
uses: peaceiris/actions-gh-pages@v4
167+
with:
168+
github_token: ${{ secrets.GITHUB_TOKEN }}
169+
publish_dir: ./
170+
publish_branch: gh-pages
171+
keep_files: |
172+
open-code-agents-latest.epub
173+
*.pdf
174+
allow_empty_commit: false
175+
force_orphan: true
176+
177+
# Job to build on other platforms for consistency
178+
build-cross-platform:
179+
name: Cross-platform Build
180+
runs-on: ${{ matrix.os }}
181+
needs: build-epub
182+
if: startsWith(github.ref, 'refs/tags/')
183+
184+
strategy:
185+
matrix:
186+
os: [macos-latest, windows-latest]
187+
188+
steps:
189+
- name: Checkout repository
190+
uses: actions/checkout@v4
191+
192+
- name: Setup Pandoc (macOS)
193+
if: runner.os == 'macOS'
194+
run: |
195+
brew install pandoc librsvg
196+
197+
- name: Setup Pandoc (Windows)
198+
if: runner.os == 'Windows'
199+
run: |
200+
choco install pandoc
201+
202+
- name: Determine version
203+
id: version
204+
run: |
205+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
206+
VERSION="${{ github.ref_name }}"
207+
else
208+
VERSION="$(date +%Y%m%d)-dev"
209+
fi
210+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
211+
212+
- name: Make scripts executable
213+
if: runner.os != 'Windows'
214+
run: chmod +x scripts/*.sh
215+
216+
- name: Generate EPUB content
217+
run: |
218+
if [ "${{ runner.os }}" = "Windows" ]; then
219+
bash scripts/generate-epub-content.sh "${{ steps.version.outputs.VERSION }}"
220+
else
221+
./scripts/generate-epub-content.sh "${{ steps.version.outputs.VERSION }}"
222+
fi
223+
224+
- name: Build EPUB
225+
run: |
226+
if [ "${{ runner.os }}" = "Windows" ]; then
227+
bash scripts/build-epub.sh "${{ steps.version.outputs.VERSION }}"
228+
else
229+
./scripts/build-epub.sh "${{ steps.version.outputs.VERSION }}"
230+
fi
231+
232+
- name: Upload cross-platform artifacts
233+
uses: actions/upload-artifact@v4
234+
with:
235+
name: epub-${{ runner.os }}
236+
path: |
237+
*.epub
238+
*.pdf
239+
retention-days: 7

0 commit comments

Comments
 (0)