Skip to content

Commit

Permalink
Add support for Linux and macOS (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusancky authored Apr 14, 2023
1 parent f2285f6 commit a536a03
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Setup Typst

Setup Typst in GitHub Actions (currently only supported for Windows).
A cross-OS action for installing Typst.

## Inputs

Expand All @@ -15,7 +15,7 @@ Exact version of Typst to use.
## Example usage

```yaml
- uses: yusancky/setup-typst@v0.1
- uses: yusancky/setup-typst@v1
id: setup-typst
with:
version: 'v0.2.0'
Expand Down
55 changes: 46 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,68 @@
name: Setup Typst
author: yusancky
description: Setup Typst in GitHub Actions
description: A cross-OS action for installing Typst

inputs:
token:
description: The token used to authenticate when fetching Typst distributions. 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.
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
version:
description: Exact version of Typst to use.

runs:
using: composite
steps:
- name: Configure filenames (Linux)
run: |
echo "typst_asset_name=unknown-linux-gnu" >> $GITHUB_ENV
echo "typst_asset_zip_name=tar.gz" >> $GITHUB_ENV
shell: bash
if: runner.os == 'Linux'
- name: Configure filenames (Windows)
run: |
echo "typst_asset_name=pc-windows-msvc" >> $GITHUB_ENV
echo "typst_asset_zip_name=zip" >> $GITHUB_ENV
shell: bash
if: runner.os == 'Windows'
- name: Configure filenames (macOS)
run: |
echo "typst_asset_name=apple-darwin" >> $GITHUB_ENV
echo "typst_asset_zip_name=tar.gz" >> $GITHUB_ENV
shell: bash
if: runner.os == 'macOS'

- name: Download release
uses: robinraju/[email protected]
with:
repository: "typst/typst"
repository: typst/typst
tag: ${{ inputs.version }}
fileName: "typst-x86_64-pc-windows-msvc.zip"
fileName: ${{ format('typst-x86_64-{0}.{1}', env.typst_asset_name, env.typst_asset_zip_name) }}
token: ${{ inputs.token }}
- name: Unzip Typst
run: 7z x typst-x86_64-pc-windows-msvc.zip -oc:\typst typst.exe -r

- name: Unzip Typst (Linux, macOS)
run: |
sudo mkdir /usr/local/typst
${{ format('sudo tar -xzf typst-x86_64-{0}.{1} -C /usr/local/typst/', env.typst_asset_name, env.typst_asset_zip_name) }}
shell: bash
if: runner.os == 'Linux' || runner.os == 'macOS'
- name: Unzip Typst (Windows)
run: ${{ format('7z x typst-x86_64-{0}.{1} -oc:\typst', env.typst_asset_name, env.typst_asset_zip_name) }}
shell: bash
if: runner.os == 'Windows'

- name: Delete zip
run: rm -f typst-x86_64-pc-windows-msvc.zip
run: ${{ format('rm -f typst-x86_64-{0}.{1}', env.typst_asset_name, env.typst_asset_zip_name) }}
shell: bash

- name: Add system path (Linux, macOS)
run: ${{ format('echo "/usr/local/typst/typst-x86_64-{0}" >> $GITHUB_PATH', env.typst_asset_name) }}
shell: bash
- name: Add system path
run: echo "c:\typst\typst-x86_64-pc-windows-msvc" >> $GITHUB_PATH
if: runner.os == 'Linux' || runner.os == 'macOS'
- name: Add system path (Windows)
run: ${{ format('echo "c:\typst\typst-x86_64-{0}" >> $GITHUB_PATH', env.typst_asset_name) }}
shell: bash
if: runner.os == 'Windows'

branding:
color: blue
color: orange
icon: download

0 comments on commit a536a03

Please sign in to comment.