-
Notifications
You must be signed in to change notification settings - Fork 3
140 lines (123 loc) · 4.58 KB
/
book.yaml
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
name: Build epub
permissions:
id-token: write
checks: write
contents: write
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: 5.x
- id: determine_version
name: Determine Version
uses: gittools/actions/gitversion/[email protected]
with:
additionalArguments: /overrideconfig mode=Mainline
- uses: nelonoel/[email protected]
- name: Build book
env:
VERSION: ${{ steps.determine_version.outputs.semVer }}
run: |-
sudo apt-get update
sudo apt-get install -y ruby-full build-essential zlib1g-dev python2 dos2unix libegl1 libopengl0 epubcheck
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
sudo gem install jekyll bundler jekyll-contentful-data-import
cd scripts
dos2unix create-epub.sh
chmod +x create-epub.sh
./create-epub.sh
- name: Validate EPUB
run: epubcheck _site/book/MyBook.epub
- name: Install Calibre
run: sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo --preserve-env=CALIBRE_INSTALLER_LOCAL_URL sh /dev/stdin version=6.13.0
env:
CALIBRE_INSTALLER_LOCAL_URL: https://octopus-sales-engineering.s3.ap-southeast-2.amazonaws.com/calibre-6.13.0-x86_64.txz
# Letter size is 816px x 1056px, but we double the cover image because kindle recommends larger images
- name: Convert to PDF
if: github.event_name != 'pull_request'
run: |
ebook-convert \
_site/book/MyBook.epub \
_site/book/MyBook.pdf \
--pdf-sans-family 'Helvetica' \
--pdf-serif-family 'Helvetica' \
--pdf-default-font-size 12 \
--pdf-mono-font-size 12 \
--paper-size letter \
--cover 'pdf-cover.png'
- name: Create Release
id: create_release
uses: actions/create-release@v1
if: github.event_name != 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.determine_version.outputs.semVer }}+run${{ github.run_number }}-attempt${{ github.run_attempt }}
release_name: Release ${{ steps.determine_version.outputs.semVer }} Run ${{ github.run_number }} Attempt ${{ github.run_attempt }}
draft: github.ref != 'refs/heads/main'
prerelease: github.ref != 'refs/heads/main'
- name: Upload EPUB Release Asset
id: upload-release-asset-epub
uses: actions/upload-release-asset@v1
if: github.event_name != 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: _site/book/MyBook.epub
asset_name: deaas.epub
asset_content_type: application/zip
- name: Upload HTML ZIP
id: upload-release-asset-zip
if: github.event_name != 'pull_request'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: _site/book/html.zip
asset_name: deaas.zip
asset_content_type: application/zip
- name: Upload PDF Release Asset
id: upload-release-asset-pdf
if: github.event_name != 'pull_request'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: _site/book/MyBook.pdf
asset_name: deaas.pdf
asset_content_type: application/pdf
- name: Build printable EPUB
if: github.event_name != 'pull_request'
env:
VERSION: ${{ steps.determine_version.outputs.semVer }}
run: |-
cd scripts
dos2unix create-epub-kdp.sh
chmod +x create-epub-kdp.sh
./create-epub-kdp.sh
- name: Upload Printable EPUB Release Asset
if: github.event_name != 'pull_request'
id: upload-release-asset-printable-epub
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: _site/kdp/MyBookKDP.epub
asset_name: deaas-printable.epub
asset_content_type: application/zip