Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache Typst packages #16

Merged
merged 9 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ jobs:
- run: npm ci
- run: npm run build
- uses: ./
with:
cache-dependency-path: test/requirements.typ
- run: typst --version
- run: typst compile test.typ
- run: typst compile test/test.typ
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 yusancky
Copyright (c) 2023-2024 yusancky

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Setup Typst

📑 Install Typst for use in GitHub Actions
📑 Install Typst for GitHub Actions \
⚡ Caches Typst installation \
📦 Caches [packages](https://github.com/typst/packages) as dependencies

<table align=center><td>

Expand All @@ -11,9 +13,6 @@

</table>

📝 Installs [Typst] for GitHub Actions \
⚡ Caches installation files

## Usage

![GitHub Actions](https://img.shields.io/static/v1?style=for-the-badge&message=GitHub+Actions&color=2088FF&logo=GitHub+Actions&logoColor=FFFFFF&label=)
Expand All @@ -28,7 +27,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: typst-community/setup-typst@v3
# Now Typst is installed!
with:
cache-dependency-path: requirements.typ
# Now Typst is installed and packages will be cached!
- run: typst compile paper.typ paper.pdf
- uses: actions/upload-artifact@v4
with:
Expand All @@ -38,30 +39,35 @@ jobs:

### Inputs

- **`typst-token`:** The GitHub token to use when pulling versions from
[typst/typst]. By default this should cover all cases. You shouldn't have to
touch this setting.
- **`typst-token`:** The GitHub token to use when pulling
versions from [typst/typst]. By default this should cover all
cases. You shouldn't have to touch this setting.

- **`typst-version`:** The version of Typst to install. This can
be an exact version like `0.10.0` or a semver range like
`0.10` or `0.x`. You can also specify `latest` to always use
the latest version. The default is `latest`.

- **`typst-version`:** Which version of `typst` to install. This can be an exact
version like `0.10.0` or a semver range like `0.10` or `0.x`. You can also
specify `latest` to always use the latest version. The default is `latest`.
- **`cache-dependency-path`:** Used to specify the path to
dependency file. Supports a Typst file with lines of
'import' keyword.

### Outputs

- **`typst-version`:** The version of `typst` that was installed. This will be
something like `0.10.0` or similar.
- **`typst-version`:** The version of `typst` that was
installed. This will be something like `0.10.0` or similar.

- **`cache-hit`:** Whether or not Typst was restored from the runner's cache or
download anew.
- **`cache-hit`:** Whether or not Typst was restored from the
runner's cache or download anew.

## Development

![Node.js](https://img.shields.io/static/v1?style=for-the-badge&message=Node.js&color=339933&logo=Node.js&logoColor=FFFFFF&label=)

**How do I test my changes?**

Open a Draft Pull Request and some magic GitHub Actions will run to test the
action.
Open a draft Pull Request and some magic GitHub Actions will run
to test the action.

[typst]: https://typst.app/
[typst/typst]: https://github.com/typst/typst
27 changes: 17 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,34 @@ branding:
inputs:
typst-token:
description: >
The GitHub token to use when pulling versions from typst/typst. By default
this should cover all cases. You shouldn't have to touch this setting.
The GitHub token to use when pulling versions from
typst/typst. By default this should cover all cases.
You shouldn't have to touch this setting.
default:
${{ github.server_url == 'https://github.com' && github.token || '' }}
typst-version:
description: >
Which version of 'typst' to install. This can be an exact version like
'0.10.0' or a semver range like '0.10' or '0.x'. You can also specify
'latest' to always use the latest version. The default is 'latest'.
The version of Typst to install. This can be an exact
version like '0.10.0' or a semver range like '0.10' or
'0.x'. You can also specify 'latest' to always use the
latest version. The default is 'latest'.
default: latest
cache-dependency-path:
description: >
Used to specify the path to dependency file. Supports a
Typst file with lines of 'import' keyword.
required: false

outputs:
typst-version:
description: >
The version of 'typst' that was installed. This will be something like
'0.10.0' or similar.
The version of 'typst' that was installed. This will be
something like '0.10.0' or similar.
cache-hit:
description: >
Whether or not Typst was restored from the runner's cache or download
anew.
Whether or not Typst was restored from the runner's cache
or download anew.

runs:
using: node20
main: dist/main.js
main: dist/main/index.js
Loading