Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions .github/scripts/generate_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,16 @@ def update_changelog(path: Path, version_heading: str, date: str, body: str) ->
"[Conventional Commits](https://www.conventionalcommits.org/).\n\n"
)
marker = re.search(r"^## \[", content, re.MULTILINE)
if marker:
insert_at = marker.start()
content = content[:insert_at] + section + content[insert_at:]
# A retried/re-run pre-publish generation (--new-tag hasn't become a real tag yet, so the
# walk range and version_heading are identical to last time) would otherwise prepend another
# full duplicate section on every retry instead of regenerating the same one - replace the
# existing section in place when it's for this exact version and already sits at the top.
if marker and content[marker.start():].startswith(f"## {version_heading} - "):
next_marker = re.search(r"^## \[", content[marker.end():], re.MULTILINE)
section_end = marker.end() + next_marker.start() if next_marker else len(content)
content = content[:marker.start()] + section + content[section_end:]
elif marker:
content = content[:marker.start()] + section + content[marker.start():]
else:
content = content.rstrip("\n") + "\n\n" + section
path.write_text(content)
Expand Down Expand Up @@ -230,13 +237,19 @@ def main() -> None:
"explicitly (e.g. HEAD) when --new-tag isn't a ref that exists yet")
parser.add_argument("--prev-tag", default=None, help="auto-detected if omitted")
parser.add_argument("--changelog-path", type=Path, default=None)
parser.add_argument("--latest-path", type=Path, default=None,
help="also write just this release's own rendered body (no accumulated "
"history) here - e.g. for modpublisher's changelog = file(...), "
"which submits its whole input as a single platform-side upload "
"(Modrinth's version_body has a length limit CHANGELOG.md's full, "
"ever-growing history will eventually exceed)")
parser.add_argument("--posts-dir", type=Path, default=None,
help="omit to skip news-post generation (e.g. the pre-publish flow)")
parser.add_argument("--dry-run", action="store_true", help="print instead of writing files")
args = parser.parse_args()

if not args.dry_run and not args.changelog_path and not args.posts_dir:
parser.error("nothing to do - pass --changelog-path and/or --posts-dir, or --dry-run")
if not args.dry_run and not args.changelog_path and not args.latest_path and not args.posts_dir:
parser.error("nothing to do - pass --changelog-path, --latest-path, and/or --posts-dir, or --dry-run")

range_end = args.range_end or args.new_tag
prev_tag = args.prev_tag or detect_previous_tag(range_end)
Expand Down Expand Up @@ -264,6 +277,11 @@ def main() -> None:
update_changelog(args.changelog_path, f"[{version_display}]", date, body)
print(f"Updated {args.changelog_path}")

if args.latest_path:
args.latest_path.parent.mkdir(parents=True, exist_ok=True)
args.latest_path.write_text(body)
print(f"Wrote {args.latest_path}")

if args.posts_dir:
post_path = write_news_post(
args.posts_dir, args.repo, version_display, date, prev_tag, body, len(entries),
Expand Down
10 changes: 7 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,9 @@ publisher {
apiKeys {
curseforge("curseforge_api_key".localOrEnv)
modrinth("modrinth_api_key".localOrEnv)
github("github_token".localOrEnv)
}

debug = true

curseID = "1029738"
modrinthID = "archie"
githubRepo = "https://github.com/kernel-panic-codecave/Archie"
Expand All @@ -227,7 +226,11 @@ publisher {
artifact = tasks.fusejars.get()
javaVersions = listOf(JavaVersion.VERSION_21)

changelog = file("CHANGELOG.md")
// Just this release's own notes (generateChangelog writes it below), not the whole
// ever-growing CHANGELOG.md - modpublisher submits this file's entire content as the
// version body, and Modrinth's version_body has a length limit CHANGELOG.md's full history
// eventually exceeds.
changelog = file("build/latest-changelog.md")

curseDepends {
required = listOf("fabric-api", "fabric-language-kotlin", "kotlinlangforge", "architectury-api", "cloth-config")
Expand Down Expand Up @@ -288,6 +291,7 @@ tasks {
"--new-tag", "v${project.version}",
"--range-end", "HEAD",
"--changelog-path", "CHANGELOG.md",
"--latest-path", "build/latest-changelog.md",
)
}
listOf("publishCurseforge", "publishModrinth", "publishGitHub", "publishMod").forEach {
Expand Down
Loading