Add typst role
This commit is contained in:
parent
77a4fdcc16
commit
d41ea98da0
@ -30,6 +30,7 @@
|
||||
- role: ripgrep
|
||||
- role: tidy
|
||||
- role: tree
|
||||
- role: typst
|
||||
- role: watch
|
||||
- role: wget
|
||||
- role: yq
|
||||
|
@ -20,6 +20,7 @@
|
||||
- role: jq
|
||||
- role: ripgrep
|
||||
- role: tree
|
||||
- role: typst
|
||||
- role: yq
|
||||
|
||||
- role: llvm
|
||||
|
76
roles/typst/tasks/Linux.yaml
Normal file
76
roles/typst/tasks/Linux.yaml
Normal file
@ -0,0 +1,76 @@
|
||||
---
|
||||
- name: get latest github release
|
||||
uri:
|
||||
url: https://api.github.com/repos/typst/typst/releases/latest
|
||||
headers: '{{github_auth_headers}}'
|
||||
register: latest
|
||||
|
||||
- set_fact:
|
||||
asset_name: >-
|
||||
{{
|
||||
{
|
||||
'amd64': 'typst-x86_64-unknown-linux-musl',
|
||||
'x86_64': 'typst-x86_64-unknown-linux-musl',
|
||||
'arm64': 'typst-aarch64-unknown-linux-musl',
|
||||
}[ansible_architecture]
|
||||
}}
|
||||
|
||||
- set_fact:
|
||||
asset_query: '[?contains(name, `{{asset_name}}.tar.xz`)] | [0]'
|
||||
assets: '{{latest.json.assets}}'
|
||||
asset_archive: '{{asset_name}}.tar.xz'
|
||||
latest_version: '{{latest.json.tag_name}}'
|
||||
exe: '{{ansible_env.HOME}}/.local/bin/typst'
|
||||
|
||||
- name: check if already installed
|
||||
stat:
|
||||
path: '{{exe}}'
|
||||
register: stat_exe
|
||||
|
||||
- name: get installed version
|
||||
when: stat_exe.stat.exists == True
|
||||
command: '{{exe}} --version'
|
||||
register: version_output
|
||||
changed_when: false
|
||||
|
||||
- when: stat_exe.stat.exists == True
|
||||
set_fact:
|
||||
installed_version:
|
||||
'v{{version_output.stdout.strip() | regex_replace("^.*(\d+\.\d+\.\d+).*$", "\1")}}'
|
||||
|
||||
- set_fact:
|
||||
asset: '{{assets | to_json | from_json | json_query(asset_query)}}'
|
||||
|
||||
- name: download archive
|
||||
when: installed_version is not defined or installed_version != latest_version
|
||||
get_url:
|
||||
url: '{{asset.browser_download_url}}'
|
||||
dest: '/tmp/{{asset_archive}}'
|
||||
environment: '{{proxy_environment}}'
|
||||
|
||||
- name: extract archive
|
||||
when: installed_version is not defined or installed_version != latest_version
|
||||
unarchive:
|
||||
src: '/tmp/{{asset_archive}}'
|
||||
dest: '/tmp'
|
||||
|
||||
- name: remove archive
|
||||
when: installed_version is not defined or installed_version != latest_version
|
||||
file:
|
||||
state: absent
|
||||
path: '/tmp/{{asset_archive}}'
|
||||
|
||||
- name: copy executable
|
||||
when: installed_version is not defined or installed_version != latest_version
|
||||
copy:
|
||||
src: '/tmp/{{asset_name}}/typst'
|
||||
dest: '{{exe}}'
|
||||
mode: +x
|
||||
|
||||
- name: remove extraced archive
|
||||
when: installed_version is not defined or installed_version != latest_version
|
||||
file:
|
||||
state: absent
|
||||
path: '/tmp/{{asset_archive}}'
|
||||
|
||||
# TODO: install zsh completions
|
15
roles/typst/tasks/main.yaml
Normal file
15
roles/typst/tasks/main.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: install homebrew package
|
||||
when: ansible_os_family == 'Darwin'
|
||||
homebrew:
|
||||
state: latest
|
||||
name: typst
|
||||
|
||||
- name: install scoop package
|
||||
when: ansible_os_family == 'Windows'
|
||||
community.windows.win_scoop:
|
||||
state: present
|
||||
name: typst
|
||||
|
||||
- when: ansible_os_family != 'Darwin' and ansible_os_family != 'Windows'
|
||||
include_tasks: Linux.yaml
|
Loading…
x
Reference in New Issue
Block a user