mirror of
https://github.com/lexmount/moli.git
synced 2026-09-23 00:01:25 +00:00
Add Moli skills and release installers
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
$releaseBaseUrl = if ($env:MOLI_RELEASE_BASE_URL) {
|
||||
$env:MOLI_RELEASE_BASE_URL.TrimEnd("/")
|
||||
} else {
|
||||
"https://github.com/lexmount/moli/releases/latest/download"
|
||||
}
|
||||
$assetName = "moli-x86_64-pc-windows-msvc.zip"
|
||||
$installDir = if ($env:MOLI_INSTALL_DIR) {
|
||||
$env:MOLI_INSTALL_DIR
|
||||
} else {
|
||||
Join-Path $env:LOCALAPPDATA "Moli\bin"
|
||||
}
|
||||
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) (
|
||||
"moli-install-" + [System.Guid]::NewGuid().ToString("N")
|
||||
)
|
||||
|
||||
New-Item -ItemType Directory -Path $tempDir | Out-Null
|
||||
try {
|
||||
$archivePath = Join-Path $tempDir $assetName
|
||||
$extractDir = Join-Path $tempDir "package"
|
||||
|
||||
Write-Host "Downloading $assetName..."
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "$releaseBaseUrl/$assetName" -OutFile $archivePath
|
||||
|
||||
Expand-Archive -LiteralPath $archivePath -DestinationPath $extractDir
|
||||
$packageDirs = @(
|
||||
Get-ChildItem -LiteralPath $extractDir -Directory |
|
||||
Where-Object { Test-Path -LiteralPath (Join-Path $_.FullName "moli.exe") }
|
||||
)
|
||||
if ($packageDirs.Count -ne 1) {
|
||||
throw "Downloaded archive does not contain a single Moli package."
|
||||
}
|
||||
$packageDir = $packageDirs[0].FullName
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $packageDir "moli.exe") `
|
||||
-Destination (Join-Path $installDir "moli.exe") -Force
|
||||
Write-Host "Installed moli to $(Join-Path $installDir 'moli.exe')"
|
||||
|
||||
$pathEntries = $env:PATH -split ";"
|
||||
if ($installDir -notin $pathEntries) {
|
||||
Write-Host "Add $installDir to PATH, then run: moli version"
|
||||
}
|
||||
} finally {
|
||||
if (Test-Path -LiteralPath $tempDir) {
|
||||
Remove-Item -LiteralPath $tempDir -Recurse -Force
|
||||
}
|
||||
}
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
moli_release_base_url=${MOLI_RELEASE_BASE_URL:-https://github.com/lexmount/moli/releases/latest/download}
|
||||
moli_install_dir=${MOLI_INSTALL_DIR:-${HOME:?HOME is not set}/.local/bin}
|
||||
moli_tmp_dir=
|
||||
moli_staged_binary=
|
||||
|
||||
moli_fail() {
|
||||
printf 'moli installer: %s\n' "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
moli_cleanup() {
|
||||
if [ -n "$moli_staged_binary" ] && \
|
||||
{ [ -e "$moli_staged_binary" ] || [ -L "$moli_staged_binary" ]; }; then
|
||||
rm -f "$moli_staged_binary"
|
||||
fi
|
||||
if [ -n "$moli_tmp_dir" ] && [ -d "$moli_tmp_dir" ]; then
|
||||
rm -rf "$moli_tmp_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
moli_download() {
|
||||
moli_download_url=$1
|
||||
moli_download_output=$2
|
||||
case "$moli_download_url" in
|
||||
https://*)
|
||||
curl --proto '=https' --tlsv1.2 -fsSL \
|
||||
"$moli_download_url" -o "$moli_download_output"
|
||||
;;
|
||||
*)
|
||||
curl -fsSL "$moli_download_url" -o "$moli_download_output"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
moli_system=$(uname -s)
|
||||
moli_machine=$(uname -m)
|
||||
case "$moli_system:$moli_machine" in
|
||||
Linux:x86_64 | Linux:amd64)
|
||||
moli_target=x86_64-unknown-linux-gnu
|
||||
;;
|
||||
Darwin:x86_64 | Darwin:amd64)
|
||||
moli_target=x86_64-apple-darwin
|
||||
;;
|
||||
Darwin:arm64 | Darwin:aarch64)
|
||||
moli_target=aarch64-apple-darwin
|
||||
;;
|
||||
*)
|
||||
moli_fail "unsupported platform: $moli_system $moli_machine"
|
||||
;;
|
||||
esac
|
||||
|
||||
moli_archive_name="moli-$moli_target.tar.gz"
|
||||
moli_release_base_url=${moli_release_base_url%/}
|
||||
moli_tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/moli-install.XXXXXX")
|
||||
trap moli_cleanup EXIT HUP INT TERM
|
||||
|
||||
moli_archive_path="$moli_tmp_dir/$moli_archive_name"
|
||||
moli_package_dir="$moli_tmp_dir/package"
|
||||
|
||||
printf 'Downloading %s...\n' "$moli_archive_name"
|
||||
moli_download "$moli_release_base_url/$moli_archive_name" "$moli_archive_path"
|
||||
|
||||
mkdir "$moli_package_dir"
|
||||
tar -xzf "$moli_archive_path" -C "$moli_package_dir" --strip-components=1
|
||||
if [ ! -f "$moli_package_dir/moli" ]; then
|
||||
moli_fail "downloaded archive does not contain moli"
|
||||
fi
|
||||
|
||||
mkdir -p "$moli_install_dir"
|
||||
moli_staged_binary="$moli_install_dir/.moli.install.$$"
|
||||
install -m 0755 "$moli_package_dir/moli" "$moli_staged_binary"
|
||||
mv -f "$moli_staged_binary" "$moli_install_dir/moli"
|
||||
printf 'Installed moli to %s/moli\n' "$moli_install_dir"
|
||||
|
||||
case ":${PATH:-}:" in
|
||||
*":$moli_install_dir:"*) ;;
|
||||
*)
|
||||
printf 'Add %s to PATH, then run: moli version\n' "$moli_install_dir"
|
||||
;;
|
||||
esac
|
||||
+1
-1
@@ -233,7 +233,7 @@ def package_release(
|
||||
) -> tuple[Path, int, int]:
|
||||
package_name = f"moli-v{version}-{target}"
|
||||
extension = ".zip" if "-windows-" in target else ".tar.gz"
|
||||
archive_path = output_dir / f"{package_name}{extension}"
|
||||
archive_path = output_dir / f"moli-{target}{extension}"
|
||||
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
if archive_path.exists():
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)
|
||||
exec python3 "$script_dir/release.py" "$@"
|
||||
Reference in New Issue
Block a user