Files
arnaud.dartois c9bb94bbc0
Build Bifrost / build (push) Failing after 1m50s
docs: add MIT license and rewrite README (#3)
## Summary
- Add the MIT license and public repository, source, and issue tracker metadata.
- Rewrite the README as a user and contributor guide covering installation, configuration, builds, end-to-end testing, CI, releases, and known limitations.
- Clarify that Bifrost creates linked SonarQube projects but does not clone or analyze source code.

SonarQube Cloud analysis is intentionally not included yet.

## Validation
- `./mvnw -B verify` passed (8 tests).
- `make build`, changelog validation, shell syntax check, manifest metadata check, and `git diff --check` passed.

Reviewed-on: #3
Co-authored-by: Arnaud Dartois <admin@tordais.cc>
2026-11-06 11:59:21 +01:00

76 lines
4.0 KiB
Bash

#!/usr/bin/env sh
set -eu
version=${1:?Usage: scripts/changelog.sh X.Y.Z}
printf '%s\n' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || { echo 'Version must be X.Y.Z.' >&2; exit 2; }
export CHANGELOG_VERSION="$version"
export GITEA_REPOSITORY_URL="${GITEA_REPOSITORY_URL:-https://sources.tordais.cc/arnaud.dartois/Bifrost}"
python_bin=${PYTHON:-python3}
"$python_bin" - <<'PY'
import datetime
import os
import re
import subprocess
from pathlib import Path
path = Path("CHANGELOG.md")
text = path.read_text(encoding="utf-8")
version = os.environ["CHANGELOG_VERSION"]
base_url = os.environ["GITEA_REPOSITORY_URL"].rstrip("/")
today = datetime.date.today().isoformat()
if re.search(rf"^## \[{re.escape(version)}\] - ", text, re.M):
raise SystemExit(f"Changelog already contains version {version}.")
heading = "## [Unreleased]"
if heading not in text:
raise SystemExit("CHANGELOG.md has no Unreleased section.")
prefix, remainder = text.split(heading, 1)
match = re.search(r"\n## \[\d+\.\d+\.\d+\] - \d{4}-\d{2}-\d{2}\n", remainder)
if match:
unreleased_body = remainder[:match.start()].strip()
old_sections = remainder[match.start():]
else:
old_sections = ""
unreleased_body = remainder.split("\n[Unreleased]:", 1)[0].strip()
old_sections = re.split(r"\n\[Unreleased\]:", old_sections, maxsplit=1)[0].strip()
if not unreleased_body:
previous = subprocess.run(["git", "describe", "--tags", "--match", "v[0-9]*.[0-9]*.[0-9]*", "--abbrev=0"], text=True, capture_output=True).stdout.strip()
revision = f"{previous}..HEAD" if previous else "HEAD"
categories = {"Added": [], "Changed": [], "Deprecated": [], "Removed": [], "Fixed": [], "Security": []}
commits = subprocess.run(["git", "log", "--no-merges", "--format=%s%x00%b%x00", revision], text=True, capture_output=True, check=False).stdout.split("\x00")
mapping = {"feat": "Added", "fix": "Fixed", "perf": "Changed", "refactor": "Changed", "deprecate": "Deprecated", "revert": "Removed", "security": "Security"}
for index in range(0, len(commits) - 1, 2):
subject, body = commits[index].strip(), commits[index + 1].strip()
parsed = re.match(r"^([a-z]+)(?:\([^)]*\))?(!)?:\s*(.+)$", subject)
if not parsed or parsed.group(1) not in mapping:
continue
kind, breaking_mark, summary = parsed.groups()
if kind == "deprecate": category = "Deprecated"
elif kind == "revert" or "Removed:" in body: category = "Removed"
elif kind == "security" or "Security:" in body: category = "Security"
elif "Deprecated:" in body: category = "Deprecated"
else: category = mapping[kind]
breaking = bool(breaking_mark or re.search(r"^(BREAKING CHANGE|BREAKING-CHANGE):", body, re.M))
sentence = summary[0].upper() + summary[1:]
if sentence[-1] not in ".!?": sentence += "."
if breaking: sentence = "**BREAKING:** " + sentence
categories[category].append("- " + sentence)
blocks = [f"### {name}\n\n" + "\n".join(entries) for name, entries in categories.items() if entries]
unreleased_body = "\n\n".join(blocks)
tags = subprocess.run(["git", "tag", "--list", "v[0-9]*.[0-9]*.[0-9]*", "--sort=-version:refname"], text=True, capture_output=True).stdout.splitlines()
previous = tags[0] if tags else "v0.0.0"
existing_versions = re.findall(r"^## \[(\d+\.\d+\.\d+)\] - \d{4}-\d{2}-\d{2}$", old_sections, re.M)
new_refs = [f"[Unreleased]: {base_url}/compare/v{version}...HEAD"]
new_refs.append(f"[{version}]: {base_url}/compare/{previous or 'v0.0.0'}...v{version}")
historical = [item for item in existing_versions if item != version]
for index, item in enumerate(historical):
prior = "v" + historical[index + 1] if index + 1 < len(historical) else "v0.0.0"
new_refs.append(f"[{item}]: {base_url}/compare/{prior}...v{item}")
parts = [prefix.rstrip(), heading, "", f"## [{version}] - {today}", "", unreleased_body, old_sections, "\n".join(new_refs)]
output = "\n".join(part for part in parts if part is not None).rstrip() + "\n"
path.write_text(output, encoding="utf-8")
PY