Add Github Workflow Template for Automatic PDF generation on releases
Personally, I use the following config to render my exposé and thesis PDFs with each new release on GitHub.
However, it requires:
- to a font called
assets/fonts/Palatino.ttcin the repo (unsure about the license, hence won't distribute) - to have a
.releaserc.mjsto generate aCHANGELOG.mdautomatically based on [Conventional Commits] (https://www.conventionalcommits.org/en/v1.0.0/), which might not suit everyone, and only runs for new releases, when theRelease workflow is triggered manually.
Ideally, make it more customizable than this example:
Details for `.github/workflow.yaml`:
name: Release
on:
workflow_dispatch:
permissions:
packages: write # to be able to publish packages
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Update submodules
run: git submodule update --init --recursive
- name: Install Palatino font
run: |
mkdir -p ~/.fonts
cp assets/fonts/Palatino.ttc ~/.fonts/palatino.ttc
fc-cache -fv
- name: Set up Typst
uses: typst-community/setup-typst@v3
- name: Run semantic-release
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: cycjimmy/semantic-release-action@v5
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/exec
@semantic-release/git
@semantic-release/github
Details for `.releaserc.mjs`:
/** @type {import('semantic-release').GlobalConfig} */
export default {
preset: 'angular',
tagFormat: 'v${version}',
branches: ["main"],
repositoryUrl: 'https://github.com/<user>/<repo>.git',
plugins: [
[
"@semantic-release/commit-analyzer",
{
preset: "angular",
releaseRules: [
{ type: "thesis", release: "minor" },
{ type: "expose", release: "minor" }
]
}
],
[
"@semantic-release/release-notes-generator",
{
preset: "angular",
presetConfig: {
types: [
{ type: "feat", section: "Features" },
{ type: "fix", section: "Bug Fixes" },
{ type: "thesis", section: "Thesis" },
{ type: "expose", section: "Expose" },
{ type: "perf", section: "Performance Improvements" },
{ type: "revert", section: "Reverts" },
{ type: "docs", section: "Documentation" },
{ type: "style", section: "Styles" },
{ type: "chore", section: "Miscellaneous Chores", hidden: false },
{ type: "refactor", section: "Code Refactoring" },
{ type: "test", section: "Tests" },
{ type: "build", section: "Build System" },
{ type: "ci", section: "Continuous Integration" }
]
},
writerOpts: {
groupBy: "scope"
}
}
],
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
prepareCmd: "typst compile expose.typ expose_v${nextRelease.version}.pdf && typst compile thesis.typ thesis_v${nextRelease.version}.pdf"
}
],
[
"@semantic-release/github",
{
assets: [
{ path: "expose_*.pdf", label: "Expose PDF" },
{ path: "thesis_*.pdf", label: "Thesis PDF" }
]
}
],
[
"@semantic-release/git",
{
assets: ["CHANGELOG.md"],
message: "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}