Developing Typst Packages on Codeberg
Published
As you may know, there's a Typst package template that I maintain for the Typst community. The biggest feature of that template are probably the CI workflows that provide automated testing and publishing when you push your changes to Github.
I'm currently on a quest to move most of my open source activity to Codeberg, and since the biggest part of that is Typst packages, I have adapted the template's CI workflows to make it as simple as possible to use them with Forgejo Actions.
(Full out-of-the-box compatibility unfortunately doesn't work: custom actions like typst-community/setup-typst aren't resolved correctly on Codeberg, and qualifying them as https://github.com/typst-community/setup-typst doesn't work on Github. Also, some actions are not 100% compatible and need replacements or different parameters, and the runs-on option needs to be changed anyway.)
Nevertheless, if you are on Codeberg, ensko/typst-package-template can either be used as a template (beware, it contains some personal customizations of mine) or you can look at the diffs (particularly in the workflow files) to see what changes are needed to make them work on Codeberg—here's a short, deliberately inclomplete excerpt of these changes:
It boils down to
- change the
runs-onoptions fromubuntu-latesttocodeberg-tiny - prefix some custom actions with
https://github.com/ - change
actions/upload-artifacttoforgejo/upload-artifact, same foractions/download-artifact - replace
ncipollo/release-actionwithactions/forgejo-release, which requires changing the parameters a bit
Since you'll want to make PRs against https://github.com/typst/packages/, you'll still want a Github account and access token, but Codeberg actually makes this more convenient for you: Github doesn't let you set account-wide secrets for CI—that only works for organizations and single repositories—but Codeberg does. So you can configure a token with write access to your typst/packages fork once, and all your packages can automatically use it. As that's my preferred way, I have renamed the secret to TYPST_REGISTRY_TOKEN to not clash with any other REGISTRY_TOKEN you may be using.
The test workflow just needs to do basic authentication to download Typst and Tytanic, for which I use an (also user-wide) BASIC_GITHUB_TOKEN.
Recap
The Typst ecosystem is heavily centered around Github—which is understandable, as a lot of open source happens there, and you simply get better reach. But just because Typst itself is there does not mean you're forced to also host your packages there. Codeberg, which uses the Forgejo software, is fairly compatible with Github when it comes to CI, and in general you can access the Github parts of the Typst ecosystem with a suitable API token. The community's package template is now a bit closer to the needs of Forgejo users, so if you're on a Forgejo host like Codeberg, I hope this makes your life a bit easier.