action.yml
1
name: Set up koment
2
description: Install the koment CLI onto a runner and put it on PATH.
3
branding:
4
icon: message-square
5
color: blue
7
inputs:
8
version:
9
description: Release to install, with or without a leading v. Defaults to the latest release.
10
required: false
11
default: latest
13
outputs:
14
version:
15
description: The release that was installed.
16
value: ${{ steps.install.outputs.version }}
17
path:
18
description: Absolute path to the installed binary.
19
value: ${{ steps.install.outputs.path }}
21
runs:
22
using: composite
23
steps:
24
- id: install
25
shell: bash
26
env:
27
KOMENT_REQUESTED: ${{ inputs.version }}
28
KOMENT_SOURCE: ${{ github.action_repository || 'janpuc/koment' }}
29
run: | # zizmor: ignore[github-env]
30
set -euo pipefail
32
case "$RUNNER_OS" in
33
Linux) platform=linux ;;
34
macOS) platform=darwin ;;
35
*)
36
echo "::error::koment's setup action supports Linux and macOS runners." \
37
"Download the checksum-listed Windows archive from the koment release instead."
38
exit 1
39
;;
40
esac
42
case "$RUNNER_ARCH" in
43
X64) arch=amd64 ;;
44
ARM64) arch=arm64 ;;
45
*)
46
echo "::error::no koment release is built for $RUNNER_ARCH"
47
exit 1
48
;;
49
esac
51
if [ "$KOMENT_REQUESTED" = "latest" ]; then
52
resolved=$(curl -fsSLI -o /dev/null -w '%{url_effective}' \
53
"https://github.com/${KOMENT_SOURCE}/releases/latest")
54
tag=${resolved##*/}
55
else
56
tag=v${KOMENT_REQUESTED#v}
57
fi
58
version=${tag#v}
60
if [ -z "$version" ] || [ "$tag" = "latest" ] ||
61
[[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
62
echo "::error::could not resolve a koment release from '${KOMENT_REQUESTED}'"
63
exit 1
64
fi
66
base="https://github.com/${KOMENT_SOURCE}/releases/download/${tag}"
67
archive="koment_${version}_${platform}_${arch}.tar.gz"
68
work=$(mktemp -d)
70
echo "installing koment ${version} (${platform}/${arch})"
71
curl -fsSL --retry 3 -o "${work}/${archive}" "${base}/${archive}"
72
curl -fsSL --retry 3 -o "${work}/checksums.txt" "${base}/koment_${version}_checksums.txt"
74
(
75
cd "$work"
76
if command -v sha256sum >/dev/null; then
77
grep " ${archive}\$" checksums.txt | sha256sum -c -
78
else
79
grep " ${archive}\$" checksums.txt | shasum -a 256 -c -
80
fi
81
)
83
target="${RUNNER_TEMP}/koment-bin"
84
mkdir -p "$target"
85
tar -xzf "${work}/${archive}" -C "$target" koment
86
chmod +x "${target}/koment"
87
rm -rf "$work"
89
echo "$target" >> "$GITHUB_PATH"
90
echo "version=${version}" >> "$GITHUB_OUTPUT"
91
echo "path=${target}/koment" >> "$GITHUB_OUTPUT"
93
- shell: bash
94
run: koment version