|
| 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 | + - name: Get commit hash and create filename prefix |
| 52 | + run: | |
| 53 | + echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 54 | + echo "filename_prefix='linux-insides_$commit'" >> $GITHUB_ENV |
| 55 | +
|
| 56 | + - name: Generate PDF |
| 57 | + run: honkit pdf ./ "./$filename_prefix.pdf" |
| 58 | + |
| 59 | + - name: Generate EPUB |
| 60 | + run: honkit epub ./ "./$filename_prefix.epub" |
| 61 | + |
| 62 | + - name: Generate MOBI |
| 63 | + run: honkit mobi ./ "./$filename_prefix.mobi" |
| 64 | + |
| 65 | + # Create a release on GitHub. |
| 66 | + - name: Create release |
| 67 | + uses: ncipollo/release-action@v1 |
| 68 | + with: |
| 69 | + artifacts: "${{ env.filename_prefix }}.*" |
| 70 | + generateReleaseNotes: true |
| 71 | + allowUpdates: true |
| 72 | + artifactErrorsFailBuild: true |
| 73 | + tag: "${{ env.commit }}" |
| 74 | + commit: "master" |
| 75 | + # End of steps. |
| 76 | + # End of release_ebooks. |
| 77 | +# End of jobs. |
| 78 | + |
| 79 | + |
| 80 | +# End of file. |
0 commit comments