Skip to content

Commit c5bfe70

Browse files
kerollozmadeindjs
andauthored
Add GitHub Action workflow to build the book (#50)
* Add GitHub Action workflow to build the book - updated packages & bundler - removed 'kindlegen'. More at tdtds/kindlegen#42 * [GitHub Actions] run only on master Co-authored-by: Alexandre Rousseau <[email protected]> * store builds in YAML instead of JSON * [GitHub Actions] change tag_name to include version and github run number Co-authored-by: Alexandre Rousseau <[email protected]> Co-authored-by: Alexandre Rousseau <[email protected]>
1 parent 0aa47b3 commit c5bfe70

File tree

5 files changed

+91
-24
lines changed

5 files changed

+91
-24
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build Book
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: ruby/setup-ruby@v1
17+
with:
18+
ruby-version: 2.7
19+
- run: bundle install
20+
- run: rake build:CI
21+
- uses: actions/github-script@v2
22+
with:
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
script: |
25+
const fs = require('fs').promises;
26+
27+
const { repo: { owner, repo }, sha } = context;
28+
29+
const release = await github.repos.createRelease({
30+
owner, repo,
31+
tag_name: `v6.${process.env.GITHUB_RUN_NUMBER}`,
32+
draft: true,
33+
target_commitish: sha
34+
});
35+
36+
console.log('A release has been created');
37+
const build_dir = 'build';
38+
39+
for (let file of await fs.readdir(build_dir)) {
40+
if (file == '.gitkeep') continue;
41+
console.log('uploading', file);
42+
await github.repos.uploadReleaseAsset({
43+
owner, repo,
44+
release_id: release.data.id,
45+
name: file,
46+
data: await fs.readFile(`${build_dir}/${file}`)
47+
});
48+
}
49+
console.log('DONE')

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ gem "asciidoctor-pdf", "~> 1.5.beta.7"
1111
gem "concurrent-ruby", "~> 1.1"
1212
gem "rouge", "~> 3.3"
1313
gem "asciidoctor-epub3", "~> 1.5.alpha.9"
14-
gem "kindlegen", "~> 3.0"
14+
# TODO: uncomment when issue(https://github.com/tdtds/kindlegen/issues/42) solved
15+
# gem "kindlegen", "~> 3.0"

Gemfile.lock

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ GEM
66
public_suffix (>= 2.0.2, < 5.0)
77
afm (0.2.2)
88
asciidoctor (2.0.10)
9-
asciidoctor-epub3 (1.5.0.alpha.9)
10-
asciidoctor (>= 1.5.0, < 3.0.0)
11-
concurrent-ruby (~> 1.1.5)
12-
gepub (~> 1.0.2)
13-
thread_safe (~> 0.3.6)
14-
asciidoctor-pdf (1.5.0.rc.2)
9+
asciidoctor-epub3 (1.5.0.alpha.18)
10+
asciidoctor (>= 1.5.6, < 3.0.0)
11+
gepub (~> 1.0.0)
12+
mime-types (~> 3.0)
13+
asciidoctor-pdf (1.5.3)
1514
asciidoctor (>= 1.5.3, < 3.0.0)
1615
concurrent-ruby (~> 1.1.0)
1716
prawn (~> 2.2.0)
@@ -21,20 +20,20 @@ GEM
2120
prawn-templates (~> 0.1.0)
2221
safe_yaml (~> 1.0.0)
2322
thread_safe (~> 0.3.0)
24-
treetop (~> 1.5.0)
23+
treetop (~> 1.6.0)
2524
ttfunk (~> 1.5.0, >= 1.5.1)
26-
concurrent-ruby (1.1.5)
25+
concurrent-ruby (1.1.7)
2726
css_parser (1.7.1)
2827
addressable
29-
gepub (1.0.7)
28+
gepub (1.0.11)
3029
nokogiri (>= 1.8.2, < 1.11)
31-
rubyzip (> 1.1.1, < 2.1)
30+
rubyzip (> 1.1.1, < 2.3)
3231
hashery (2.1.2)
33-
kindlegen (3.0.5)
34-
rake
35-
rubyzip
32+
mime-types (3.3.1)
33+
mime-types-data (~> 3.2015)
34+
mime-types-data (3.2020.0512)
3635
mini_portile2 (2.4.0)
37-
nokogiri (1.10.8)
36+
nokogiri (1.10.10)
3837
mini_portile2 (~> 2.4.0)
3938
pdf-core (0.7.0)
4039
pdf-reader (2.4.0)
@@ -57,14 +56,13 @@ GEM
5756
prawn-templates (0.1.2)
5857
pdf-reader (~> 2.0)
5958
prawn (~> 2.2)
60-
public_suffix (4.0.3)
61-
rake (13.0.1)
62-
rouge (3.14.0)
59+
public_suffix (4.0.5)
60+
rouge (3.22.0)
6361
ruby-rc4 (0.1.5)
64-
rubyzip (2.0.0)
62+
rubyzip (2.2.0)
6563
safe_yaml (1.0.5)
6664
thread_safe (0.3.6)
67-
treetop (1.5.3)
65+
treetop (1.6.10)
6866
polyglot (~> 0.3)
6967
ttfunk (1.5.1)
7068

@@ -76,8 +74,7 @@ DEPENDENCIES
7674
asciidoctor-epub3 (~> 1.5.alpha.9)
7775
asciidoctor-pdf (~> 1.5.beta.7)
7876
concurrent-ruby (~> 1.1)
79-
kindlegen (~> 3.0)
8077
rouge (~> 3.3)
8178

8279
BUNDLED WITH
83-
1.17.3
80+
2.1.4

Rakefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'asciidoctor'
22
require 'asciidoctor-pdf'
3+
require 'yaml'
34

45
LANGS = %w[en fr es].freeze
56
VERSIONS = %w[5 6].freeze
@@ -10,13 +11,13 @@ FONTS_DIR = File.join __dir__, 'fonts'
1011
def check_args(args)
1112
lang = args[:lang]
1213
unless LANGS.include?(lang)
13-
msg = format('Lang not availaible. Select on of theses langs: %s', LANGS.join(', '))
14+
msg = format('Lang not available. Select on of these langs: %s', LANGS.join(', '))
1415
raise ArgumentError, msg
1516
end
1617

1718
version = args[:version]
1819
unless VERSIONS.include?(version)
19-
msg = format('Version not availaible. Select on of theses versions: %s', VERSIONS.join(', '))
20+
msg = format('Version not available. Select on of these versions: %s', VERSIONS.join(', '))
2021
raise ArgumentError, msg
2122
end
2223

@@ -32,6 +33,23 @@ def out_filename(args, extension)
3233
end
3334

3435
namespace :build do
36+
desc 'Build for all versions, languages'
37+
task :CI do
38+
builds = YAML.load(File.read("builds.yaml"))
39+
builds.entries.each do |version, languages|
40+
languages.each do |language|
41+
puts "VERSION: #{version} - LANG: #{language}"
42+
args = { version: version, lang: language }
43+
Rake::Task['build:pdf'].execute(args)
44+
Rake::Task['build:html'].execute(args)
45+
Rake::Task['build:epub'].execute(args)
46+
# [temporary] no mobi build
47+
# TODO: fix when issue(https://github.com/tdtds/kindlegen/issues/42) solved
48+
# Rake::Task['build:mobi'].execute(args)
49+
end
50+
end
51+
end
52+
3553
desc 'Build all versions'
3654
task :all, [:version, :lang] do |_task, args|
3755
check_args(args)

builds.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
5: [en, fr]
2+
6: [en, es, fr]

0 commit comments

Comments
 (0)