Skip to content

Commit 0bb64c6

Browse files
authored
Allow installing multiple Typst versions at once (#58)
resolve #53 ## Important Changes - Added a new input parameter: `typst-versions-map`, which allows installing multiple Typst versions at once. - Removed the following original outputs due to the support for multiple simultaneous Typst installations: - `typst-version`: The installed Typst version. Useful when given a version range as input. - `cache-hit`: A boolean value to indicate a cache entry was found.
1 parent cf80824 commit 0bb64c6

File tree

5 files changed

+208
-64
lines changed

5 files changed

+208
-64
lines changed

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,30 @@ jobs:
8080
- run: typst-latest compile test/basic/main.typ
8181
- run: typst-013 --version
8282
- run: typst-013 compile test/basic/main.typ
83+
test-versions-map:
84+
runs-on: ${{ matrix.os }}
85+
needs: [build, test-basic]
86+
strategy:
87+
fail-fast: false
88+
matrix:
89+
os: [ubuntu-latest, macos-latest, windows-latest]
90+
steps:
91+
- uses: actions/checkout@v4
92+
- uses: actions/download-artifact@v4
93+
with:
94+
name: action-dist
95+
path: ./dist
96+
- uses: ./
97+
with:
98+
typst-versions-map: |
99+
{
100+
"typst-latest": {"version": "latest"},
101+
"typst-013": {"version": "v0.13"}
102+
}
103+
- run: typst-latest --version
104+
- run: typst-latest compile test/basic/main.typ
105+
- run: typst-013 --version
106+
- run: typst-013 compile test/basic/main.typ
83107
test-zip-packages:
84108
runs-on: ${{ matrix.os }}
85109
needs: [build, test-basic]

README.md

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ jobs:
3434
3535
### Inputs
3636
37-
#### Specifying Typst Versions
37+
#### Installing A Typst Version
3838
3939
- **`typst-version`:** Version range or exact version of Typst to use, using SemVer's version range syntax. Uses the latest version if unset.
4040
- **`allow-prereleases`:** When `true`, a version range including `latest` passed to `typst-version` input will match prerelease versions.
41+
**`executable-name`:** Used to specify the executable file name of Typst.
4142

4243
```yaml
4344
# Example 1
@@ -50,25 +51,41 @@ jobs:
5051
with:
5152
typst-version: 0.14.0-rc1
5253
allow-prereleases: true
53-
```
54-
55-
#### Specifying Typst Executable File Name
5654
57-
**`executable-name`:** Used to specify the executable file name of Typst.
58-
59-
```yaml
55+
# Example 3
6056
- uses: typst-community/setup-typst@v4
6157
with:
6258
executable-name: typst-latest
63-
- run: typst-latest compile paper.typ paper.pdf
6459
```
6560

6661
> [!TIP]
6762
>
6863
> - `executable-name` defaults to `typst`.
6964
> - A Typst executable named `typst-${version}` is always kept.
7065
> - For Windows, there is no need to include the executable file extension `.exe` in the parameters.
71-
> - Multiple distinct `executable-name` values can be set for the same Typst version. Setting the same `executable-name` (including the default `typst`) for different Typst versions is **not recommended**, as it may lead to version management confusion.
66+
> - Multiple distinct `executable-name` values can be set for the same Typst version.
67+
> - Setting the same `executable-name` (including the default `typst`) for different Typst versions is **not recommended**, as it may lead to version management confusion.
68+
69+
#### Installing Multiple Typst Versions
70+
71+
**`typst-versions-map`:** Used to specify a JSON map of executable names to Typst version configurations, for installing multiple Typst versions at once. Each value is an object with a required `version` field and an optional `allowPrerelease` field.
72+
73+
> [!NOTE]
74+
>
75+
> When `typst-versions-map` is set, `typst-version` and `executable-name` are **ignored**. The `allow-prereleases` input is used as the **default value** for all entries in the map, but can be **overridden** by `allowPrerelease` in each individual config object.
76+
77+
```yaml
78+
- uses: typst-community/setup-typst@v4
79+
with:
80+
typst-versions-map: |
81+
{
82+
"typst-latest": {"version": "latest"},
83+
"typst-013": {
84+
"version": "v0.13",
85+
"allowPrerelease": true
86+
}
87+
}
88+
```
7289

7390
#### Managing Packages with Cache
7491

@@ -121,11 +138,6 @@ jobs:
121138

122139
**`token`:** The token used to authenticate when fetching Typst distributions from [typst/typst]. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
123140

124-
### Outputs
125-
126-
- **`typst-version`:** The installed Typst version. Useful when given a version range as input.
127-
- **`cache-hit`:** A boolean value to indicate a cache entry was found.
128-
129141
### Integration with Other Actions
130142

131143
#### Uploading Artifacts

README_zh-Hans-CN.md

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ jobs:
3434
3535
### 输入
3636
37-
#### 指定 Typst 版本
37+
#### 安装单个 Typst 版本
3838
3939
- **`typst-version`:** 使用的 Typst 版本范围或确切版本,采用 SemVer 语义化版本范围语法。默认使用最新版本。
4040
- **`allow-prereleases`:** 当设置为 `true` 时,传递给 `typst-version` 的版本范围(包含 `latest`)将匹配预发布版本。
41+
**`executable-name`:** 指定的 Typst 可执行文件的名称。
4142

4243
```yaml
4344
# Example 1
@@ -50,25 +51,41 @@ jobs:
5051
with:
5152
typst-version: 0.14.0-rc1
5253
allow-prereleases: true
53-
```
54-
55-
#### 指定 Typst 可执行文件名
5654
57-
**`executable-name`:** 指定的 Typst 可执行文件的名称。
58-
59-
```yaml
55+
# Example 3
6056
- uses: typst-community/setup-typst@v4
6157
with:
62-
executable-name: typst-latest
63-
- run: typst-latest compile paper.typ paper.pdf
58+
executable-name: typst-latest
6459
```
6560

6661
> [!TIP]
6762
>
6863
> - `executable-name` 默认为 `typst`。
6964
> - 一份名为 `typst-${version}` 的 Typst 可执行文件总是被保存。
7065
> - 对于 Windows,不需要在参数中设置可执行文件后缀名 `.exe`。
71-
> - 可以为同一版本 Typst 设置多个不同的 `executable-name`。**不推荐** 对不同版本 Typst 设置相同的 `executable-name`(包括默认的 `typst`),因为这可能导致版本管理混乱。
66+
> - 可以为同一版本 Typst 设置多个不同的 `executable-name`。
67+
> - **不推荐** 对不同版本 Typst 设置相同的 `executable-name`(包括默认的 `typst`),因为这可能导致版本管理混乱。
68+
69+
#### 同时安装多个 Typst 版本
70+
71+
**`typst-versions-map`:** 用于指定一个以可执行文件名为键、Typst 版本配置为值的 JSON 映射,以同时安装多个 Typst 版本。每个值是一个包含必填 `version` 字段和可选 `allowPrerelease` 字段的对象。
72+
73+
> [!NOTE]
74+
>
75+
> 当 `typst-versions-map` 被设置时,`typst-version` 和 `executable-name` 将被**忽略**。`allow-prereleases` 输入将作为映射中所有条目的**默认值**,但可被各条目中的 `allowPrerelease` 字段**覆盖**。
76+
77+
```yaml
78+
- uses: typst-community/setup-typst@v4
79+
with:
80+
typst-versions-map: |
81+
{
82+
"typst-latest": {"version": "latest"},
83+
"typst-013": {
84+
"version": "v0.13",
85+
"allowPrerelease": true
86+
}
87+
}
88+
```
7289

7390
#### 包管理与缓存
7491

@@ -121,11 +138,6 @@ jobs:
121138

122139
**`token`:** 当从 [typst/typst] 拉取版本时使用的 GitHub 令牌。当在 github.com 上运行操作时,使用默认值;当在 GitHub Enterprise Server(GHES)上运行,可以传递一个 github.com 的个人访问令牌规避速率限制问题。
123140

124-
### 输出
125-
126-
- **`typst-version`:** 安装的 Typst 的确切版本。在输入时给定版本范围时可能有用。
127-
- **`cache-hit`:** 一个表示是否找到 Typst 缓存的布尔值。
128-
129141
### 与其它操作组合使用
130142

131143
#### 上传构件

action.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ inputs:
1515
executable-name:
1616
description: "Used to specify the executable file name of Typst."
1717
default: typst
18+
typst-versions-map:
19+
description: "Used to specify a JSON map of executable names to Typst version configurations, for installing multiple Typst versions at once. Each value is an object with a required 'version' field and an optional 'allowPrerelease' field."
20+
required: false
1821
cache-dependency-path:
1922
description: "Used to specify the path to a Typst file containing lines of 'import' keyword."
2023
required: false
@@ -31,12 +34,6 @@ inputs:
3134
description: "The token used to authenticate when fetching Typst distributions from typst/typst. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting."
3235
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
3336

34-
outputs:
35-
typst-version:
36-
description: "The installed Typst version. Useful when given a version range as input."
37-
cache-hit:
38-
description: "A boolean value to indicate a cache entry was found."
39-
4037
runs:
4138
using: node20
4239
main: dist/main/index.js

0 commit comments

Comments
 (0)