Your Name 42564cf558
Some checks failed
CI - 4NK_node / Code Quality (push) Failing after 38s
CI - 4NK_node / Unit Tests (push) Failing after 36s
CI - 4NK_node / Integration Tests (push) Successful in 33s
CI - 4NK_node / Security Tests (push) Failing after 33s
CI - 4NK_node / Docker Build & Test (push) Failing after 15s
CI - 4NK_node / Documentation Tests (push) Successful in 12s
CI - 4NK_node / Release Guard (push) Has been skipped
CI - 4NK_node / Performance Tests (push) Successful in 35s
CI - 4NK_node / Notify (push) Failing after 2s
chore(refine): adapter .gitea/docs/scripts au projet 4NK_node
2025-08-27 11:56:17 +02:00

67 lines
2.0 KiB
Bash
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
# Release guard script
# Checks: tests, docs updated, compile, version ↔ changelog ↔ tag consistency, release type
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)"
cd "$ROOT_DIR"
mode="${RELEASE_TYPE:-ci-verify}" # values: latest | wip | ci-verify
echo "[release-guard] mode=$mode"
# 1) Basic presence checks
[[ -f CHANGELOG.md ]] || { echo "CHANGELOG.md manquant"; exit 1; }
version_file="VERSION"
[[ -f TEMPLATE_VERSION ]] && version_file="TEMPLATE_VERSION"
[[ -f "$version_file" ]] || { echo "$version_file manquant"; exit 1; }
# 2) Extract version
project_version=$(tr -d '\r' < "$version_file" | head -n1 | sed 's/^v//')
[[ -n "$project_version" ]] || { echo "Version vide dans $version_file"; exit 1; }
echo "[release-guard] version=$project_version"
# 3) Changelog checks
if ! grep -Eq "^## \\[$project_version\\]" CHANGELOG.md; then
if [[ "$mode" == "wip" ]]; then
grep -Eq "^## \\[Unreleased\\]" CHANGELOG.md || { echo "Section [Unreleased] absente du CHANGELOG"; exit 1; }
else
echo "Entrée CHANGELOG pour version $project_version manquante"; exit 1;
fi
fi
# 4) Tests (optional best-effort)
if [[ -x tests/run_all_tests.sh ]]; then
echo "[release-guard] exécution tests/run_all_tests.sh"
./tests/run_all_tests.sh || { echo "Tests en échec"; exit 1; }
else
echo "[release-guard] tests absents (ok)"
fi
# 5) Build/compile (optional based on project)
if [[ -d sdk_relay ]] && command -v cargo >/dev/null 2>&1; then
echo "[release-guard] cargo build (sdk_relay)"
(cd sdk_relay && cargo build --quiet) || { echo "Compilation échouée"; exit 1; }
else
echo "[release-guard] build spécifique non applicable (ok)"
fi
# 6) Release type handling
case "$mode" in
latest)
;;
wip)
# En wip, autoriser versions suffixées; pas dexigence dentrée datée
;;
ci-verify)
# En CI, on valide juste la présence de CHANGELOG et version
;;
*)
echo "RELEASE_TYPE invalide: $mode (latest|wip|ci-verify)"; exit 1;
;;
esac
echo "[release-guard] OK"