ci: autogen-banner (#118)
Create Release Commit / prepare (push) Has been cancelled Details

Reviewed-on: #118
Release-As: v0.6.1
Generate-Assets
This commit is contained in:
Sven Vogel 2024-11-30 19:04:13 +00:00
parent a8d2161efa
commit a6d0d70f08
9 changed files with 159 additions and 9 deletions

View File

@ -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::"

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.pdf
*.log
images/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

After

Width:  |  Height:  |  Size: 638 KiB

59
baker/banner.typ Normal file
View File

@ -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)))

34
baker/preview.typ Normal file
View File

@ -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))

18
baker/run-bake-banner.sh Executable file
View File

@ -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

14
baker/shell.nix Normal file
View File

@ -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
];
}

6
run-bake-assets.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
cd baker
echo "==> generate assets"
nix-shell --run "./run-bake-banner.sh ../example.pdf"

View File

@ -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: (