editors/vscode/package-vsix.sh
1
#!/usr/bin/env bash
2
# Usage: package-vsix.sh <version> <archive-directory> <output-directory>
3
#
4
# Builds one VSIX per platform carrying the released koment binary for that
5
# platform, plus a universal VSIX that carries none. Archives are the canonical
6
# release artifacts and are verified against the release checksum manifest
7
# before anything is packaged (ADR 0109, ADR 0113).
8
set -euo pipefail
10
version=${1:?version}
11
archives=$(cd "${2:?archive directory}" && pwd)
12
output=${3:?output directory}
14
extension=$(cd "$(dirname "$0")" && pwd)
15
repository=$(cd "$extension/../.." && pwd)
16
vsce="$extension/node_modules/.bin/vsce"
17
manifest="$archives/koment_${version}_checksums.txt"
19
mkdir -p "$output"
20
output=$(cd "$output" && pwd)
22
cp "$repository/LICENSE" "$extension/LICENSE"
23
cp "$repository/internal/ui/assets/koment-logo.png" "$extension/icon.png"
25
verify() {
26
local archive=$1
27
(
28
cd "$archives"
29
if command -v sha256sum >/dev/null; then
30
grep " ${archive}\$" "$manifest" | sha256sum -c -
31
else
32
grep " ${archive}\$" "$manifest" | shasum -a 256 -c -
33
fi
34
)
35
}
37
# vsce target -> koment archive platform. Every koment archive has exactly one
38
# VS Code target, so a platform that stops being built stops being packaged.
39
targets="linux-x64:linux_amd64 linux-arm64:linux_arm64 darwin-x64:darwin_amd64 darwin-arm64:darwin_arm64 win32-x64:windows_amd64 win32-arm64:windows_arm64"
41
for pair in $targets; do
42
target=${pair%%:*}
43
platform=${pair##*:}
45
rm -rf "$extension/bin"
46
mkdir -p "$extension/bin"
48
case "$platform" in
49
windows_*)
50
archive="koment_${version}_${platform}.zip"
51
verify "$archive"
52
unzip -q -o "$archives/$archive" koment.exe -d "$extension/bin"
53
;;
54
*)
55
archive="koment_${version}_${platform}.tar.gz"
56
verify "$archive"
57
tar -xzf "$archives/$archive" -C "$extension/bin" koment
58
chmod +x "$extension/bin/koment"
59
;;
60
esac
62
(cd "$extension" && "$vsce" package --target "$target" \
63
--out "$output/koment-vscode_${version}_${target}.vsix")
64
done
66
rm -rf "$extension/bin"
67
(cd "$extension" && "$vsce" package --out "$output/koment-vscode_${version}.vsix")
69
rm -f "$extension/LICENSE" "$extension/icon.png"
70
ls -1 "$output"