diff --git a/.gitea/workflows/prepare.yml b/.gitea/workflows/prepare.yml index 7dc4eef..9f2a9b4 100644 --- a/.gitea/workflows/prepare.yml +++ b/.gitea/workflows/prepare.yml @@ -12,27 +12,44 @@ jobs: env: USERNAME: servostar EMAIL: sven.vogel123@web.de + GIT_AUTH_TOKEN: ${{ secrets.RELEASE_TOKEN }} + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} steps: - name: Check out repository code uses: actions/checkout@v3 with: ref: 'main' token: ${{ secrets.RELEASE_TOKEN }} - - name: Tag Release Commit - env: - COMMIT_MESSAGE: ${{ github.event.head_commit.message }} - GIT_AUTH_TOKEN: ${{ secrets.RELEASE_TOKEN }} + - name: Install dependencies for Nix setup action + run: | + apt update -y + apt install sudo -y + - name: Setup Nix + uses: cachix/install-nix-action@v27 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Setup Git run: | - export VERSION=$(echo "${COMMIT_MESSAGE}" | grep -Po '(?<=Release-As: )v\d+\.\d+\.\d+') git config --global user.name "${USERNAME}" git config --global user.email "${EMAIL}" - echo "==> Update typst.toml version" + - name: Update Typst.toml + run: | + export VERSION=$(echo "${COMMIT_MESSAGE}" | grep -Po '(?<=Release-As: )v\d+\.\d+\.\d+') sed -i "/version/c\version = \"${VERSION#v}\"" typst.toml git add typst.toml git commit -m "chore: bump release version to $VERSION" -m "Generated-By: ${{ gitea.actor }}" + - name: Generate Example Document + run: nix-shell --run ./run-ci.sh + - name: Generate Assets + if: contains(github.event.head_commit.message, 'Generate-Assets') + run: | + ./run-bake-assets.sh + git add assets/banner.png + git add assets/page-preview.png + git commit -m "chore: update assets" -m "Generated-By: ${{ gitea.actor }}" + - name: Tag and Push Changes + run: | git push origin main - echo "::endgroup::" - echo "::group::{Tag commit}" + export VERSION=$(echo "${COMMIT_MESSAGE}" | grep -Po '(?<=Release-As: )v\d+\.\d+\.\d+') git tag -m "Release" "${VERSION}" git push origin "${VERSION}" - echo "::endgroup::" diff --git a/.gitignore b/.gitignore index 5eba6c3..4d77b65 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pdf *.log +images/ diff --git a/assets/banner.png b/assets/banner.png index d77e278..0e3b603 100644 Binary files a/assets/banner.png and b/assets/banner.png differ diff --git a/baker/banner.typ b/baker/banner.typ new file mode 100644 index 0000000..f2729a3 --- /dev/null +++ b/baker/banner.typ @@ -0,0 +1,59 @@ +#import "@preview/shadowed:0.1.2": shadowed + +#let LE = 10cm +#let shadow = 0.25cm + +#set page(margin: 0pt, width: 2 * LE, height: LE, fill: rgb(0, 0, 0, 0)) + +#place( + dx: 3cm, + dy: 1.1cm, + rotate( + -9deg, + shadowed( + radius: 0pt, + inset: 0pt, + blur: shadow, + image("./images/21.svg", height: LE * 0.6)))) + +#place( + dx: 1cm, + dy: 3.25cm, + rotate( + -20deg, + shadowed( + radius: 0pt, + inset: 0pt, + blur: shadow, + image("./images/51.svg", height: LE * 0.55)))) + +#place( + dx: 14cm, + dy: 1.5cm, + rotate( + 6deg, + shadowed( + radius: 0pt, + inset: 0pt, + blur: shadow, + image("./images/41.svg", height: LE * 0.65)))) + +#place( + dx: 11cm, + dy: 2cm, + rotate( + 25deg, + shadowed( + radius: 0pt, + inset: 0pt, + blur: shadow, + image("./images/31.svg", height: LE * 0.6)))) + +#place( + dx: 7cm, + dy: 0.75cm, + shadowed( + radius: 0pt, + inset: 0pt, + blur: shadow, + image("./images/11.svg", height: LE * 0.75))) diff --git a/baker/preview.typ b/baker/preview.typ new file mode 100644 index 0000000..cacc374 --- /dev/null +++ b/baker/preview.typ @@ -0,0 +1,34 @@ + +#let gap = 0.5cm + +#set page(margin: 0pt, width: 210mm * 3 + 2 * gap, height: 297mm * 2 + gap, fill: rgb(0, 0, 0, 0)) + +#place( + dx: 0mm, + dy: 0mm, + image("./images/11.svg", height: 297mm)) + +#place( + dx: 210mm + gap, + dy: 0mm, + image("./images/21.svg", height: 297mm)) + +#place( + dx: (210mm + gap) * 2, + dy: 0mm, + image("./images/31.svg", height: 297mm)) + +#place( + dx: 210mm * 0, + dy: 297mm + gap, + image("./images/71.svg", height: 297mm)) + +#place( + dx: (210mm + gap) * 1, + dy: 297mm + gap, + image("./images/41.svg", height: 297mm)) + +#place( + dx: (210mm + gap) * 2, + dy: 297mm + gap, + image("./images/51.svg", height: 297mm)) diff --git a/baker/run-bake-banner.sh b/baker/run-bake-banner.sh new file mode 100755 index 0000000..5dc1bc2 --- /dev/null +++ b/baker/run-bake-banner.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +echo "==> generate images" +mkdir images || true + +# extract images from document created by action +mutool convert -o images/1.svg "$1" 1 +mutool convert -o images/2.svg "$1" 2 +mutool convert -o images/2.svg "$1" 2 +mutool convert -o images/3.svg "$1" 5 +mutool convert -o images/7.svg "$1" 7 +mutool convert -o images/4.svg "$1" 15 +mutool convert -o images/5.svg "$1" 16 + +echo "==> generate banner" +typst compile banner.typ --ppi 360 ../assets/banner.png +echo "==> generate preview" +typst compile preview.typ --ppi 360 ../assets/page-preview.png diff --git a/baker/shell.nix b/baker/shell.nix new file mode 100644 index 0000000..b334270 --- /dev/null +++ b/baker/shell.nix @@ -0,0 +1,14 @@ +let + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-unstable"; + pkgs = import nixpkgs { config = {}; overlays = []; }; +in + +pkgs.mkShellNoCC { + packages = with pkgs; [ + python312 + python312Packages.pyyaml + typst + typstyle + mupdf-headless + ]; +} diff --git a/run-bake-assets.sh b/run-bake-assets.sh new file mode 100755 index 0000000..41f4315 --- /dev/null +++ b/run-bake-assets.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cd baker + +echo "==> generate assets" +nix-shell --run "./run-bake-banner.sh ../example.pdf" diff --git a/src/style.typ b/src/style.typ index 511adf0..9615f94 100644 --- a/src/style.typ +++ b/src/style.typ @@ -241,6 +241,7 @@ set page( paper: style.page.format, foreground: watermark(config), + background: [#rect(width: 100%, height: 100%, fill: white)], header-ascent: style.header.content-padding, footer-descent: style.header.content-padding, margin: (