Konloch Software

Importing GitHub Release Notes

Published 08/09/2024

One of the things I want to do with this project is to import my old GitHub release notes. They’re not exactly pretty, or indicative of my current-day writing. But it’s at least something, and it’s stuff I’d like to share.

Bytecode-Viewer is my largest project on GitHub, it contains 55 releases as of writing.

One of the challenges was getting all of my release notes reliably. With all information, such as versioning, title, date, etc.

One benefit I share with GitHub is I write my posts with Markdown. So I assumed I could just use the GitHub API and poll my releases page.

Getting Started

The GitHub API for Bytecode-Viewer’s release is located at https://api.github.com/repos/Konloch/bytecode-viewer/releases

This returns json blob containing all the information I could ever want. Including everything I set out for initially. Great start.

Parsing & Saving To Disk

Once you fetch the contents, you’ll have to parse it & save to disk.

String jsonResponse = fetchReleases();

JSONArray releases = new JSONArray(jsonResponse);

for (int i = 0; i < releases.length(); i++)
{
	try
	{
		JSONObject release = releases.getJSONObject(i);
		String version = release.getString("tag_name");
		String title = release.getString("name");
		String description = release.getString("body");
		String publishedDate = release.getString("published_at").substring(0, 10);
		String editedDate = release.has("updated_at") ? release.getString("updated_at").substring(0, 10) : publishedDate;

		publishedDate = formatDate(publishedDate);
		editedDate = formatDate(editedDate);

		saveDescriptionToFile(version, title, publishedDate, editedDate, description);
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
}

Getting GitHub To Return More Than 30 Results

This worked for the first 30 releases, but it’s limited after that. After consulting the manual there was two possible fixes. I could append a page number and do multiple requests. Or I could just append ?per_page=100 onto the GitHub URL.

  • The end URL being https://api.github.com/repos/Konloch/bytecode-viewer/releases?per_page=100

And that’s it. Using this system I was able to automatically import 55 old posts for the Bytecode-Viewer update log section.

I eventually plan to turn this blog base into a static website generator. When I do I’d like to add GitHub release notes as a supported module.