Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
168 lines (149 loc) · 5.35 KB
/
Copy pathaction.yml
File metadata and controls
168 lines (149 loc) · 5.35 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: 'evp'
description: >-
Render a VHS-format .tape script with evp, producing an animated GIF or SVG.
Downloads a prebuilt linux-amd64 binary from the GitHub Release matching the
requested version (no Docker, no Rust toolchain required).
author: 'HalFrgrd'
branding:
icon: 'film'
color: 'purple'
inputs:
script:
description: 'Path to the .tape script to render.'
required: true
output:
description: >-
Output file path. Extension picks the renderer (.gif or .svg). If unset,
the script's `Output` directive is used.
required: false
default: ''
version:
description: >-
evp release tag to install (e.g. `v0.2.0`), or `latest`.
required: false
default: 'latest'
font:
description: >-
Optional path to a TTF/OTF font for the GIF renderer. Defaults to the
embedded JetBrains Mono family.
required: false
default: ''
log-level:
description: 'Log level: error|warn|info|debug|trace.'
required: false
default: 'info'
install-dir:
description: >-
Directory where the `evp` binary is installed. Added to $PATH for
subsequent steps.
required: false
default: '/usr/local/bin'
outputs:
output-path:
description: 'Resolved output path that evp wrote to.'
value: ${{ steps.render.outputs.output-path }}
evp-version:
description: 'Resolved evp release tag that was installed.'
value: ${{ steps.install.outputs.tag }}
runs:
using: 'composite'
steps:
- id: install
shell: bash
run: |
set -euo pipefail
repo="${{ github.action_repository || 'HalFrgrd/evp' }}"
version="${{ inputs.version }}"
install_dir="${{ inputs.install-dir }}"
# Skip the install if a matching evp is already on PATH (useful
# for self-hosted runners or local testing with `act`).
if command -v evp >/dev/null 2>&1; then
existing="$(evp --version 2>/dev/null | head -n1 || true)"
echo "evp already on PATH: ${existing}"
fi
if [ "${version}" = "latest" ]; then
api="https://api.github.com/repos/${repo}/releases/latest"
else
api="https://api.github.com/repos/${repo}/releases/tags/${version}"
fi
# Resolve the release JSON (with auth where available — public
# repos work unauthenticated but we get a much higher rate limit
# by sending the workflow's GITHUB_TOKEN).
auth=()
if [ -n "${GITHUB_TOKEN:-}" ]; then
auth=(-H "Authorization: Bearer ${GITHUB_TOKEN}")
fi
release_json="$(curl -fsSL "${auth[@]}" "${api}")"
tag="$(printf '%s' "${release_json}" | grep -m1 '"tag_name":' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')"
if [ -z "${tag}" ]; then
echo "::error ::could not resolve evp release tag from ${api}"
exit 1
fi
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
# Resolve target platform
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
arch="$(uname -m)"
case "${os}" in
linux)
case "${arch}" in
x86_64) target="x86_64-unknown-linux-musl" ;;
aarch64) target="aarch64-unknown-linux-musl" ;;
*) echo "::error ::Unsupported Linux architecture: ${arch}"; exit 1 ;;
esac
;;
darwin)
case "${arch}" in
x86_64) target="x86_64-apple-darwin" ;;
aarch64) target="aarch64-apple-darwin" ;;
*) echo "::error ::Unsupported macOS architecture: ${arch}"; exit 1 ;;
esac
;;
*)
echo "::error ::Unsupported OS: ${os}"
exit 1
;;
esac
version_no_v="${tag#v}"
stage="evp-${version_no_v}-${target}"
url="https://github.com/${repo}/releases/download/${tag}/${stage}.tar.gz"
sha_url="${url}.sha256"
tmpdir="$(mktemp -d)"
echo "downloading ${url}"
curl -fsSL "${auth[@]}" -o "${tmpdir}/${stage}.tar.gz" "${url}"
if curl -fsSL "${auth[@]}" -o "${tmpdir}/${stage}.tar.gz.sha256" "${sha_url}" 2>/dev/null; then
if command -v sha256sum >/dev/null 2>&1; then
(cd "${tmpdir}" && sha256sum -c "${stage}.tar.gz.sha256")
else
(cd "${tmpdir}" && shasum -a 256 -c "${stage}.tar.gz.sha256")
fi
else
echo "::warning ::no .sha256 checksum published for ${tag}; skipping verification"
fi
tar -xzf "${tmpdir}/${stage}.tar.gz" -C "${tmpdir}"
mkdir -p "${install_dir}"
sudo install -m755 "${tmpdir}/${stage}/evp" "${install_dir}/evp"
echo "${install_dir}" >> "$GITHUB_PATH"
"${install_dir}/evp" --version
- id: render
shell: bash
run: |
set -euo pipefail
script="${{ inputs.script }}"
output="${{ inputs.output }}"
font="${{ inputs.font }}"
log_level="${{ inputs.log-level }}"
args=("${script}")
if [ -n "${output}" ]; then
args+=(--output "${output}")
fi
if [ -n "${font}" ]; then
args+=(--font "${font}")
fi
if [ -n "${log_level}" ]; then
args+=(--log-level "${log_level}")
fi
echo "running: evp ${args[*]}"
evp "${args[@]}"
if [ -n "${output}" ]; then
echo "output-path=${output}" >> "$GITHUB_OUTPUT"
fi