-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathpackage.sh
More file actions
executable file
·72 lines (59 loc) · 1.85 KB
/
package.sh
File metadata and controls
executable file
·72 lines (59 loc) · 1.85 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
#!/usr/bin/env sh
set -eu
if [ "${1:-}" = "" ]; then
echo "Usage: $0 <linux|macos> [version]" >&2
exit 1
fi
OS="$1"
VERSION="${2:-${GITHUB_REF_NAME:-}}"
if [ -z "$VERSION" ]; then
VERSION="$(git describe --tags --abbrev=0 2>/dev/null || true)"
fi
if [ -z "$VERSION" ]; then
echo "Version is required (pass as arg or run from a tagged commit)." >&2
exit 1
fi
case "$OS" in
linux|macos) ;;
*)
echo "Unsupported OS '$OS'. Use linux or macos." >&2
exit 1
;;
esac
DIST_DIR="dist"
PKG_DIR="$DIST_DIR/prometheus-lua-$VERSION-$OS"
ARCHIVE="$DIST_DIR/prometheus-lua-$VERSION-$OS.tar.gz"
rm -rf "$PKG_DIR"
mkdir -p "$PKG_DIR/src"
mkdir -p "$PKG_DIR/runtime"
cp -R src/prometheus "$PKG_DIR/src/"
cp src/prometheus.lua "$PKG_DIR/src/"
cp src/logger.lua "$PKG_DIR/src/"
cp src/colors.lua "$PKG_DIR/src/"
cp src/highlightlua.lua "$PKG_DIR/src/"
cp src/presets.lua "$PKG_DIR/src/"
cp cli.lua "$PKG_DIR/"
cp LICENSE README.md "$PKG_DIR/"
cp prometheus-lua "$PKG_DIR/"
RUNTIME_BIN="${PROMETHEUS_BUNDLED_LUA:-}"
if [ -z "$RUNTIME_BIN" ]; then
if command -v luajit >/dev/null 2>&1; then
RUNTIME_BIN="$(command -v luajit)"
elif command -v lua5.1 >/dev/null 2>&1; then
RUNTIME_BIN="$(command -v lua5.1)"
elif command -v lua >/dev/null 2>&1; then
RUNTIME_BIN="$(command -v lua)"
else
echo "No Lua runtime available to bundle. Install luajit/lua5.1 or set PROMETHEUS_BUNDLED_LUA." >&2
exit 1
fi
fi
cp "$RUNTIME_BIN" "$PKG_DIR/runtime/lua"
chmod +x "$PKG_DIR/runtime/lua"
# Inject release version into the packaged launcher without relying on git metadata at runtime.
sed -i.bak "s/PROMETHEUS_LUA_VERSION:=dev/PROMETHEUS_LUA_VERSION:=$VERSION/" "$PKG_DIR/prometheus-lua"
rm -f "$PKG_DIR/prometheus-lua.bak"
chmod +x "$PKG_DIR/prometheus-lua"
mkdir -p "$DIST_DIR"
tar -czf "$ARCHIVE" -C "$DIST_DIR" "prometheus-lua-$VERSION-$OS"
echo "Created $ARCHIVE"