Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hendricius committed Apr 26, 2024
0 parents commit c787f6b
Show file tree
Hide file tree
Showing 39 changed files with 2,506 additions and 0 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/release-book.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Release the book

on:
push:
branches:
- main
env:
IMAGE_NAME: ${{ github.repository }}
LATEST_IMAGE: ghcr.io/${{ github.repository }}:latest

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Figure out branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Determine docker image tag
shell: bash
id: determine_tag
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=${{ steps.extract_branch.outputs.branch }}" >> $GITHUB_OUTPUT
fi
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Buildx for caching
- uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.determine_tag.outputs.tag }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

release-book-website:
needs: build-and-push-image
runs-on: ubuntu-latest
steps:
- name: Set up git repository
uses: actions/checkout@v3
- name: Print dependency versions
uses: addnab/docker-run-action@v3
with:
image: ${{ env.LATEST_IMAGE }}
options: -v ${{ github.workspace }}:/app
run: |
cd /app/book
make show_tools_version
- name: Print build variables
uses: addnab/docker-run-action@v3
with:
image: ${{ env.LATEST_IMAGE }}
options: -v ${{ github.workspace }}:/app
run: |
cd /app/book
make printvars
- name: Bake the book
uses: addnab/docker-run-action@v3
with:
image: ${{ env.LATEST_IMAGE }}
options: -v ${{ github.workspace }}:/app
run: |
cd /app/book
make -j bake
- name: Release baked book to S3
uses: shallwefootball/s3-upload-action@master
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: ${{ secrets.AWS_BUCKET_BOOK }}
source_dir: book/release
destination_dir: release-recipes
- name: Upload book Artifacts
uses: actions/upload-artifact@v3
with:
name: books
path: |
book/book_serif/book.log
book/book_serif/book.pdf
book/book-epub/book.epub
invalidate-book-cache:
needs: release-book-website
runs-on: ubuntu-latest
steps:
- name: Invalidate Cloudfront book cache
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_BOOK }}
PATHS: "/*"
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
9 changes: 9 additions & 0 deletions .github/workflows/test-book-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Test building book

on: [push, pull_request]

jobs:
test-building-book:
uses: ./.github/workflows/test-book.yml
with:
docker-image: ghcr.io/${{ github.repository }}:latest
55 changes: 55 additions & 0 deletions .github/workflows/test-book.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Test book for given image

on:
workflow_call:
inputs:
docker-image:
required: true
type: string

jobs:
test-book:
runs-on: ubuntu-latest
steps:
- name: Set up git repository
uses: actions/checkout@v3
- name: Print dependency versions
uses: addnab/docker-run-action@v3
with:
image: ${{ inputs.docker-image }}
options: -v ${{ github.workspace }}:/app
run: |
cd /app/book
make show_tools_version
- name: Print build variables
uses: addnab/docker-run-action@v3
with:
image: ${{ inputs.docker-image }}
options: -v ${{ github.workspace }}:/app
run: |
cd /app/book
make printvars
- name: Test baking the book pdf
uses: addnab/docker-run-action@v3
with:
image: ${{ inputs.docker-image }}
options: -v ${{ github.workspace }}:/app
run: |
cd /app/book
make build_serif_pdf build_ebook
- name: Test baking the book epub
uses: addnab/docker-run-action@v3
with:
image: ${{ inputs.docker-image }}
options: -v ${{ github.workspace }}:/app
run: |
cd /app/book
make build_ebook
- name: Upload book Artifacts
uses: actions/upload-artifact@v3
with:
name: books
path: |
book/book_serif/book.log
book/book_serif/book.pdf
book/book-epub/book.epub
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.DS_Store
*.xbb
*.aux
*.fdb_latexmk
*.fls
*.log
*.synctex.gz
*.toc
*.pdf
*.bbl
*.bcf
*.blg
*.run.xml
*.html
*.dlog
*.bak
*.opf
book/book.out
.vscode/
book/bookch*
book/figures/*.png
book/figures/*.pdf
book/figures/*.in
book/book*.4ct
book/book*.4tc
book/book*.css
book/book*.dvi
book/book*.idv
book/book*.lg
book/book*.ncx
book/book*.out
book/book*.tmp
book/book*.xref
book/book*.svg
# Directories created during build
book/book_sans_serif/*
book/book_serif/*
book/static_website_html/*
website/static_website_html/*
book/epub/
book/book-epub/
book/bw-book-epub/*
book/release/*
62 changes: 62 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM debian:trixie

LABEL "maintainer"="Hendrik Kleinwächter <[email protected]>"
LABEL "repository"="https://github.com/hendricius/the-sourdough-framework-recipes"
LABEL "homepage"="https://github.com/hendricius/the-sourdough-framework-recipes"
LABEL org.opencontainers.image.source="https://github.com/hendricius/the-sourdough-framework-recipes"

# Print release information if needed
RUN cat /etc/*release*

# Install base depdendencies
RUN apt-get update && \
apt-get install --yes -y --no-install-recommends \
sudo \
make \
tidy \
pandoc \
zip \
git \
wget \
imagemagick \
rsync \
wget \
perl \
xzdec \
# dvisvgm dependencies
build-essential \
fonts-texgyre \
fontconfig \
libfontconfig1 \
libkpathsea-dev \
libptexenc-dev \
libsynctex-dev \
libx11-dev \
libxmu-dev \
libxaw7-dev \
libxt-dev \
libxft-dev \
libwoff-dev

# Install TeX
RUN apt-get update && \
apt-get install -y --no-install-recommends \
texlive-full \
texlive-luatex

# Compile latest dvisvgm
RUN wget https://github.com/mgieseki/dvisvgm/releases/download/3.1.2/dvisvgm-3.1.2.tar.gz && \
mv dvisvgm-3.1.2.tar.gz dvisvgm.tar.gz && \
tar -xzf dvisvgm.tar.gz && \
cd dvisvgm-* && \
./configure && \
make && \
make install

# Make sure everything is UTF-8
RUN echo "export LC_ALL=en_US.UTF-8" >> /root/.bashrc && \
echo "export LANG=en_US.UTF-8" >> /root/.bashrc

WORKDIR /root

CMD ["/bin/bash"]
Loading

0 comments on commit c787f6b

Please sign in to comment.