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
This commit is contained in:
Grok 2026-06-06 15:30:50 +01:00
parent db2c51f9dc
commit 428acea198
4 changed files with 156 additions and 3 deletions

View File

@ -32,10 +32,28 @@ jobs:
make test-short
# go mod tidy ensures go.sum is complete (fixes "missing go.sum entry" for deps during `go test`)
lint:
name: Lint
runs-on: ubuntu-gitea
needs: [test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.2'
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.1.6
build:
name: Build
runs-on: ubuntu-gitea
needs: [test]
needs: [test, lint]
steps:
- name: Checkout code
uses: actions/checkout@v4
@ -59,8 +77,8 @@ jobs:
- name: Linux Build
run: |
go mod tidy
make build
# go mod tidy ensures go.sum is fully populated for this Go version before the make build / go build
./ci-build.sh
# go mod tidy ensures go.sum is fully populated for this Go version before the make build / go build (ci-build.sh just wraps make build for workflow naming parity with gostations)
- name: Verify binary
run: |

8
ci-build.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env sh
# CI build step (kept for the workflow's "Linux Build" name).
# Now uses modern Go from setup-go in the workflow.
set -e
echo "Running make build with Go: $(go version)"
make build

View File

@ -0,0 +1,49 @@
param(
[string]$Version = $env:VERSION
)
if (-not $Version) {
Write-Error "Provide -Version or set VERSION env var, e.g. VERSION=0.1.0"
exit 1
}
$Version = $Version.TrimStart('v')
$GITEA_BASE = "https://repos.gmgauthier.com/gmgauthier/galculator"
$OS = if ($IsWindows) { "windows" } elseif ($IsMacOS) { "darwin" } else { "linux" }
$ARCH = if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq "X64") { "amd64" } else { "arm64" }
$ASSET = "gralculator-$OS-$ARCH-v$Version.tar.gz"
Write-Host "Installing gralculator $Version for $OS/$ARCH..."
$tempDir = New-TemporaryFile | % { rm $_; mkdir $_ }
try {
Push-Location $tempDir
Write-Host "Downloading $ASSET..."
Invoke-WebRequest -Uri "$GITEA_BASE/releases/download/v$Version/$ASSET" -OutFile "asset.tar.gz"
Write-Host "Downloading checksums.txt..."
Invoke-WebRequest -Uri "$GITEA_BASE/releases/download/v$Version/checksums.txt" -OutFile "checksums.txt"
# Extract (tar on Windows via tar if available, or 7z, but assume tar in modern PS)
Write-Host "Extracting..."
tar -xzf asset.tar.gz
$binary = "gralculator-$OS-$ARCH"
if ($OS -eq "windows") { $binary += ".exe" }
$installDir = "$HOME\.local\bin"
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
Move-Item -Force $binary "$installDir\gralculator.exe" -ErrorAction SilentlyContinue
Move-Item -Force $binary "$installDir\gralculator" -ErrorAction SilentlyContinue
Write-Host "✅ gralculator $Version installed to $installDir\gralculator"
& "$installDir\gralculator" -v
} finally {
Pop-Location
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
}

78
scripts/gralculator-install.sh Executable file
View File

@ -0,0 +1,78 @@
#!/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