gralculator/scripts/gralculator-install.sh
Grok 428acea198 ci: add ci-build.sh, install scripts, and lint job
- ci-build.sh for parity with gostations (Linux Build step in workflow)
- scripts/gralculator-install.sh and .ps1 modeled directly on gostations (platform detection, download, checksum verify with sha256sum/shasum, extract, install to ~/.local/bin, versioned)
- Updated build.yml: Linux Build now calls ./ci-build.sh; added lint job (golangci-lint-action@v7 v2.1.6 like grokkit) after test, build now needs [test, lint]
- release.yml already prepared to include the scripts if present
- All modeled closely on gostations/grokkit for consistency
2026-06-06 15:30:50 +01:00

79 lines
2.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
VERSION=${VERSION:-${1:?Provide VERSION env or arg, e.g. VERSION=0.1.0 bash gralculator-install.sh}}
# Strip leading 'v' if present
VERSION=${VERSION#v}
GITEA_BASE=https://repos.gmgauthier.com/gmgauthier/galculator
# Platform detection
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$OS" in
linux) OS=linux ;;
darwin) OS=darwin ;;
esac
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64) ARCH=amd64 ;;
arm64|aarch64) ARCH=arm64 ;;
esac
ASSET="gralculator-${OS}-${ARCH}-v${VERSION}.tar.gz"
echo "Installing gralculator ${VERSION} for ${OS}/${ARCH}..."
TEMP_DIR=$(mktemp -d)
trap 'rm -rf "${TEMP_DIR}"' EXIT
cd "${TEMP_DIR}"
# Download asset + checksums
echo "Downloading ${ASSET}..."
curl -fL "${GITEA_BASE}/releases/download/v${VERSION}/${ASSET}" -o asset.tar.gz
echo "Downloading checksums.txt..."
curl -fL "${GITEA_BASE}/releases/download/v${VERSION}/checksums.txt" -o checksums.txt
# Robust checksum verification
echo "Verifying checksum..."
CHECKSUM_CMD=""
if command -v sha256sum >/dev/null 2>&1; then
CHECKSUM_CMD="sha256sum"
elif command -v shasum >/dev/null 2>&1; then
CHECKSUM_CMD="shasum -a 256"
fi
if [ -n "$CHECKSUM_CMD" ] && [ -f checksums.txt ]; then
HASH=$(grep -oE '[0-9a-f]{64}\s+build/[^ ]*' checksums.txt | grep "${ASSET}" | cut -d' ' -f1 || true)
if [ -z "$HASH" ]; then
echo "⚠️ No checksum entry found for ${ASSET} continuing without verification"
else
echo "${HASH} asset.tar.gz" | $CHECKSUM_CMD --check - || {
echo "❌ Checksum mismatch for ${ASSET}!"
exit 1
}
echo "✅ Checksum verified successfully"
fi
else
echo "⚠️ Checksum tool not found (sha256sum/shasum) skipping verification"
fi
# Extract
echo "Extracting asset..."
tar xzf asset.tar.gz
BINARY="gralculator-${OS}-${ARCH}"
if [ "$OS" = "windows" ]; then BINARY="${BINARY}.exe"; fi
# Install
INSTALL_DIR="${HOME}/.local/bin"
mkdir -p "${INSTALL_DIR}"
mv "${BINARY}" "${INSTALL_DIR}/gralculator" 2>/dev/null || mv "${BINARY}" "${INSTALL_DIR}/gralculator.exe" 2>/dev/null || true
chmod +x "${INSTALL_DIR}/gralculator" 2>/dev/null || true
echo "✅ gralculator ${VERSION} installed to ${INSTALL_DIR}/gralculator"
echo "Add to PATH if needed: export PATH=\"${INSTALL_DIR}:\$PATH\""
gralculator -v || true