Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release CLI

on:
push:
tags:
- "v*"

permissions:
contents: write

jobs:
test:
name: Lua tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Lua 5.1
run: |
sudo apt-get update
sudo apt-get install -y lua5.1
- name: Run tests
run: lua5.1 ./tests.lua --Linux

package:
name: Package (${{ matrix.os_name }})
runs-on: ${{ matrix.runner }}
needs: test
strategy:
matrix:
include:
- runner: ubuntu-latest
os_name: linux
- runner: macos-latest
os_name: macos
steps:
- uses: actions/checkout@v4
- name: Install LuaJIT (Linux)
if: matrix.os_name == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y luajit
- name: Install LuaJIT (macOS)
if: matrix.os_name == 'macos'
run: brew install luajit
- name: Build package
run: PROMETHEUS_BUNDLED_LUA="$(command -v luajit)" ./scripts/release/package.sh "${{ matrix.os_name }}" "${GITHUB_REF_NAME}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: prometheus-lua-${{ matrix.os_name }}
path: dist/prometheus-lua-${{ github.ref_name }}-${{ matrix.os_name }}.tar.gz

publish:
name: Publish release
runs-on: ubuntu-latest
needs: package
steps:
- uses: actions/download-artifact@v4
with:
path: dist
- name: Move release assets
run: |
mkdir -p dist/out
mv dist/prometheus-lua-linux/*.tar.gz dist/out/
mv dist/prometheus-lua-macos/*.tar.gz dist/out/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
files: dist/out/*.tar.gz
generate_release_notes: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ buildnotes.txt
srlua.exe
glue.exe
build
dist

# Web tooling
node_modules
Expand Down
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,35 @@ Try the browser version first:
<img src="https://img.shields.io/badge/Prometheus%20Web-Open-0F766E?style=for-the-badge&logo=github&logoColor=white" alt="Open Prometheus Web UI" />
</a>

### Local CLI usage
Clone the repository:
### Install CLI (Linux/macOS)

Install latest release with one command:

```bash
git clone https://github.com/prometheus-lua/Prometheus.git
cd Prometheus
curl -fsSL https://raw.githubusercontent.com/prometheus-lua/Prometheus/master/install.sh | sh
```

Then use the CLI directly:

```bash
prometheus-lua --version
prometheus-lua --preset Medium ./your_file.lua
```

Alternatively, you can download the sources directly [here](https://github.com/prometheus-lua/Prometheus/archive/refs/heads/master.zip).
The release bundle includes a Lua runtime, so no separate Lua install is required for the packaged CLI.

To update to the latest release:

```bash
prometheus-lua update
```

To obfuscate a script, run:
### Local source usage

```bash
lua ./cli.lua --preset Medium ./your_file.lua
git clone https://github.com/prometheus-lua/Prometheus.git
cd Prometheus
./prometheus-lua --preset Medium ./your_file.lua
```

---
Expand Down Expand Up @@ -123,7 +137,8 @@ You can find the full documentation, including the getting started guide, here:

### Requirements

Prometheus requires **LuaJIT** or **Lua 5.1** in order to run.
Packaged CLI releases include a bundled Lua runtime.
For source usage, Prometheus requires **LuaJIT** or **Lua 5.1+**.

Lua 5.1 binaries can be downloaded here:
https://sourceforge.net/projects/luabinaries/files/5.1.5/Tools%20Executables/
Expand Down
32 changes: 27 additions & 5 deletions doc/getting-started/installation.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
# Installation

To install Prometheus, simply clone the Github Repository using:
## Linux and macOS (recommended)

```batch
git clone "https://github.com/levno-710/Prometheus.git"
Install the latest release:

```bash
curl -fsSL https://raw.githubusercontent.com/prometheus-lua/Prometheus/master/install.sh | sh
```

Verify:

```bash
prometheus-lua --version
```

Release bundles include a Lua runtime, so no separate Lua install is needed for installed CLI usage.

Update later:

```bash
prometheus-lua update
```

Alternatively you can download the Sources [here](https://github.com/levno-710/Prometheus/archive/refs/heads/master.zip).
## From source

```bash
git clone "https://github.com/prometheus-lua/Prometheus.git"
cd Prometheus
./prometheus-lua --preset Medium ./your_file.lua
```

Prometheus also Requires LuaJIT or Lua51 in order to work. The Lua51 binaries can be downloaded [here](https://sourceforge.net/projects/luabinaries/files/5.1.5/Tools%20Executables/).
For source usage, Prometheus requires LuaJIT or Lua 5.1+.
85 changes: 85 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env sh
set -eu

REPO="prometheus-lua/Prometheus"
INSTALL_BASE="${PROMETHEUS_LUA_HOME:-$HOME/.local/share/prometheus-lua}"
BIN_DIR="${PROMETHEUS_LUA_BIN:-$HOME/.local/bin}"

need_cmd() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "Missing required command: $1" >&2
exit 1
fi
}

fetch() {
url="$1"
out="$2"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "$out"
return
fi
if command -v wget >/dev/null 2>&1; then
wget -qO "$out" "$url"
return
fi
echo "Neither curl nor wget is installed." >&2
exit 1
}

need_cmd tar
need_cmd uname
need_cmd mktemp
need_cmd grep
need_cmd sed

OS_NAME="$(uname -s)"
case "$OS_NAME" in
Linux) OS="linux" ;;
Darwin) OS="macos" ;;
*)
echo "Unsupported operating system: $OS_NAME" >&2
exit 1
;;
esac

TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT INT TERM

LATEST_JSON="$TMP_DIR/latest.json"
fetch "https://api.github.com/repos/$REPO/releases/latest" "$LATEST_JSON"

TAG="$(grep '"tag_name":' "$LATEST_JSON" | sed -E 's/.*"([^"]+)".*/\1/' | head -n1)"
if [ -z "$TAG" ]; then
echo "Failed to resolve latest release tag." >&2
exit 1
fi

ASSET="prometheus-lua-$TAG-$OS.tar.gz"
ASSET_URL="https://github.com/$REPO/releases/download/$TAG/$ASSET"
ARCHIVE_PATH="$TMP_DIR/$ASSET"

fetch "$ASSET_URL" "$ARCHIVE_PATH"

mkdir -p "$INSTALL_BASE" "$BIN_DIR"

tar -xzf "$ARCHIVE_PATH" -C "$INSTALL_BASE"
TARGET_DIR="$INSTALL_BASE/prometheus-lua-$TAG-$OS"
if [ ! -d "$TARGET_DIR" ]; then
echo "Unexpected archive layout; missing $TARGET_DIR" >&2
exit 1
fi

ln -sfn "$TARGET_DIR/prometheus-lua" "$BIN_DIR/prometheus-lua"
chmod +x "$TARGET_DIR/prometheus-lua"

printf 'Installed prometheus-lua %s to %s\n' "$TAG" "$TARGET_DIR"
printf 'Linked command: %s/prometheus-lua\n' "$BIN_DIR"

case ":$PATH:" in
*":$BIN_DIR:"*)
;;
*)
printf 'Add %s to PATH, e.g.: export PATH="%s:$PATH"\n' "$BIN_DIR" "$BIN_DIR"
;;
esac
27 changes: 27 additions & 0 deletions prometheus-lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env sh
set -eu

SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
BUNDLED_LUA="$SCRIPT_DIR/runtime/lua"

: "${PROMETHEUS_LUA_VERSION:=dev}"
export PROMETHEUS_LUA_VERSION

if [ -x "$BUNDLED_LUA" ]; then
exec "$BUNDLED_LUA" "$SCRIPT_DIR/cli.lua" "$@"
fi

if command -v luajit >/dev/null 2>&1; then
exec luajit "$SCRIPT_DIR/cli.lua" "$@"
fi

if command -v lua5.1 >/dev/null 2>&1; then
exec lua5.1 "$SCRIPT_DIR/cli.lua" "$@"
fi

if command -v lua >/dev/null 2>&1; then
exec lua "$SCRIPT_DIR/cli.lua" "$@"
fi

echo "No Lua runtime found. Reinstall with official installer or install Lua5.1/LuaJIT." >&2
exit 1
72 changes: 72 additions & 0 deletions scripts/release/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,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"
Loading
Loading