googleapis / googleapis/google-cloud-python

automated release fails due to missing PyPI history anchor

Offen
#16,188 2 Kommentare 2 Reaktionen 1 zugewiesene Person Beansprucht von @gkevinzheng Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
5.4k
Forks
1.8k
Ø Merge
3 T. 4 Std.
Gemergte PRs (30 T.)
122

Beschreibung

### Description

The release automation script (`cli.py`) fails with a `ValueError` when trying to update a library's `CHANGELOG.md` if the file doesn't use the exact hardcoded PyPI history anchor. This blocks releases for any package that has a malformed or missing header.

### Affected Code

In `.generator/cli.py` (lines 1533-1540):

```python
anchor_pattern = re.compile(
rf"(\[1\]: https://pypi\.org/project/{library_id}/#history)",
re.MULTILINE,
)
...
if num_subs == 0:
raise ValueError("Changelog anchor '[1]: ...#history' not found.")
```

### Root Cause

The regular expression is too strict:
1. It expects `[1]:` literally. If a package uses `[2]:` or similar, it fails.
2. It expects the PyPI project name to match the folder name `{library_id}` exactly.
3. It has strict spacing requirements.

### Proposed Solution

Make `_process_changelog` more robust by:
- Falling back to a less strict regex (e.g., searching for any link containing `pypi.org/project/` and `#history`).
- If no anchor is found, auto-prepend it to the file instead of raising a fatal error.

### Culprit Found

During investigation, `packages/google-cloud-documentai-toolbox/CHANGELOG.md` was found to be missing this anchor, which was blocking its release. I will create a PR to add this shortly.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.