Skip to content

Merge pull request #475 from ndw/improve-pdf #196

Merge pull request #475 from ndw/improve-pdf

Merge pull request #475 from ndw/improve-pdf #196

Workflow file for this run

name: Build DocBook xslTNG
on: push
jobs:
check_branch:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.check_step.outputs.branch }}
reponame: ${{ steps.check_step.outputs.reponame }}
tag: ${{ steps.check_step.outputs.tag }}
guideversion: ${{ steps.check_step.outputs.guideversion }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get branch name, etc.
id: check_step
run: |
raw=${{ github.repository }}
reponame=${raw##*/}
echo "reponame=$reponame" >> $GITHUB_OUTPUT
raw=$(git branch -r --contains ${{ github.ref }})
branch=${raw##*/}
echo "branch=$branch" >> $GITHUB_OUTPUT
tag=""
if [ ${{ github.ref_type }} = "tag" ]; then
tag=${{ github.ref_name }}
echo "Running in $reponame on $branch for $tag"
else
echo "Running in $reponame on $branch"
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
raw=`cat properties.gradle | grep guideVersion | sed "s#[ '\"]##g"`
guideversion=${raw##*=}
echo "guideversion=${raw##*=}" >> $GITHUB_OUTPUT
build-and-deploy:
name: Build xslTNG on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: check_branch
env:
HAVE_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN != '' }}
HAVE_GPGKEYURI: ${{ secrets.ACCESS_TOKEN != '' && secrets.GPGKEYURI != '' }}
HAVE_SAXON_EE: ${{ secrets.SAXON_PASSPHRASE != '' }}
CIWORKFLOW: yes
CI_SHA1: ${{ github.sha }}
CI_BUILD_NUM: ${{ github.run_number }}
CI_PROJECT_USERNAME: ${{ github.repository_owner }}
CI_PROJECT_REPONAME: ${{ needs.check_branch.outputs.reponame }}
CI_BRANCH: ${{ needs.check_branch.outputs.branch }}
CI_TAG: ${{ needs.check_branch.outputs.tag }}
GUIDE_VERSION: ${{ needs.check_branch.outputs.guideversion }}
strategy:
matrix:
os: [ubuntu-20.04]
steps:
- name: Report guide version
run: |
echo "Building guide version ::${GUIDE_VERSION}::"
- name: Install platform-independent Python modules
run: |
python3 -m pip install pygments==2.14.0 click cython
# Test the build on Mac
- name: Install dependencies on Mac
if: matrix.os == 'macos-11'
run: |
brew install rsync libxml2 libxslt sass/sass/sass
python3 -m pip install saxonche
python3 -m pip install --no-binary lxml html5-parser
- name: Checkout the main branch on Mac
if: matrix.os == 'macos-11'
uses: actions/checkout@v3
- name: Get the latest releases (authenticated request on mac)
if: ${{ matrix.os == 'macos-11' && env.HAVE_ACCESS_TOKEN == 'true' }}
run: |
mkdir -p build
# Don’t attempt to use continuation lines here because Windows
curl --request GET --url https://api.github.com/repos/${{ github.repository }}/releases --header 'authorization: Bearer ${{ secrets.ACCESS_TOKEN }}' -o build/releases.json
- name: Build on Mac
if: matrix.os == 'macos-11'
run: |
ls build
./gradlew --stacktrace -PrequireCompileSuccess=true dist
# Test the build on Windows
- name: Install dependencies on Windows
if: matrix.os == 'windows-2019'
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install sass
- name: Checkout the main branch on Windows
if: matrix.os == 'windows-2019'
uses: actions/checkout@v3
- name: Get the latest releases (authenticated request on Windows)
if: ${{ matrix.os == 'windows-2019' && env.HAVE_ACCESS_TOKEN == 'true' }}
run: |
mkdir -p build
# Don’t attempt to use continuation lines here because Windows
curl --request GET --url https://api.github.com/repos/${{ github.repository }}/releases --header 'authorization: Bearer ${{ secrets.ACCESS_TOKEN }}' -o build/releases.json
- name: Build on Windows
if: matrix.os == 'windows-2019'
env:
JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
run: |
./gradlew --stacktrace -PrequireCompileSuccess=true -PrequireTestSuccess=false dist
# Test the build on Linux
- name: Install dependencies on Linux
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install epubcheck rsync libxml2-dev libxslt-dev
curl -o /tmp/dart.tar.gz -L https://github.com/sass/dart-sass/releases/download/1.56.0/dart-sass-1.56.0-linux-x64.tar.gz
cd /tmp && tar zxf dart.tar.gz && sudo mv dart-sass/sass /usr/local/bin
python3 -m pip install saxonche
python3 -m pip install --no-binary lxml html5-parser
- name: Checkout the gh-pages branch on Linux
if: matrix.os == 'ubuntu-20.04'
uses: actions/checkout@v3
with:
ref: 'gh-pages'
- name: Save EPUB and PDFs
if: matrix.os == 'ubuntu-20.04'
run: tar cf - epub pdf | gzip > /tmp/save-epub-pdf.tar.gz
- name: Save the current version(s) of the guide
if: matrix.os == 'ubuntu-20.04'
run: |
mkdir /tmp/guide
rsync -ar guide/ /tmp/guide/
rm -rf /tmp/guide/$GUIDE_VERSION
- name: Checkout the main branch on Linux
if: matrix.os == 'ubuntu-20.04'
uses: actions/checkout@v3
- name: Setup SaxonEE on Linux
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_SAXON_EE == 'true' }}
run: gpg --batch --yes --passphrase ${{ secrets.SAXON_PASSPHRASE }} -d tools/saxon.enc | tar zxf -
- name: Get the latest releases (authenticated request on Windows)
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' }}
run: |
mkdir -p build
# Don’t attempt to use continuation lines here because Windows
curl --request GET --url https://api.github.com/repos/${{ github.repository }}/releases --header 'authorization: Bearer ${{ secrets.ACCESS_TOKEN }}' -o build/releases.json
- name: Build on Linux
if: matrix.os == 'ubuntu-20.04'
run: |
./gradlew --stacktrace -PrequireCompileSuccess=true dist
- name: Cleanup SaxonEE
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_SAXON_EE == 'true' }}
run: rm -rf lib
- name: Restore EPUB and PDFs
if: matrix.os == 'ubuntu-20.04'
run: cd build/website && tar zxf /tmp/save-epub-pdf.tar.gz
- name: Restore previous version(s) of the guide
if: matrix.os == 'ubuntu-20.04'
run: |
rsync -ar /tmp/guide/ build/website/guide/
if [ ! -f build/website/guide/index.html ]; then \
mv /tmp/guide/index.html build/website/guide/; \
fi
- name: Deploy main to gh-pages
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/website
token: ${{ secrets.ACCESS_TOKEN }}
branch: gh-pages
target-folder: /
- name: Deploy tagged release to CDN as ${{ env.CI_TAG }}
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/release
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: ${{ github.repository_owner}}/cdn
branch: master
target-folder: /release/xsltng/${{ env.CI_TAG }}
- name: Deploy tagged release to CDN as current
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/release
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: ${{ github.repository_owner}}/cdn
branch: master
target-folder: /release/xsltng/current
- name: Publish release
uses: softprops/action-gh-release@v1
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
with:
draft: false
prerelease: false
fail_on_unmatched_files: true
files: |
build/distributions/docbook-xslTNG-${{ env.CI_TAG }}.zip
build/distributions/docbook-xslTNG-nosaxon-${{ env.CI_TAG }}.zip
- name: Publish to Sonatype
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_GPGKEYURI == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
run: |
curl -s -o secret.gpg ${{ secrets.GPGKEYURI }}
./gradlew -PsonatypeUsername=${{ secrets.SONATYPEUSER }} \
-PsonatypePassword="${{ secrets.SONATYPEPASS }}" \
-Psigning.keyId="${{ secrets.SIGNKEY }}" \
-Psigning.password="${{ secrets.SIGNPSW }}" \
-Psigning.secretKeyRingFile=./secret.gpg \
publish
rm -f secret.gpg
- name: Checkout the CDN
uses: actions/checkout@v3
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
with:
repository: ${{ github.repository_owner}}/cdn
token: ${{ secrets.ACCESS_TOKEN }}
fetch-depth: 0
ref: 'master'
- name: Rebuild the CDN indexes
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
run: bin/git-index-html
- name: Deploy the indexes back to the CDN
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ matrix.os == 'ubuntu-20.04' && env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' && env.CI_TAG != '' }}
with:
folder: .
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: ${{ github.repository_owner}}/cdn
branch: master
target-folder: /