diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..29e83da --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: Build Book + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + - run: bundle install + - run: rake build:CI + - uses: actions/github-script@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs').promises; + + const { repo: { owner, repo }, sha } = context; + + const release = await github.repos.createRelease({ + owner, repo, + tag_name: `v6.${process.env.GITHUB_RUN_NUMBER}`, + draft: true, + target_commitish: sha + }); + + console.log('A release has been created'); + const build_dir = 'build'; + + for (let file of await fs.readdir(build_dir)) { + if (file == '.gitkeep') continue; + console.log('uploading', file); + await github.repos.uploadReleaseAsset({ + owner, repo, + release_id: release.data.id, + name: file, + data: await fs.readFile(`${build_dir}/${file}`) + }); + } + console.log('DONE') diff --git a/Gemfile b/Gemfile index 7eb5b30..af2fba8 100644 --- a/Gemfile +++ b/Gemfile @@ -11,4 +11,5 @@ gem "asciidoctor-pdf", "~> 1.5.beta.7" gem "concurrent-ruby", "~> 1.1" gem "rouge", "~> 3.3" gem "asciidoctor-epub3", "~> 1.5.alpha.9" -gem "kindlegen", "~> 3.0" +# TODO: uncomment when issue(https://github.com/tdtds/kindlegen/issues/42) solved +# gem "kindlegen", "~> 3.0" diff --git a/Gemfile.lock b/Gemfile.lock index 3278874..fadb317 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,12 +6,11 @@ GEM public_suffix (>= 2.0.2, < 5.0) afm (0.2.2) asciidoctor (2.0.10) - asciidoctor-epub3 (1.5.0.alpha.9) - asciidoctor (>= 1.5.0, < 3.0.0) - concurrent-ruby (~> 1.1.5) - gepub (~> 1.0.2) - thread_safe (~> 0.3.6) - asciidoctor-pdf (1.5.0.rc.2) + asciidoctor-epub3 (1.5.0.alpha.18) + asciidoctor (>= 1.5.6, < 3.0.0) + gepub (~> 1.0.0) + mime-types (~> 3.0) + asciidoctor-pdf (1.5.3) asciidoctor (>= 1.5.3, < 3.0.0) concurrent-ruby (~> 1.1.0) prawn (~> 2.2.0) @@ -21,20 +20,20 @@ GEM prawn-templates (~> 0.1.0) safe_yaml (~> 1.0.0) thread_safe (~> 0.3.0) - treetop (~> 1.5.0) + treetop (~> 1.6.0) ttfunk (~> 1.5.0, >= 1.5.1) - concurrent-ruby (1.1.5) + concurrent-ruby (1.1.7) css_parser (1.7.1) addressable - gepub (1.0.7) + gepub (1.0.11) nokogiri (>= 1.8.2, < 1.11) - rubyzip (> 1.1.1, < 2.1) + rubyzip (> 1.1.1, < 2.3) hashery (2.1.2) - kindlegen (3.0.5) - rake - rubyzip + mime-types (3.3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2020.0512) mini_portile2 (2.4.0) - nokogiri (1.10.8) + nokogiri (1.10.10) mini_portile2 (~> 2.4.0) pdf-core (0.7.0) pdf-reader (2.4.0) @@ -57,14 +56,13 @@ GEM prawn-templates (0.1.2) pdf-reader (~> 2.0) prawn (~> 2.2) - public_suffix (4.0.3) - rake (13.0.1) - rouge (3.14.0) + public_suffix (4.0.5) + rouge (3.22.0) ruby-rc4 (0.1.5) - rubyzip (2.0.0) + rubyzip (2.2.0) safe_yaml (1.0.5) thread_safe (0.3.6) - treetop (1.5.3) + treetop (1.6.10) polyglot (~> 0.3) ttfunk (1.5.1) @@ -76,8 +74,7 @@ DEPENDENCIES asciidoctor-epub3 (~> 1.5.alpha.9) asciidoctor-pdf (~> 1.5.beta.7) concurrent-ruby (~> 1.1) - kindlegen (~> 3.0) rouge (~> 3.3) BUNDLED WITH - 1.17.3 + 2.1.4 diff --git a/Rakefile b/Rakefile index 71e8100..8eef811 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ require 'asciidoctor' require 'asciidoctor-pdf' +require 'yaml' LANGS = %w[en fr es].freeze VERSIONS = %w[5 6].freeze @@ -10,13 +11,13 @@ FONTS_DIR = File.join __dir__, 'fonts' def check_args(args) lang = args[:lang] unless LANGS.include?(lang) - msg = format('Lang not availaible. Select on of theses langs: %s', LANGS.join(', ')) + msg = format('Lang not available. Select on of these langs: %s', LANGS.join(', ')) raise ArgumentError, msg end version = args[:version] unless VERSIONS.include?(version) - msg = format('Version not availaible. Select on of theses versions: %s', VERSIONS.join(', ')) + msg = format('Version not available. Select on of these versions: %s', VERSIONS.join(', ')) raise ArgumentError, msg end @@ -32,6 +33,23 @@ def out_filename(args, extension) end namespace :build do + desc 'Build for all versions, languages' + task :CI do + builds = YAML.load(File.read("builds.yaml")) + builds.entries.each do |version, languages| + languages.each do |language| + puts "VERSION: #{version} - LANG: #{language}" + args = { version: version, lang: language } + Rake::Task['build:pdf'].execute(args) + Rake::Task['build:html'].execute(args) + Rake::Task['build:epub'].execute(args) + # [temporary] no mobi build + # TODO: fix when issue(https://github.com/tdtds/kindlegen/issues/42) solved + # Rake::Task['build:mobi'].execute(args) + end + end + end + desc 'Build all versions' task :all, [:version, :lang] do |_task, args| check_args(args) diff --git a/builds.yaml b/builds.yaml new file mode 100644 index 0000000..a4aae12 --- /dev/null +++ b/builds.yaml @@ -0,0 +1,2 @@ +5: [en, fr] +6: [en, es, fr]