Skip to content

Commit

Permalink
autorelease: add pdfium commit log
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Aug 23, 2022
1 parent 2a61322 commit c964276
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
2 changes: 2 additions & 0 deletions docs/devel/changelog_staging.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
<!-- List character: dash (-) -->

# Changelog for next release

- Rewrote the project's `README.md`. Added more support model examples and an extensive guide regarding the raw PDFium/ctypes API.
- Improved support model code style while writing the raw API guide.
- PDFium's commit log is now shown with GitHub releases.
41 changes: 28 additions & 13 deletions setupsrc/pl_setup/autorelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
exists,
abspath,
dirname,
basename,
)

sys.path.insert(0, dirname(dirname(abspath(__file__))))
Expand All @@ -21,6 +22,8 @@
set_version,
get_version_ns,
SourceTree,
SB_Dir,
PDFium_URL,
RepositoryURL,
Changelog,
ChangelogStaging,
Expand All @@ -29,6 +32,8 @@
)
from pl_setup.update_pdfium import get_latest_version


PdfiumHistoryDir = join(SB_Dir, "pdfium_history")
AutoreleaseDir = join(SourceTree, "autorelease")
UpdateMajor = join(AutoreleaseDir, "update_major.txt")
UpdateBeta = join(AutoreleaseDir, "update_beta.txt")
Expand Down Expand Up @@ -116,26 +121,36 @@ def register_changes(curr_ns):
run_local([Git, "checkout", "main"])


def link_for_tag(tag):
return RepositoryURL + "/tree/%s" % tag
def _get_log(url, cwd, ver_a, ver_b, prefix=""):
log = ""
log += "Commits between `%s` and `%s` (latest commit first):\n\n" % (ver_a, ver_b)
log += run_cmd([Git, "log", "%s..%s" % (prefix+ver_a, prefix+ver_b), "--pretty=format:* [`%h`]({}/%H) %s".format(url)], capture=True, cwd=cwd)
return log


def _get_pdfium_history():
if not exists(PdfiumHistoryDir):
run_cmd([Git, "clone", "--filter=blob:none", "--no-checkout", PDFium_URL, basename(PdfiumHistoryDir)], cwd=SB_Dir)
else:
run_cmd([Git, "pull"], cwd=PdfiumHistoryDir)


def make_releasenotes(summary, prev_ns, curr_ns):

# TODO include PDFium commit log

prev_ver = prev_ns["V_PYPDFIUM2"]
curr_ver = curr_ns["V_PYPDFIUM2"]
# Get a cut-down clone of PDFium that only contains the commit history
_get_pdfium_history()

relnotes = "Release %s\n\n" % curr_ver
relnotes += "## Changes\n\n"
relnotes += "### Manual Summary\n\n"
relnotes = ""
relnotes += "# Changes (Release %s)\n\n" % curr_ns["V_PYPDFIUM2"]
relnotes += "## pypdfium2\n\n"
relnotes += "### Summary\n\n"
if summary:
relnotes += summary + "\n"
relnotes += "### Git History\n\nCommits between "
relnotes += "[`%s`](%s) and [`%s`](%s) " % (prev_ver, link_for_tag(prev_ver), curr_ver, link_for_tag(curr_ver))
relnotes += "(latest commit first):\n\n"
relnotes += run_local([Git, "log", "%s..%s" % (prev_ver, curr_ver), "--pretty=format:* %H %s"], capture=True)
relnotes += "### Log\n\n"
relnotes += _get_log(RepositoryURL+"/commit", SourceTree, prev_ns["V_PYPDFIUM2"], curr_ns["V_PYPDFIUM2"]) + "\n\n"
relnotes += "## PDFium\n\n"
relnotes += "### Log\n\n"
relnotes += _get_log(PDFium_URL+"/+", PdfiumHistoryDir, prev_ns["V_LIBPDFIUM"], curr_ns["V_LIBPDFIUM"], prefix="origin/chromium/")
relnotes += "\n"

with open(join(SourceTree, "RELEASE.md"), "w") as fh:
Expand Down
5 changes: 2 additions & 3 deletions setupsrc/pl_setup/build_pdfium.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
Libnames,
DataTree,
VerNamespace,
PDFium_URL,
DepotTools_URL,
PlatformNames,
run_cmd,
call_ctypesgen,
Expand All @@ -30,9 +32,6 @@
PDFiumBuildDir = join(PDFiumDir, "out", "Default")
OutputDir = join(DataTree, PlatformNames.sourcebuild)

DepotTools_URL = "https://chromium.googlesource.com/chromium/tools/depot_tools.git"
PDFium_URL = "https://pdfium.googlesource.com/pdfium.git"

PdfiumMainPatches = [
(join(PatchDir, "pdfium", "public_headers.patch"), PDFiumDir),
(join(PatchDir, "pdfium", "shared_library.patch"), PDFiumDir),
Expand Down
4 changes: 3 additions & 1 deletion setupsrc/pl_setup/packaging_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
VersionFile = join(ModuleDir, "version.py")
Changelog = join(SourceTree, "docs", "source", "changelog.md")
ChangelogStaging = join(SourceTree, "docs", "devel", "changelog_staging.md")
RepositoryURL = "https://github.com/pypdfium2-team/pypdfium2"
SetupTargetVar = "PYP_TARGET_PLATFORM"
RepositoryURL = "https://github.com/pypdfium2-team/pypdfium2"
DepotTools_URL = "https://chromium.googlesource.com/chromium/tools/depot_tools"
PDFium_URL = "https://pdfium.googlesource.com/pdfium"


class PlatformNames:
Expand Down

0 comments on commit c964276

Please sign in to comment.