Last active
February 17, 2022 21:31
-
-
Save agilous/a92d32ea9c90c2b2602e41fe0eff85c5 to your computer and use it in GitHub Desktop.
Simple RELEASE-NOTES.md generator script using Octokit gem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'octokit' # (See: https://github.com/octokit/octokit.rb) | |
# (See: https://github.com/settings/tokens OR https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) | |
personal_access_token = 'ghp_1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' | |
client = Octokit::Client.new(access_token: personal_access_token) | |
client.auto_paginate = true | |
repo_name = 'foo/bar' | |
releases = client.releases(repo_name) | |
unless releases.any? | |
puts "No releases found for #{repo_name}" | |
exit | |
end | |
filename = "RELEASE-NOTES.md" | |
f = File.new(filename, "w") | |
releases.each do |release| | |
f.write("# [#{release[:tag_name]}](#{release[:html_url]}) #{release[:published_at].strftime('%Y-%m-%d')}\n") | |
f.write("## #{release[:name]}\n") | |
f.write("#{release[:body].gsub(/^-+/, '*')}\n\n") | |
end | |
f.close | |
puts "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment