From 0af8dccfab1c7c15bbe8ce4c68d9f5d09153322d Mon Sep 17 00:00:00 2001 From: Alexander Maslennikov Date: Thu, 16 Apr 2026 13:13:38 +0200 Subject: [PATCH] changes to release Signed-off-by: Alexander Maslennikov --- .github/workflows/release.yml | 5 ++--- .goreleaser.yml | 2 +- scripts/install.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ac14ff8a..3cb36854 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,9 +17,8 @@ name: Release on: - push: - tags: - - "v*" + release: + types: [published] concurrency: group: release-${{ github.ref }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 248dd2f1..705218b7 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -74,7 +74,7 @@ metadata: mod_timestamp: "{{ .CommitTimestamp }}" release: - prerelease: auto + mode: append changelog: sort: asc diff --git a/scripts/install.sh b/scripts/install.sh index a07c07e1..74e36b37 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -109,6 +109,32 @@ else REDIRECT_URL=$(curl -fsSIo /dev/null -w '%{redirect_url}' \ "https://github.com/${REPO}/releases/latest" 2>/dev/null || true) VERSION=$(echo "$REDIRECT_URL" | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+[^/]*' || true) + + # Verify the release has GoReleaser archives (older releases may not). + # If not, fall back to the GitHub API to find the most recent release that does. + if [ -n "$VERSION" ]; then + VERSION_NO_V_CHECK="${VERSION#v}" + CHECK_URL="https://github.com/${REPO}/releases/download/${VERSION}/l8k_${VERSION_NO_V_CHECK}_${OS}_${ARCH}.tar.gz" + if ! curl -fsSIo /dev/null "$CHECK_URL" 2>/dev/null; then + echo "Latest stable release (${VERSION}) has no binary archives." + echo "Checking for the most recent release with binaries..." + VERSION="" + fi + fi + + # Fallback: query the GitHub API for the most recent release with archives. + if [ -z "$VERSION" ]; then + AUTH_FLAG="" + if [ -n "${GITHUB_TOKEN:-}" ]; then + AUTH_FLAG="-H \"Authorization: token ${GITHUB_TOKEN}\"" + fi + VERSION=$(eval curl -fsSL $AUTH_FLAG \ + "https://api.github.com/repos/${REPO}/releases?per_page=10" 2>/dev/null \ + | grep -oE '"tag_name":\s*"v[^"]*"' \ + | head -1 \ + | grep -oE 'v[0-9]+[^"]*' || true) + fi + if [ -z "$VERSION" ]; then echo "Error: could not determine latest version." echo "Set L8K_VERSION explicitly or check https://github.com/${REPO}/releases"