Skip to content

Commit 20e8ad0

Browse files
authored
Initial commit
0 parents  commit 20e8ad0

File tree

21 files changed

+746
-0
lines changed

21 files changed

+746
-0
lines changed

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Package and push to registry repo
2+
on:
3+
push:
4+
tags: [ v* ]
5+
6+
env:
7+
# the repository to which to push the release version
8+
# usually a fork of typst/packages (https://github.com/typst/packages/)
9+
# that you have push privileges to
10+
REGISTRY_REPO: author/typst-packages
11+
# the path within that repo where the "<name>/<version>" directory should be put
12+
# for the Typst package registry, keep this as is
13+
PATH_PREFIX: packages/preview
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Install just
23+
uses: taiki-e/install-action@v2
24+
with:
25+
tool: just
26+
27+
- name: Setup typst
28+
uses: typst-community/setup-typst@v4
29+
with:
30+
typst-version: latest
31+
32+
- name: Determine and check package metadata
33+
run: |
34+
. scripts/setup
35+
echo "PKG_NAME=${PKG_PREFIX}" >> "${GITHUB_ENV}"
36+
echo "PKG_VERSION=${VERSION}" >> "${GITHUB_ENV}"
37+
38+
if [[ "${GITHUB_REF_NAME}" != "v${VERSION}" ]]; then
39+
echo "package version ${VERSION} does not match release tag ${GITHUB_REF_NAME}" >&2
40+
exit 1
41+
fi
42+
43+
- name: Build package
44+
run: |
45+
just doc
46+
just package out
47+
48+
- name: Checkout package registry
49+
uses: actions/checkout@v4
50+
with:
51+
repository: ${{ env.REGISTRY_REPO }}
52+
token: ${{ secrets.REGISTRY_TOKEN }}
53+
path: typst-packages
54+
55+
- name: Release package
56+
run: |
57+
mkdir -p "typst-packages/${{ env.PATH_PREFIX }}/$PKG_NAME"
58+
mv "out/${PKG_NAME}/${PKG_VERSION}" "typst-packages/${{ env.PATH_PREFIX }}/${PKG_NAME}"
59+
rmdir "out/${PKG_NAME}"
60+
rmdir out
61+
62+
GIT_USER_NAME="$(git log -1 --pretty=format:'%an')"
63+
GIT_USER_EMAIL="$(git log -1 --pretty=format:'%ae')"
64+
65+
cd typst-packages
66+
git config user.name "${GIT_USER_NAME}"
67+
git config user.email "${GIT_USER_EMAIL}"
68+
git checkout -b "${PKG_NAME}-${PKG_VERSION}"
69+
git add .
70+
git commit -m "${PKG_NAME}:${PKG_VERSION}"
71+
git push --set-upstream origin "${PKG_NAME}-${PKG_VERSION}"

.github/workflows/tests.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches: [ main ]
5+
pull_request:
6+
branches: [ main ]
7+
8+
jobs:
9+
tests:
10+
strategy:
11+
# run tests on all versions, even if one fails
12+
fail-fast: false
13+
matrix:
14+
# add any other Typst versions that your package should support
15+
typst-version:
16+
- typst: 0.12
17+
tytanic: 0.1
18+
- typst: 0.13
19+
tytanic: 0.2
20+
# the docs don't need to build with all versions supported by the package;
21+
# the latest one is enough
22+
doc: true
23+
24+
name: Test for ${{ matrix.typst-version.typst }} (Tytanic ${{ matrix.typst-version.tytanic }}${{ matrix.typst-version.doc && ', with docs' }})
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Install just
32+
uses: taiki-e/install-action@v2
33+
with:
34+
tool: just
35+
36+
- name: Install tytanic
37+
uses: typst-community/setup-tytanic@v1
38+
with:
39+
tytanic-version: ${{ matrix.typst-version.tytanic }}
40+
41+
- name: Setup typst
42+
id: setup-typst
43+
uses: typst-community/setup-typst@v4
44+
with:
45+
typst-version: ${{ matrix.typst-version.typst }}
46+
47+
- name: Run test suite
48+
run: just test
49+
50+
- name: Archive test results
51+
uses: actions/upload-artifact@v4
52+
if: always()
53+
with:
54+
name: typst-${{ steps.setup-typst.outputs.typst-version }}-test-results
55+
path: |
56+
tests/**/diff/*.png
57+
tests/**/out/*.png
58+
tests/**/ref/*.png
59+
retention-days: 5
60+
61+
- name: Build docs
62+
if: ${{ matrix.typst-version.doc }}
63+
run: just doc

.typstignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# this is not a "standard" ignore file, it's specific to this template's `scripts/package` script
2+
# list any files here that should not be uploaded to Universe when releasing this package
3+
4+
# if you are used to ignore files, be aware that .typstignore is a bit more limited:
5+
# - only this file is used; .typstignore files in subdirectories are not considered
6+
# - patterns must match file/directory names from the beginning: `x.typ` will not match `src/x.typ`
7+
# - `*` in patterns works, but also matches directory separators: `*.typ` _will_ match `src/x.typ`
8+
# .git and .typstignore are excluded automatically
9+
10+
.github
11+
scripts
12+
tests
13+
Justfile
14+
# PDF manuals should be included so that they can be linked, but not their sources
15+
docs/*
16+
!docs/*.pdf

CHANGELOG.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
<details>
11+
<summary>Migration guide from v0.1.X</summary>
12+
13+
<!-- Write migration guide here -->
14+
15+
</details>
16+
17+
### Added
18+
19+
### Changed
20+
21+
### Deprecated
22+
23+
### Removed
24+
25+
### Fixed
26+
27+
### Security
28+
29+
## [0.1.0] - 2025-01-01
30+
31+
### Added
32+
33+
<!-- Describe the feature set of the initial release here -->
34+
-
35+
-
36+
-
37+
38+
<!--
39+
Below are the target URLs for each version
40+
You can link version numbers (in level-2 headings)
41+
to the corresponding tag on GitHub, or the diff
42+
in comparison to the previous release
43+
-->
44+
45+
[Unreleased]: https://github.com/<author>/<my-package>/compare/v0.1.0...HEAD
46+
[0.1.0]: https://github.com/<author>/<my-package>/releases/tag/v0.1.0

Justfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
root := justfile_directory()
2+
3+
export TYPST_ROOT := root
4+
5+
[private]
6+
default:
7+
@just --list --unsorted
8+
9+
# generate manual
10+
doc:
11+
typst compile docs/manual.typ docs/manual.pdf
12+
typst compile docs/thumbnail.typ thumbnail-light.svg
13+
typst compile --input theme=dark docs/thumbnail.typ thumbnail-dark.svg
14+
15+
# run test suite
16+
test *args:
17+
tt run {{ args }}
18+
19+
# update test cases
20+
update *args:
21+
tt update {{ args }}
22+
23+
# package the library into the specified destination folder
24+
package target:
25+
./scripts/package "{{target}}"
26+
27+
# install the library with the "@local" prefix
28+
install: (package "@local")
29+
30+
# install the library with the "@preview" prefix (for pre-release testing)
31+
install-preview: (package "@preview")
32+
33+
[private]
34+
remove target:
35+
./scripts/uninstall "{{target}}"
36+
37+
# uninstalls the library from the "@local" prefix
38+
uninstall: (remove "@local")
39+
40+
# uninstalls the library from the "@preview" prefix (for pre-release testing)
41+
uninstall-preview: (remove "@preview")
42+
43+
# run ci suite
44+
ci: test doc

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org/>

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# The `my-package` Package
2+
<div align="center">Version 0.1.0</div>
3+
4+
A short description about the project and/or client.
5+
6+
## Template adaptation checklist
7+
8+
- [ ] Fill out `README.md`
9+
- Change the `my-package` package name, including code snippets
10+
- Check section contents and/or delete sections that don't apply
11+
- [ ] Check and/or replace `LICENSE` by something that suits your needs
12+
- [ ] Fill out `typst.toml`
13+
- See also the [typst/packages README](https://github.com/typst/packages/?tab=readme-ov-file#package-format)
14+
- [ ] Adapt Repository URLs in `CHANGELOG.md`
15+
- Consider only committing that file with your first release, or removing the "Initial Release" part in the beginning
16+
- [ ] Adapt or deactivate the release workflow in `.github/workflows/release.yml`
17+
- to deactivate it, delete that file or remove/comment out lines 2-4 (`on:` and following)
18+
- to use the workflow
19+
- [ ] check the values under `env:`, particularly `REGISTRY_REPO`
20+
- [ ] if you don't have one, [create a fine-grained personal access token](https://github.com/settings/tokens?type=beta) with [only Contents permission](https://stackoverflow.com/a/75116350/371191) for the `REGISTRY_REPO`
21+
- [ ] on this repo, create a secret `REGISTRY_TOKEN` (at `https://github.com/[user]/[repo]/settings/secrets/actions`) that contains the so created token
22+
23+
if configured correctly, whenever you create a tag `v...`, your package will be pushed onto a branch on the `REGISTRY_REPO`, from which you can then create a pull request against [typst/packages](https://github.com/typst/packages/)
24+
- [ ] remove/replace the example test case
25+
- [ ] (add your actual code, docs and tests)
26+
- [ ] remove this section from the README
27+
28+
## Getting Started
29+
30+
These instructions will get you a copy of the project up and running on the typst web app. Perhaps a short code example on importing the package and a very simple teaser usage.
31+
32+
```typ
33+
#import "@preview/my-package:0.1.0": *
34+
35+
#show: my-show-rule.with()
36+
#my-func()
37+
```
38+
39+
<picture>
40+
<source media="(prefers-color-scheme: dark)" srcset="./thumbnail-dark.svg">
41+
<img src="./thumbnail-light.svg">
42+
</picture>
43+
44+
### Installation
45+
46+
A step by step guide that will tell you how to get the development environment up and running. This should explain how to clone the repo and where to (maybe a link to the typst documentation on it), along with any pre-requisite software and installation steps.
47+
48+
```
49+
$ First step
50+
$ Another step
51+
$ Final step
52+
```
53+
54+
## Usage
55+
56+
A more in-depth description of usage. Any template arguments? A complicated example that showcases most if not all of the functions the package provides? This is also an excellent place to signpost the manual.
57+
58+
```typ
59+
#import "@preview/my-package:0.1.0": *
60+
61+
#let my-complicated-example = ...
62+
```
63+
64+
## Additional Documentation and Acknowledgments
65+
66+
* Project folder on server:
67+
* Confluence link:
68+
* Asana board:
69+
* etc...

docs/manual.typ

Whitespace-only changes.

docs/thumbnail.typ

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#import "/src/lib.typ" as my-package: *
2+
3+
#set page(height: auto, margin: 5mm, fill: none)
4+
5+
// style thumbnail for light and dark theme
6+
#let theme = sys.inputs.at("theme", default: "light")
7+
#set text(white) if theme == "dark"
8+
9+
#set text(22pt)
10+
#align(center)[_a thumbnail showing the package's output_]

0 commit comments

Comments
 (0)