Skip to content

Commit

Permalink
Merge main into sweep/add-sweep-config
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Dec 17, 2023
2 parents de07e48 + 831cd2a commit f27681e
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/install_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: install_test.sh
on:
push:
branches: "main"
paths-ignore:
- README.md
- LICENSE
- .gitignore
- .github/**
- "!.github/workflows/install_test.yml"
pull_request:
paths-ignore:
- README.md
- LICENSE
- .gitignore
- .github/**
- "!.github/workflows/install_test.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: shellcheck install.sh
install_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: bash ./install_test.sh
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# typst_install
🤖 curl | sh installer script for Typst

## Usage

Linux, macOS, WSL

```sh
curl -fsSL https://typst.community/install_typst/install.sh | sh
```

Windows

```ps1
irm https://typst.community/install_typst/install.ps1 | iex
```

## Development

GitHub Pages is enabled and pulls straight from the `main` branch's root folder.
That's how the `https://typst.community/typst_install/install.sh` script is
published. That means it's a good idea to **make sure that the `main` branch
always works!** 😉
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<meta http-equiv="refresh" content="0;url=https://github.com/typst-community/typst_install">
<script>location.replace("https://github.com/typst-community/typst_install")</script>
51 changes: 51 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env pwsh
# Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
# TODO(everyone): Keep this script simple and easily auditable.
# Forked from Deno's install.ps1 script

$ErrorActionPreference = 'Stop'

if ($v) {
$Version = "v${v}"
}
if ($Args.Length -eq 1) {
$Version = $Args.Get(0)
}

$TypstInstall = $env:TYPST_INSTALL
$BinDir = if ($TypstInstall) {
"${TypstInstall}\bin"
} else {
"${Home}\.typst\bin"
}

$TypstZip = "$BinDir\typst.zip"
$TypstExe = "$BinDir\typst.exe"
$Target = 'x86_64-pc-windows-msvc'

$DownloadUrl = if (!$Version) {
"https://github.com/typst/typst/releases/latest/download/typst-${Target}.zip"
} else {
"https://github.com/typst/typst/releases/download/${Version}/typst-${Target}.zip"
}

if (!(Test-Path $BinDir)) {
New-Item $BinDir -ItemType Directory | Out-Null
}

curl.exe -Lo $TypstZip $DownloadUrl

tar.exe xf $TypstZip -C $BinDir --strip-components=1

Remove-Item $TypstZip

$User = [System.EnvironmentVariableTarget]::User
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
if (!(";${Path};".ToLower() -like "*;${BinDir};*".ToLower())) {
[System.Environment]::SetEnvironmentVariable('Path', "${Path};${BinDir}", $User)
$Env:Path += ";${BinDir}"
}

Write-Output "Typst was installed successfully to ${TypstExe}"
Write-Output "Run 'typst --help' to get started"
Write-Output "Stuck? Join our Discord https://discord.gg/2uDybryKPe"
81 changes: 81 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/sh
# Copyright 2019 the Deno authors. All rights reserved. MIT license.
# TODO(everyone): Keep this script simple and easily auditable.
# Forked from Deno's install.sh script

set -e

use_unzip=false

if [ "$OS" = "Windows_NT" ]; then
target="x86_64-pc-windows-msvc"
use_unzip=true
else
case $(uname -sm) in
"Darwin x86_64") target="x86_64-apple-darwin" ;;
"Darwin arm64")
echo "Error: Official Typst builds for Darwin arm64 are not available." 1>&2 # (see: https://github.com/denoland/deno/issues/1846 )" 1>&2
exit 1
;;
"Linux aarch64")
echo "Error: Official Typst builds for Linux aarch64 are not available." 1>&2 # (see: https://github.com/denoland/deno/issues/1846 )" 1>&2
exit 1
;;
*) target="x86_64-unknown-linux-gnu" ;;
esac
fi

if [ "$use_unzip" = true ] && ! command -v unzip >/dev/null; then
echo "Error: unzip is required to install Typst." 1>&2 # (see: https://github.com/denoland/deno_install#unzip-is-required )." 1>&2
exit 1
fi

typst_install="${TYPST_INSTALL:-$HOME/.typst}"
bin_dir="$typst_install/bin"
exe="$bin_dir/typst"

if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
fi

if [ "$use_unzip" = true ]; then
if [ $# -eq 0 ]; then
typst_uri="https://github.com/typst/typst/releases/latest/download/typst-${target}.zip"
else
typst_uri="https://github.com/typst/typst/releases/download/${1}/typst-${target}.zip"
fi

curl --fail --location --progress-bar --output "$exe.zip" "$typst_uri"
unzip -d "$bin_dir" -o "$exe.zip"
mv "$bin_dir/typst-${target}/*" "$bin_dir"
chmod +x "$exe"
rm -r "$bin_dir/typst-${target}/*"
rm "$exe.zip"
else
if [ $# -eq 0 ]; then
typst_uri="https://github.com/typst/typst/releases/latest/download/typst-${target}.tar.gz"
else
typst_uri="https://github.com/typst/typst/releases/download/${1}/typst-${target}.tar.gz"
fi

curl --fail --location --progress-bar --output "$exe.tar.gz" "$typst_uri"
tar -xf "$exe.tar.gz" -C "$bin_dir" --strip-components=1
chmod +x "$exe"
rm "$exe.tar.gz"
fi

echo "Typst was installed successfully to $exe"
if command -v typst >/dev/null; then
echo "Run 'typst --help' to get started"
else
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".bashrc" ;;
esac
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
echo " export TYPST_INSTALL=\"$typst_install\""
echo " export PATH=\"\$TYPST_INSTALL/bin:\$PATH\""
echo "Run '$exe --help' to get started"
fi
echo
echo "Stuck? Join our Discord https://discord.gg/2uDybryKPe"
8 changes: 8 additions & 0 deletions install_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

if [ "$OS" = "Windows_NT" ]; then

else

fi

0 comments on commit f27681e

Please sign in to comment.