Skip to content

Commit 6656001

Browse files
committed
Create a release with ebooks on push to master
Use GitHub actions to create a release with PDF, EPUB, and MOBI files automatically on push to master. The action can also be triggered manually. The commit ID will be used as tag for releases. This action does not use GitBook, but a fork of it named HonKit. gitbook-cli isn't maintained since 6 years, whereas honkit is a maintained fork.
1 parent 859d98c commit 6656001

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Note: Indentation here is of 2 spaces.
2+
3+
name: Generate release with ebooks
4+
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
11+
workflow_dispatch: {} # For manual switch.
12+
# End of on.
13+
14+
15+
jobs:
16+
release_ebooks:
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: write
21+
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v3
25+
with:
26+
ref: master
27+
28+
- name: Setup node
29+
uses: actions/setup-node@v3
30+
with:
31+
node-version: "latest"
32+
33+
# HonKit is a maintained fork of GitBook.
34+
- name: Install honkit
35+
run: npm install honkit -g
36+
37+
# APT install can take a long time due to installing dependencies,
38+
# so we will use caching.
39+
- name: Install calibre for ebook-convert
40+
uses: awalsh128/cache-apt-pkgs-action@latest
41+
with:
42+
packages: calibre
43+
44+
# HonKit uses highlight.js for syntax highlighting, which doesn't have
45+
# "assembly" option, but has "x86asm". Currently, there is a better
46+
# "x86asmatt" option in main branch but it is unreleased.
47+
- name: Change highlighting code for honkit
48+
run: find . -type f -name "*.md" -exec sed -i 's/```assembly/```x86asm/g' {} \;
49+
50+
# Create environment variables for convenience.
51+
# GITHUB_ENV stores the env variables between steps.
52+
- name: Get commit hash and create filename prefix
53+
run: |
54+
commit="$(git rev-parse --short HEAD)"
55+
echo "commit=$commit" >> $GITHUB_ENV
56+
echo "filename_prefix='linux-insides_$commit'" >> $GITHUB_ENV
57+
58+
- name: Generate PDF
59+
run: honkit pdf ./ "./$filename_prefix.pdf"
60+
61+
- name: Generate EPUB
62+
run: honkit epub ./ "./$filename_prefix.epub"
63+
64+
- name: Generate MOBI
65+
run: honkit mobi ./ "./$filename_prefix.mobi"
66+
67+
# Create a release on GitHub.
68+
- name: Create release
69+
uses: ncipollo/release-action@v1
70+
with:
71+
artifacts: "${{ env.filename_prefix }}.*"
72+
generateReleaseNotes: true
73+
allowUpdates: true
74+
artifactErrorsFailBuild: true
75+
tag: "${{ env.commit }}"
76+
commit: "master"
77+
# End of steps.
78+
# End of release_ebooks.
79+
# End of jobs.
80+
81+
82+
# End of file.

0 commit comments

Comments
 (0)