invidious/scripts/release-utils/convert_changelog.cr
2025-12-18 23:31:42 -08:00

40 lines
1.2 KiB
Crystal

# A quick and dirty script to convert Github's automatically generated list of merged PRs since last
# release into a partially filled Invidious changelog.
#
# Reads from an "auto_changelog.md" file in the working directory
#
# `crystal run scripts/release-utils/convert_changelog.cr -- <VERSION>`
#
require "ecr"
abort "Missing version argument" unless (version = ARGV[0]?)
unless (semantic_version = version.match(/v(\d+)\.(\d+)\.(\d+)/))
abort "Version must be format v{major}.{date}.{patch}"
end
# index zero is reserved for the matched string
is_patch_release = semantic_version[3] != "0"
autogenerated_changelog = File.read("./auto_changelog.md")
CORE_TEAM = {
"samantazfox", "unixfox", "syeopite", "fijxu", "alexmaras", "thefrenchghosty", "perflyst",
}
MATCH_PULL_REQUEST_PATTERN = /(?<body>.*) by @(?<username>[a-zA-Z0-9_\-\[\]]+) in (?<link>https:\/\/github.com\/iv-org\/invidious\/pull\/\d+)/
prs = autogenerated_changelog.scan(MATCH_PULL_REQUEST_PATTERN).map do |pr|
username = pr["username"]
if CORE_TEAM.includes?(username.downcase)
attribution = "by"
else
attribution = "thanks"
end
"#{pr["body"]} (#{pr["link"]}, #{attribution} @#{username})"
end
puts ECR.render("scripts/release-utils/changelog-template.ecr")