Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions .ci/scripts/collect_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@
# For more info visit https://github.com/pulp/plugin_template

import itertools
import json
import os
import re
import tomllib
import urllib.request
from pathlib import Path

from git import GitCommandError, Repo
from packaging.version import parse as parse_version


PYPI_PROJECT = "pulp_npm"

# Read Towncrier settings
with open("pyproject.toml", "rb") as fp:
tc_settings = tomllib.load(fp)["tool"]["towncrier"]
tc_settings = tomllib.loads(Path("pyproject.toml").read_text())["tool"]["towncrier"]

CHANGELOG_FILE = tc_settings.get("filename", "NEWS.rst")
START_STRING = tc_settings.get(
Expand All @@ -35,7 +40,7 @@
# see help(re.split) for more info.
NAME_REGEX = r".*"
VERSION_REGEX = r"[0-9]+\.[0-9]+\.[0-9][0-9ab]*"
VERSION_CAPTURE_REGEX = rf"({VERSION_REGEX})"
VERSION_CAPTURE_REGEX = rf"(?:YANKED )?({VERSION_REGEX})"
DATE_REGEX = r"[0-9]{4}-[0-9]{2}-[0-9]{2}"
TITLE_REGEX = (
"("
Expand Down Expand Up @@ -75,6 +80,20 @@ def main():
branches.sort(key=lambda ref: parse_version(ref.remote_head), reverse=True)
branches = [ref.name for ref in branches]

changed = False

try:
response = urllib.request.urlopen(f"https://pypi.org/pypi/{PYPI_PROJECT}/json")
pypi_record = json.loads(response.read())
yanked_versions = {
parse_version(version): release[0]["yanked_reason"]
for version, release in pypi_record["releases"].items()
if release[0]["yanked"] is True
}
except Exception:
# If something failed, just don't mark anything as yanked.
yanked_versions = {}

with open(CHANGELOG_FILE, "r") as f:
main_changelog = f.read()
preamble, main_changes = split_changelog(main_changelog)
Expand All @@ -95,9 +114,19 @@ def main():
if left[0] != right[0]:
main_changes.append(right)

if yanked_versions:
for change in main_changes:
if change[0] in yanked_versions and "YANKED" not in change[1].split("\n")[0]:
reason = yanked_versions[change[0]]
version = str(change[0])
change[1] = change[1].replace(version, "YANKED " + version, count=1)
if reason:
change[1] = change[1].replace("\n", f"\n\nYank reason: {reason}\n", count=1)
changed = True

new_length = len(main_changes)
if old_length < new_length:
print(f"{new_length - old_length} new versions have been added.")
if old_length < new_length or changed:
print(f"{new_length - old_length} new versions have been added (or something has changed).")
with open(CHANGELOG_FILE, "w") as fp:
fp.write(preamble)
for change in main_changes:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/create-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
strategy:
fail-fast: false

permissions:
contents: write

steps:
- uses: "actions/checkout@v4"
with:
Expand Down
22 changes: 8 additions & 14 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
# For more info visit https://github.com/pulp/plugin_template

---
name: "Docs"
name: "Docs CI"
on:
workflow_call:

jobs:
test:
changelog:
if: "endsWith(github.base_ref, 'main')"
runs-on: "ubuntu-latest"
defaults:
Expand All @@ -22,28 +22,22 @@ jobs:
with:
fetch-depth: 1
path: "pulp_npm"
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
repository: "pulp/pulp-docs"
path: "pulp-docs"
ref: "rewrite-as-mkdocs-plugin"
- uses: "actions/setup-python@v5"
with:
python-version: "3.12"
- name: "Install python dependencies"
run: |
echo ::group::PYDEPS
pip install ../pulp-docs towncrier
pip install towncrier
echo ::endgroup::
- name: "Build changelog"
run: |
towncrier build --yes --version 4.0.0.ci
- name: "Build docs"
working-directory: "pulp-docs"
run: |
pulp-docs fetch --dest ..
pulp-docs build
docs:
if: "endsWith(github.base_ref, 'main')"
uses: 'pulp/pulp-docs/.github/workflows/docs-ci.yml@rewrite-as-mkdocs-plugin'
with:
pulpdocs_ref: 'rewrite-as-mkdocs-plugin'

no-test:
if: "!endsWith(github.base_ref, 'main')"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- uses: "actions/setup-python@v5"
with:
python-version: "3.11"
python-version: "3.13"

- name: "Install python dependencies"
run: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ jobs:
- "publish-python-bindings"
- "publish-ruby-bindings"

permissions:
contents: write

steps:
- name: "Create release on GitHub"
uses: "actions/github-script@v7"
Expand Down
2 changes: 1 addition & 1 deletion doc_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
#
# For more info visit https://github.com/pulp/plugin_template
towncrier
pulp-docs @ git+https://github.com/pulp/pulp-docs@main
pulp-docs @ git+https://github.com/pulp/pulp-docs@rewrite-as-mkdocs-plugin