-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yml
150 lines (145 loc) · 6.38 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Setup TeX Live
author: Paolo Brasolin <[email protected]>
description: GHA action to setup TeX Live
branding:
icon: book-open
color: blue
inputs:
profile-path:
description: File path of a tlmgr profile. The default is a `scheme-infraonly` with no documentation or source files. You use it as a starting point, see https://github.com/paolobrasolin/setup-texlive-action/blob/main/texlive.profile
required: false
default: ${{ github.action_path }}${{ runner.os == 'Windows' && '\' || '/'}}texlive.profile
packages-path:
description: File path of a package list (plain text, one per line). The default is an empty file.
required: false
default: ${{ github.action_path }}${{ runner.os == 'Windows' && '\' || '/'}}texlive.packages
cache-key:
description: The unique key to use for cache storage and retrieval. The default is `texlive`.
required: false
default: 'texlive'
cache-enabled:
description: Option to disable caching. Default is `false`.
required: false
default: true
installation-path:
description: Path where TeX Live will be installed. The default `texlive`, inside the runner's tool cache path.
required: false
default: ${{ runner.tool_cache }}${{ runner.os == 'Windows' && '\' || '/'}}texlive
outputs: {}
runs:
using: "composite"
steps:
- name: Cache TeX Live installation
uses: actions/cache@v3
id: cache-texlive
if: inputs.cache-enabled == 'true'
with:
path: ${{ inputs.installation-path }}
key: ${{ inputs.cache-key }}-${{ hashFiles(inputs.profile-path, inputs.packages-path) }}
restore-keys: ${{ inputs.cache-key }}-
- name: Install TeX Live distribution (Windows)
if: runner.os == 'Windows' && steps.cache-texlive.outputs.cache-hit != 'true'
env:
TEXLIVE_INSTALL_PREFIX: ${{ inputs.installation-path }}
TEXLIVE_PROFILE_PATH: ${{ inputs.profile-path }}
shell: powershell
run: |
# Install TeX Live distribution (Windows)
## Check into temporary folder
Set-Location -Path ${{ runner.temp }}
## Download installer
Invoke-WebRequest http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip -OutFile install-tl.zip
## Unpack installer
Expand-Archive -Path install-tl.zip -DestinationPath .
## Check into unpacked installer folder
Set-Location -Path install-tl-20*
## Run installer with given profile
.\install-tl-windows.bat --portable --profile="${env:TEXLIVE_PROFILE_PATH}"
- name: Install TeX Live distribution (Linux or macOS)
if: runner.os != 'Windows' && steps.cache-texlive.outputs.cache-hit != 'true'
env:
TEXLIVE_INSTALL_PREFIX: ${{ inputs.installation-path }}
TEXLIVE_PROFILE_PATH: ${{ inputs.profile-path }}
shell: bash
run: |
# Install TeX Live distribution (Linux or macOS)
## Check into temporary folder
cd ${{ runner.temp }}
## Download installer
wget --quiet http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
## Unpack installer
tar -xzf install-tl-unx.tar.gz
## Check into unpacked installer folder
cd install-tl-20*
## Run installer with given profile
./install-tl --portable --profile="$TEXLIVE_PROFILE_PATH"
- name: Update system paths (Windows)
if: runner.os == 'Windows'
env:
TEXLIVE_INSTALL_PREFIX: ${{ inputs.installation-path }}
shell: powershell
run: |
# Update system paths (Windows)
## Get tlmgr path
$TLMGR_PATH = Get-ChildItem -Path "${env:TEXLIVE_INSTALL_PREFIX}\bin\*\tlmgr.bat"
## Get platform of installed distribution
$PLATFORM = Invoke-Expression "$TLMGR_PATH -print-platform"
## Build binaries path
$BINARIES_PATH = "${env:TEXLIVE_INSTALL_PREFIX}\bin\${PLATFORM}"
## Append binaries path to system paths
Write-Output "${BINARIES_PATH}" | Out-File -FilePath ${env:GITHUB_PATH} -Encoding utf8 -Append
- name: Update system paths (Linux or macOS)
if: runner.os != 'Windows'
env:
TEXLIVE_INSTALL_PREFIX: ${{ inputs.installation-path }}
shell: bash
run: |
# Update system paths (Linux or macOS)
## Get tlmgr path
TLMGR_PATH=$(ls "$TEXLIVE_INSTALL_PREFIX"/bin/*/tlmgr)
## Get platform of installed distribution
PLATFORM=$($TLMGR_PATH -print-platform)
## Build binaries path
BINARIES_PATH="$TEXLIVE_INSTALL_PREFIX/bin/$PLATFORM"
## Append binaries path to system paths
echo "$BINARIES_PATH" >> $GITHUB_PATH
- name: Install TeX Live packages (Windows)
if: runner.os == 'Windows' && steps.cache-texlive.outputs.cache-hit != 'true'
env:
TEXLIVE_PACKAGES_PATH: ${{ inputs.packages-path }}
shell: powershell
run: |
# Install TeX Live packages (Windows)
## Read nonempty lines from packages file into an array
[array] $TEXLIVE_PACKAGES = (Select-String -Pattern '^(\s*#.*)?$' -NotMatch ${env:TEXLIVE_PACKAGES_PATH}).Line
## Use tlmgr to install the packages
tlmgr install $($TEXLIVE_PACKAGES -join " ")
- name: Install TeX Live packages (Linux or macOS)
if: runner.os != 'Windows' && steps.cache-texlive.outputs.cache-hit != 'true'
env:
TEXLIVE_PACKAGES_PATH: ${{ inputs.packages-path }}
shell: bash
run: |
# Install TeX Live packages (Linux or macOS)
## Read nonempty lines from packages file into an array
while IFS=\= read pkg; do TEXLIVE_PACKAGES+=($pkg); done < <(grep --invert-match --extended-regexp '^(\s*#.*)?$' "$TEXLIVE_PACKAGES_PATH")
## Use tlmgr to install the packages
tlmgr install "${TEXLIVE_PACKAGES[@]}"
- name: Update TeX Live distribution (Windows)
if: runner.os == 'Windows' && steps.cache-texlive.outputs.cache-hit == 'true'
shell: powershell
run: |
# Update TeX Live distribution (Windows)
## Update tlmgr
tlmgr update --self
## Update everything else
tlmgr update --all
- name: Update TeX Live distribution (Linux and macOS)
if: runner.os != 'Windows' && steps.cache-texlive.outputs.cache-hit == 'true'
shell: bash
run: |
# Update TeX Live distribution (Linux and macOS)
## Update tlmgr
tlmgr update --self
## Update everything else
tlmgr update --all