Skip to content

Instantly share code, notes, and snippets.

@mara004
Last active September 26, 2023 00:28
Show Gist options
  • Save mara004/f7f47d802f068595f5656953667ea77c to your computer and use it in GitHub Desktop.
Save mara004/f7f47d802f068595f5656953667ea77c to your computer and use it in GitHub Desktop.
Extract information from GitHub release notes
# SPDX-FileCopyrightText: 2023 geisserml <geisserml@gmail.com>
# SPDX-License-Identifier: CC-BY-4.0 OR Apache-2.0 OR BSD-3-Clause
# Unlike repository files, there is no "raw view" for GH releases, but we can extract the plain markdown content using GH web API
# See also https://stackoverflow.com/q/76995969/15547292
# The following code snippet shows how to get a release title from pdfium-binaries to extract the full version
import re
import json
import urllib.request as url_request
ReleaseRepo = "https://github.com/bblanchon/pdfium-binaries"
ReleaseURL = ReleaseRepo + "/releases/download/chromium%2F"
ReleaseInfoURL = ReleaseURL.replace("github.com/", "api.github.com/repos/").replace("download/", "tags/")
def get_full_version(v_short):
info = url_request.urlopen(ReleaseInfoURL+v_short).read().decode("utf-8")
info = json.loads(info)
title = info["name"]
# note: description would be info["body"]
match = re.match(fr"PDFium (\d+.\d+.{v_short}.\d+)", title)
return match.group(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment