feat: releases from GitHub first, then git.kebcloud.no; releases sets others
CI / Checks (pull_request) Successful in 26s
PR title / Conventional title (pull_request) Successful in 2s

Updates and install.sh try the GitHub mirror, then git.kebcloud.no,
each with a short timeout, and download from the first server with the
release, checked against its checksums.txt. The releases config option
(and LAZYSECRETS_RELEASES for install.sh) lists other servers. The
release workflow copies each release to GitHub when GH_RELEASE_TOKEN is
set. The status pane's issues link points to GitHub.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kebandClaude Opus 5.5 committed 2026-10-12 14:01:51 +02:00
1 parent c00f4b14c4
commit b3c1911ba5
13 files changed
+329 -70

No files matched your search

+40 -14
View File
@@ -7,10 +7,12 @@
#
# LAZYSECRETS_INSTALL_DIR installs somewhere else. macOS and Linux, arm64
# and x86_64.
#
# Releases are on GitHub and git.kebcloud.no, tried in that order;
# LAZYSECRETS_RELEASES (repository addresses, space-separated) uses others.
set -eu
repo=https://git.kebcloud.no/keb/lazysecrets
api=https://git.kebcloud.no/api/v1/repos/keb/lazysecrets
repos="${LAZYSECRETS_RELEASES:-https://github.com/karleinarb/lazysecrets https://git.kebcloud.no/keb/lazysecrets}"
dir="${LAZYSECRETS_INSTALL_DIR:-$HOME/.local/bin}"
fail() {
@@ -18,12 +20,13 @@ fail() {
exit 1
}
# Short timeouts, so a server that's down leaves time for the next.
if command -v curl >/dev/null 2>&1; then
fetch() { curl -fsSL "$1"; }
download() { curl -fsSL -o "$2" "$1"; }
fetch() { curl -fsSL --connect-timeout 5 --max-time 15 "$1"; }
download() { curl -fsSL --connect-timeout 5 -o "$2" "$1"; }
elif command -v wget >/dev/null 2>&1; then
fetch() { wget -qO- "$1"; }
download() { wget -qO "$2" "$1"; }
fetch() { wget -qO- -T 15 "$1"; }
download() { wget -qO "$2" -T 30 "$1"; }
else
fail "needs curl or wget"
fi
@@ -39,11 +42,26 @@ arm64 | aarch64) arch=arm64 ;;
*) fail "no release for $(uname -m)" ;;
esac
# api is a repository's API: GitHub's, or Gitea's (and Forgejo's).
api() {
case "$1" in
https://github.com/*) echo "https://api.github.com/repos/${1#https://github.com/}" ;;
*)
host=${1#*://}
host=${host%%/*}
echo "${1%%://*}://$host/api/v1/repos/${1#*://"$host"/}"
;;
esac
}
tag="${1:-}"
if [ -z "$tag" ]; then
tag=$(fetch "$api/releases/latest" | sed -n 's/.*"tag_name":"\([^"]*\)".*/\1/p') ||
fail "couldn't look up the latest release"
[ -n "$tag" ] || fail "couldn't look up the latest release"
for repo in $repos; do
tag=$(fetch "$(api "$repo")/releases/latest" 2>/dev/null |
sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -n 1) || tag=
[ -n "$tag" ] && break
done
[ -n "$tag" ] || fail "couldn't look up the latest release on $repos"
fi
case "$tag" in
v*) ;;
@@ -55,11 +73,19 @@ name="lazysecrets_${version}_${os}_${arch}"
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
echo "Downloading lazysecrets $tag for $os/$arch"
download "$repo/releases/download/$tag/$name.tar.gz" "$tmp/$name.tar.gz" ||
fail "couldn't download $tag for $os/$arch: see $repo/releases"
download "$repo/releases/download/$tag/checksums.txt" "$tmp/checksums.txt" ||
fail "couldn't download $tag's checksums.txt"
# The archive and its checksums.txt from the first server that has both.
from=
for repo in $repos; do
base="$repo/releases/download/$tag"
if download "$base/checksums.txt" "$tmp/checksums.txt" 2>/dev/null; then
echo "Downloading lazysecrets $tag for $os/$arch from $repo"
if download "$base/$name.tar.gz" "$tmp/$name.tar.gz"; then
from=$repo
break
fi
fi
done
[ -n "$from" ] || fail "couldn't download $tag for $os/$arch from $repos"
want=$(awk -v f="$name.tar.gz" '$2 == f { print $1 }' "$tmp/checksums.txt")
[ -n "$want" ] || fail "$name.tar.gz isn't in checksums.txt"