Last active
September 26, 2023 00:28
-
-
Save mara004/f7f47d802f068595f5656953667ea77c to your computer and use it in GitHub Desktop.
Extract information from GitHub release notes
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
# SPDX-FileCopyrightText: 2023 geisserml <[email protected]> | |
# 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