fix(scripts): auto-detect git remotes and clean up temp files in release-stable.sh

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
This commit is contained in:
naturallaw777
2026-07-29 15:22:58 +00:00
co-authored by arena-agent
parent ae473b6041
commit 853c3edf92
+43 -7
View File
@@ -29,11 +29,31 @@ CYAN='\033[0;36m'
NC='\033[0m' NC='\033[0m'
# Configuration # Configuration
GITEA_REMOTE="gitea" GITEA_REMOTE_DEFAULT="gitea"
GITHUB_REMOTE="origin" GITHUB_REMOTE_DEFAULT="origin"
GITEA_API_URL="https://git.sovransystems.com/api/v1" GITEA_API_URL="https://git.sovransystems.com/api/v1"
CHANGELOG_FILE="CHANGELOG.md" CHANGELOG_FILE="CHANGELOG.md"
# Auto-detect remotes
detect_remote() {
local preferred="$1"
local keyword="$2"
if git remote | grep -q -x "$preferred"; then
echo "$preferred"
return
fi
local found
found=$(git remote -v | grep -i "$keyword" | head -n 1 | awk '{print $1}')
if [[ -n "$found" ]]; then
echo "$found"
return
fi
echo "$preferred"
}
GITEA_REMOTE=$(detect_remote "$GITEA_REMOTE_DEFAULT" "sovransystems\|gitea")
GITHUB_REMOTE=$(detect_remote "$GITHUB_REMOTE_DEFAULT" "github")
echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}" echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Sovran_SystemsOS Automated Stable Release Script ║${NC}" echo -e "${BLUE}║ Sovran_SystemsOS Automated Stable Release Script ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}" echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}"
@@ -139,7 +159,11 @@ fi
# ───────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────
echo echo
echo -e "${BLUE}Step 1: Pushing main → stable on Gitea...${NC}" echo -e "${BLUE}Step 1: Pushing main → stable on Gitea...${NC}"
git push "${GITEA_REMOTE}" main:stable --force-with-lease if git remote | grep -q -x "${GITEA_REMOTE}"; then
git push "${GITEA_REMOTE}" main:stable --force-with-lease || echo -e " ${YELLOW}⚠ Push to ${GITEA_REMOTE} failed.${NC}"
else
echo -e " ${YELLOW}⚠ Remote '${GITEA_REMOTE}' not found in git — skipping Gitea push.${NC}"
fi
# ───────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────
# Step 2: Create annotated tag # Step 2: Create annotated tag
@@ -149,9 +173,13 @@ echo -e "${BLUE}Step 2: Creating annotated tag ${TAG}...${NC}"
git tag -a "${TAG}" -m "${RELEASE_MESSAGE} git tag -a "${TAG}" -m "${RELEASE_MESSAGE}
- Stable release of Sovran_SystemsOS - Stable release of Sovran_SystemsOS
- See CHANGELOG.md for full details" - See CHANGELOG.md for full details" || true
git push "${GITEA_REMOTE}" "${TAG}" if git remote | grep -q -x "${GITEA_REMOTE}"; then
git push "${GITEA_REMOTE}" "${TAG}" || echo -e " ${YELLOW}⚠ Tag push to ${GITEA_REMOTE} failed.${NC}"
else
echo -e " ${YELLOW}⚠ Remote '${GITEA_REMOTE}' not found in git — skipping Gitea tag push.${NC}"
fi
# Update VERSION file for ISO builds # Update VERSION file for ISO builds
echo "${VERSION}" > VERSION echo "${VERSION}" > VERSION
@@ -199,6 +227,7 @@ if [ -f "$CHANGELOG_FILE" ]; then
} }
{ print } { print }
' "$CHANGELOG_FILE" > "${CHANGELOG_FILE}.tmp" && mv "${CHANGELOG_FILE}.tmp" "$CHANGELOG_FILE" ' "$CHANGELOG_FILE" > "${CHANGELOG_FILE}.tmp" && mv "${CHANGELOG_FILE}.tmp" "$CHANGELOG_FILE"
rm -f "${CHANGELOG_FILE}.bak"
echo -e " ${GREEN}${NC} CHANGELOG.md updated with new section for ${TAG}" echo -e " ${GREEN}${NC} CHANGELOG.md updated with new section for ${TAG}"
else else
@@ -217,9 +246,16 @@ else
echo echo
read -rp "Push the changelog commit to GitHub now? (y/N): " push_confirm read -rp "Push the changelog commit to GitHub now? (y/N): " push_confirm
if [[ "$push_confirm" =~ ^[Yy]$ ]]; then if [[ "$push_confirm" =~ ^[Yy]$ ]]; then
if git remote | grep -q -x "${GITHUB_REMOTE}"; then
echo -e "${BLUE}Pushing changelog commit...${NC}" echo -e "${BLUE}Pushing changelog commit...${NC}"
git push "${GITHUB_REMOTE}" main if git push "${GITHUB_REMOTE}" main; then
echo -e " ${GREEN}${NC} Changelog pushed to GitHub" echo -e " ${GREEN}${NC} Changelog pushed to GitHub (${GITHUB_REMOTE})"
else
echo -e " ${YELLOW}⚠ Push to GitHub failed — verify credentials or remote name.${NC}"
fi
else
echo -e " ${YELLOW}⚠ Remote '${GITHUB_REMOTE}' not found — skipping push to GitHub.${NC}"
fi
else else
echo " (Changelog commit left local — remember to push later)" echo " (Changelog commit left local — remember to push later)"
fi fi