mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
CHANGELOG-big.md is the changelog as it was: # Status, # Upcoming and every release in full, with its <details> entries. Everything that writes or edits the changelog uses it - release-all.sh, release-notes.sh and the release workflow, the commit-link repair in build.sh and fix-changelog-hashes.sh, the archive, the wrapper, the version scripts - and the release notes' "More details at ChangeLog" link goes to its section. remote-release.py, shared with FerretDB and the patch repositories, takes the file from its config, and only WeKan's names CHANGELOG-big.md. CHANGELOG.md is new: no Status and no Upcoming, only the In short paragraph of each of the five newest releases and a link to its full section, in plain Markdown - no <details>, <summary>, </summary> or </details>, and HTML links written as Markdown links. releases/changelog-short.mjs writes it; release-all.sh runs it right after naming the release, so it is in the release commit, and changelog.sh does too. The Sandstorm App Market keeps embedding CHANGELOG.md, now the short one. old-CHANGELOG/'s headers say they moved out of CHANGELOG-big.md. References to Upcoming or TODO Later in code comments and docs name CHANGELOG-big.md. CLAUDE.md and AGENTS.md describe both files: CHANGELOG-big.md is written, CHANGELOG.md is generated and never edited by hand. tests/changelogShort.test.cjs: CHANGELOG.md is exactly what the generator writes, the five newest releases with their whole In short, links that resolve, and none of the four tags or an HTML link; the changelog tests read CHANGELOG-big.md. Thanks to xet7 !
140 lines
6.7 KiB
Bash
Executable File
140 lines
6.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Print release notes, summarizing translation details as affected languages.
|
|
#
|
|
# Usage: releases/release-notes.sh <version> [changelog-file]
|
|
#
|
|
# WHY THIS IS A FILE-TO-FILE PATH AND NEVER A VARIABLE
|
|
#
|
|
# The notes are the whole newest CHANGELOG section - 172,458 characters for
|
|
# v10.92 - and there are two ways to hand a string that size to a shell step,
|
|
# both of which have already broken a release:
|
|
#
|
|
# * Inline `${{ needs.prepare.outputs.changelog }}` inside a `run:` block.
|
|
# GitHub substitutes it into the shell SOURCE before bash parses it, so every
|
|
# `code` span's backtick runs as a command. v10.59 died with "Incorrect:
|
|
# command not found" and published nothing.
|
|
#
|
|
# * Through the ENVIRONMENT - `env: CHANGELOG: ${{ … }}` then "$CHANGELOG" -
|
|
# which fixed the backticks and then hit a harder wall. Linux caps a SINGLE
|
|
# argv/envp string at MAX_ARG_STRLEN, 128 KiB, and the notes passed it:
|
|
# v10.92's release job failed before running a line of the script, with
|
|
# "An error occurred trying to start process '/usr/bin/bash' … Argument list
|
|
# too long". Nothing in the step is wrong; execve refuses to start it.
|
|
#
|
|
# So the notes never become an argument, an environment variable or a job
|
|
# output. They are read from CHANGELOG-big.md in the workspace and written to a
|
|
# file, and only file PATHS are passed around - which has no size limit, and
|
|
# leaves the text as data that no shell ever parses.
|
|
set -euo pipefail
|
|
. "$(dirname "${BASH_SOURCE[0]}")/tools-env.sh" # temporary files and downloads go to .tools/tmp
|
|
|
|
VERSION="${1:-}"
|
|
CHANGELOG_FILE="${2:-CHANGELOG-big.md}"
|
|
|
|
if [ -z "$VERSION" ]; then
|
|
echo "usage: releases/release-notes.sh <version> [changelog-file]" >&2
|
|
exit 2
|
|
fi
|
|
if [ ! -r "$CHANGELOG_FILE" ]; then
|
|
echo "::error::release-notes: cannot read $CHANGELOG_FILE" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Prefer a version-specific "# v<version> …" section; otherwise the topmost
|
|
# "# Upcoming/Upcomig WeKan ® release" one. The python reads the file itself and
|
|
# writes to stdout, so the notes never pass through the shell.
|
|
NOTES_FILE="$(mktemp "$TMPDIR/wekan.XXXXXX")"
|
|
trap 'rm -f "$NOTES_FILE"' EXIT
|
|
|
|
VERSION="$VERSION" CHANGELOG_FILE="$CHANGELOG_FILE" python3 - > "$NOTES_FILE" <<'PYEOF'
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
version = os.environ["VERSION"]
|
|
with open(os.environ["CHANGELOG_FILE"], encoding="utf-8") as f:
|
|
content = f.read()
|
|
|
|
patterns = [
|
|
rf"(^# v{re.escape(version)} [^\n]*\n.*?)(?=^# v[0-9]|\Z)",
|
|
r"(^# Upcom\w* WeKan [^\n]*\n.*?)(?=^# v[0-9]|\Z)",
|
|
]
|
|
for pat in patterns:
|
|
m = re.search(pat, content, re.DOTALL | re.MULTILINE)
|
|
if m:
|
|
notes = m.group(1).strip()
|
|
summary = re.search(r"^\*\*In short:\*\* (.*?)(?=\n\s*\n|\Z)", notes, re.MULTILINE | re.DOTALL)
|
|
# Everything in a release section is optional (releases/check-upcoming-release.sh):
|
|
# no summary, no In short section in the notes.
|
|
if not summary:
|
|
sys.stderr.write("::warning::release-notes: no **In short:** summary; the notes have none.\n")
|
|
lines = notes.splitlines(keepends=True)
|
|
# A Translations group lists its languages by name, or - when there are
|
|
# too many to list - only their count: "**Languages updated:** 172 languages."
|
|
security, languages, counts, translated = [], set(), [], False
|
|
i = 0
|
|
while i < len(lines):
|
|
line = lines[i]
|
|
is_translation = bool(re.match(r"^\*\*Translations\*\* - ", line))
|
|
is_security = bool(re.match(r"^\*\*Security(?: hardening)?\*\* - ", line, re.IGNORECASE))
|
|
is_security_header = bool(re.match(r"^(?:This release |and ).*(?:CRITICAL SECURITY ISSUE|security hardening)", line, re.IGNORECASE))
|
|
if not (is_translation or is_security or is_security_header):
|
|
i += 1
|
|
continue
|
|
j, depth = i + 1, 0
|
|
while j < len(lines):
|
|
next_line = lines[j]
|
|
boundary = re.match(r"^(?:\*\*[^\n]+\*\* - |and |This release |Thanks to above GitHub)", next_line)
|
|
if depth == 0 and boundary:
|
|
break
|
|
depth += len(re.findall(r"<details(?:\s[^>]*)?>", next_line))
|
|
depth -= next_line.count("</details>")
|
|
j += 1
|
|
block = "".join(lines[i + 1:j]).strip()
|
|
if is_translation:
|
|
translated = True
|
|
names = re.search(r"^\*\*Languages updated:\*\* (.+)$", block, re.MULTILINE)
|
|
count = names and re.fullmatch(r"(\d+) languages?\.?", names.group(1).strip())
|
|
if count:
|
|
counts.append(int(count.group(1)))
|
|
elif names:
|
|
languages.update(name.strip().rstrip(".") for name in names.group(1).split(",") if name.strip().rstrip("."))
|
|
else:
|
|
sys.stderr.write("::warning::release-notes: a Translations group has no **Languages updated:** line; its languages are not listed.\n")
|
|
elif block:
|
|
security.append((line.strip() + "\n\n" if is_security else "") + block)
|
|
i = j
|
|
heading = notes.splitlines()[0].removeprefix("# ")
|
|
if heading.startswith("Upcoming"):
|
|
from datetime import date
|
|
heading = f"v{version} {date.today().isoformat()} WeKan ® release"
|
|
anchor = re.sub(r"[^\w\s-]", "", heading.lower())
|
|
anchor = re.sub(r"\s", "-", anchor)
|
|
output = ["## In short\n\n" + summary.group(1).strip()] if summary else []
|
|
if security:
|
|
output.append("## Security\n\n" + "\n\n".join(security))
|
|
if counts:
|
|
total = max(counts) + len(languages)
|
|
output.append(f"## Translations\n\nUpdated translations at {total} languages.")
|
|
elif languages:
|
|
output.append("## Translations\n\n" + "\n".join(
|
|
"- " + name for name in sorted(languages, key=str.casefold)))
|
|
output.extend([
|
|
"Thanks to above GitHub users for their contributions" +
|
|
(" and translators for their translations." if languages or counts or translated else "."),
|
|
f"[More details at ChangeLog](https://github.com/wekan/wekan/blob/main/CHANGELOG-big.md#{anchor})",
|
|
])
|
|
print("\n\n".join(output))
|
|
sys.exit(0)
|
|
# Neither section exists. Print nothing; the caller turns that into an error
|
|
# with a message that says what to add, rather than publishing an empty release.
|
|
sys.exit(0)
|
|
PYEOF
|
|
|
|
if [ ! -s "$NOTES_FILE" ] || [ -z "$(tr -d '[:space:]' < "$NOTES_FILE")" ]; then
|
|
echo "::error::release-notes: $CHANGELOG_FILE has no '# v$VERSION …' section and no '# Upcoming WeKan (R) release' section, so the release would have no notes. Add the section and re-run." >&2
|
|
exit 1
|
|
fi
|
|
|
|
cat "$NOTES_FILE"
|