mirror of
https://github.com/luongnv89/claude-howto.git
synced 2026-06-01 10:31:33 +02:00
feat(release): build and publish EPUB artifacts per language (#54)
Extend the release workflow to build separate EPUB artifacts for en, vi, and zh in parallel via a matrix job, then publish all built files under a single GitHub Release. Using fail-fast: false so a failure in one language does not block releasing the others. Also refactor build_epub.py to drive language-specific paths, filenames, and titles from a mapping, and add zh support (title/subtitle + choice).
This commit is contained in:
@@ -7,9 +7,14 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
name: Build EPUB (${{ matrix.lang }})
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
strategy:
|
||||||
contents: write
|
# Don't cancel other languages if one fails — we still want to release
|
||||||
|
# whichever languages built successfully.
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
lang: [en, vi, zh]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -25,11 +30,51 @@ jobs:
|
|||||||
- name: Install Mermaid CLI
|
- name: Install Mermaid CLI
|
||||||
run: npm install -g @mermaid-js/mermaid-cli
|
run: npm install -g @mermaid-js/mermaid-cli
|
||||||
|
|
||||||
|
- name: Install Python dependencies
|
||||||
|
run: |
|
||||||
|
uv venv
|
||||||
|
uv pip install -r scripts/requirements-dev.txt
|
||||||
|
|
||||||
- name: Build EPUB
|
- name: Build EPUB
|
||||||
run: uv run scripts/build_epub.py
|
run: |
|
||||||
|
echo '{"args":["--no-sandbox","--disable-setuid-sandbox"]}' > /tmp/puppeteer-ci.json
|
||||||
|
uv run scripts/build_epub.py \
|
||||||
|
--lang ${{ matrix.lang }} \
|
||||||
|
--puppeteer-config /tmp/puppeteer-ci.json
|
||||||
|
|
||||||
|
- name: Upload EPUB artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: epub-${{ matrix.lang }}
|
||||||
|
path: claude-howto-guide*.epub
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 7
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: Publish GitHub Release
|
||||||
|
needs: build
|
||||||
|
# Release even if some language builds failed — we still publish the
|
||||||
|
# artifacts that did build. `needs.build.result != 'cancelled'` guards
|
||||||
|
# against manually cancelled runs.
|
||||||
|
if: ${{ always() && needs.build.result != 'cancelled' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download all EPUB artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
pattern: epub-*
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: List built artifacts
|
||||||
|
run: ls -lh dist/
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
files: claude-howto-guide.epub
|
files: dist/*.epub
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
fail_on_unmatched_files: true
|
||||||
|
|||||||
+17
-13
@@ -113,6 +113,8 @@ class EPUBConfig:
|
|||||||
vi_subtitle: str = "Làm chủ Claude Code trong một cuối tuần"
|
vi_subtitle: str = "Làm chủ Claude Code trong một cuối tuần"
|
||||||
en_title: str = "Claude Code How-To Guide"
|
en_title: str = "Claude Code How-To Guide"
|
||||||
en_subtitle: str = "Master Claude Code in a Weekend"
|
en_subtitle: str = "Master Claude Code in a Weekend"
|
||||||
|
zh_title: str = "Claude Code 使用指南"
|
||||||
|
zh_subtitle: str = "一个周末掌握 Claude Code"
|
||||||
|
|
||||||
# Cover Settings
|
# Cover Settings
|
||||||
cover_width: int = 600
|
cover_width: int = 600
|
||||||
@@ -1057,8 +1059,11 @@ def main() -> int:
|
|||||||
"--lang",
|
"--lang",
|
||||||
type=str,
|
type=str,
|
||||||
default="en",
|
default="en",
|
||||||
choices=["en", "vi"],
|
choices=["en", "vi", "zh"],
|
||||||
help="Language code: 'en' for English, 'vi' for Vietnamese (default: en)",
|
help=(
|
||||||
|
"Language code: 'en' for English, 'vi' for Vietnamese, "
|
||||||
|
"'zh' for Chinese (default: en)"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--puppeteer-config",
|
"--puppeteer-config",
|
||||||
@@ -1073,17 +1078,16 @@ def main() -> int:
|
|||||||
repo_root = args.root if args.root else Path(__file__).parent.parent
|
repo_root = args.root if args.root else Path(__file__).parent.parent
|
||||||
repo_root = repo_root.resolve()
|
repo_root = repo_root.resolve()
|
||||||
|
|
||||||
# Set language-specific paths and metadata
|
# Set language-specific paths and metadata.
|
||||||
if args.lang == "vi":
|
# Each entry: (source root, default output filename, title)
|
||||||
root = repo_root / "vi"
|
lang_map: dict[str, tuple[Path, str, str]] = {
|
||||||
output = args.output or (repo_root / "claude-howto-guide-vi.epub")
|
"en": (repo_root, "claude-howto-guide.epub", EPUBConfig.en_title),
|
||||||
title = EPUBConfig.vi_title
|
"vi": (repo_root / "vi", "claude-howto-guide-vi.epub", EPUBConfig.vi_title),
|
||||||
language = "vi"
|
"zh": (repo_root / "zh", "claude-howto-guide-zh.epub", EPUBConfig.zh_title),
|
||||||
else:
|
}
|
||||||
root = repo_root
|
root, default_output_name, title = lang_map[args.lang]
|
||||||
output = args.output or (repo_root / "claude-howto-guide.epub")
|
output = args.output or (repo_root / default_output_name)
|
||||||
title = EPUBConfig.en_title
|
language = args.lang
|
||||||
language = "en"
|
|
||||||
|
|
||||||
root = root.resolve()
|
root = root.resolve()
|
||||||
output = output.resolve()
|
output = output.resolve()
|
||||||
|
|||||||
Reference in New Issue
Block a user