tools: add update_gitea_releases.py and release-notes snippets

One-shot script to backfill Gitea release bodies for existing releases
using the Gitea API. Reads per-version Markdown files from
tools/release-notes/ and PATCHes each release body.
Includes README.md in tools/release-notes/ explaining usage.
This commit is contained in:
2026-05-02 21:54:01 +02:00
parent df1e68b378
commit 6e91c0ac31
7 changed files with 181 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
# update_gitea_releases.py
Script one-shot per aggiornare il body delle release Gitea esistenti con il testo del CHANGELOG.
## Quando usarlo
Il workflow `release.yml` aggiorna automaticamente il body delle release **nuove** su Gitea.
Questo script serve per le release **già esistenti**, create prima che quella funzionalità fosse aggiunta.
## Prerequisiti
- Python 3.8+
- Un Gitea API token con permesso **Repository → Read and Write**
### Creare il token su Gitea
1. Gitea → avatar → **Settings****Applications**
2. Sezione **"Manage Access Tokens"** → nome a piacere (es. `release-body-update`)
3. Permission: **Repository**`Read and Write`
4. **Generate Token** → copia il valore (mostrato una sola volta)
## Uso
```bash
# Tramite variabile d'ambiente
GITEA_TOKEN=<token> python3 tools/update_gitea_releases.py
# Tramite argomento
python3 tools/update_gitea_releases.py --token <token>
```
## Output atteso
```
[v2.0.0] recupero release... id=1, aggiorno body... OK
[v2.0.1] recupero release... id=2, aggiorno body... OK
[v2.1.0] recupero release... id=3, aggiorno body... OK
[v2.2.0] recupero release... id=4, aggiorno body... OK
[v2.2.1] recupero release... id=5, aggiorno body... OK
```
Se una release non esiste su Gitea per quel tag, la riga mostra `SALTATO`.
## Come funziona
Per ogni file `tools/release-notes/vX.Y.Z.md`:
1. Chiama `GET /api/v1/repos/{owner}/{repo}/releases/tags/vX.Y.Z` per ottenere l'ID
2. Chiama `PATCH /api/v1/repos/{owner}/{repo}/releases/{id}` con il body del file `.md`
## Aggiungere nuove versioni
Crea un file `tools/release-notes/vX.Y.Z.md` con il contenuto desiderato, poi riesegui lo script.
Per le release future il workflow lo fa automaticamente — questo script non è necessario.
+8
View File
@@ -0,0 +1,8 @@
### Added
- Prima release come repository indipendente
- Build script unificato (`build_plugin.py`) con CLI canonica
- CI/CD via GitHub Actions (mirror automatico Gitea → GitHub)
- Documentazione completa (README, CONTRIBUTING, SECURITY)
---
_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._
+8
View File
@@ -0,0 +1,8 @@
### Fixed
- Restored `tools/legacy/` build scripts lost from repository
- Fixed `UnicodeEncodeError` on CI: replaced Unicode checkmarks with ASCII OK/FAIL in build summary
- Fixed MSB8020 toolset error on GitHub Actions: `build_plugin_2600_vs2026.py` now detects the installed VS toolset dynamically (falls back to v143 on VS2022 runners)
- Build script for 26.00 selects `Nsis7z_vs2026.vcxproj` (v145) or `Nsis7z.vcxproj` (v143) based on detected toolset
---
_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._
+13
View File
@@ -0,0 +1,13 @@
### Added
- NSIS plugin API (`pluginapi.cpp`/`pluginapi.h`) for 7-Zip zstd build
- `ExtractCallbackConsole` class for extraction progress and user input
- Main extraction logic (`Main.cpp`, `MainAr.cpp`) for the zstd bundle
- User input utilities (`UserInputUtils2`) for password handling and prompts
- Break signal handling (`NSISBreak`) for graceful interruption
- `Nsis7z_vs2026.vcxproj` (v145 toolset) for Visual Studio 2026 builds
- `tools/fix_vcxproj.py` helper for project file patching
- `versions/7-zip-zstd` submodule added
- `build_zstd.cmd` top-level build script for the zstd variant
---
_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._
+11
View File
@@ -0,0 +1,11 @@
### Added
- Linux MinGW-w64 cross-build support in `build_plugin.py` via `--host linux`
- `tools/linux/build_plugin_linux.py` for standalone Linux builds
- Color output and progress spinner in all legacy build scripts
### Changed
- `build_plugin.py` now supports both Windows (MSBuild) and Linux (MinGW-w64) targets
- Windows build-script f-string fixes
---
_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._
+8
View File
@@ -0,0 +1,8 @@
### Added
- Linux CI jobs for the GitHub `build` and `release` workflows using the MinGW-w64 cross-build path
### Changed
- GitHub Actions workflows now opt into Node 24 for JavaScript-based actions to avoid Node 20 deprecation warnings
---
_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._
+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env python3
"""
One-shot script: aggiorna il body delle release Gitea esistenti
con i file in tools/release-notes/.
Uso:
GITEA_TOKEN=<token> python3 tools/update_gitea_releases.py
oppure:
python3 tools/update_gitea_releases.py --token <token>
"""
import argparse
import json
import os
import sys
import urllib.request
import urllib.error
from pathlib import Path
GITEA_BASE = "https://gitea.emulab.it/api/v1"
REPO = "Simone/nsis-plugin-ns7zip"
NOTES_DIR = Path(__file__).parent / "release-notes"
def api(method: str, path: str, token: str, data: dict | None = None) -> dict:
url = f"{GITEA_BASE}{path}"
body = json.dumps(data).encode() if data else None
req = urllib.request.Request(
url,
data=body,
method=method,
headers={
"Authorization": f"token {token}",
"Content-Type": "application/json",
"Accept": "application/json",
},
)
try:
with urllib.request.urlopen(req) as resp:
return json.loads(resp.read())
except urllib.error.HTTPError as e:
print(f" HTTP {e.code} {e.reason}{e.read().decode()}", file=sys.stderr)
raise
def main() -> None:
parser = argparse.ArgumentParser(description="Update Gitea release bodies")
parser.add_argument("--token", default=os.environ.get("GITEA_TOKEN"), help="Gitea API token")
args = parser.parse_args()
if not args.token:
sys.exit("Errore: token mancante. Usa --token oppure imposta GITEA_TOKEN.")
note_files = sorted(NOTES_DIR.glob("v*.md"))
if not note_files:
sys.exit(f"Nessun file trovato in {NOTES_DIR}")
for note_path in note_files:
tag = note_path.stem # es. v2.2.1
body = note_path.read_text(encoding="utf-8").strip()
print(f"[{tag}] recupero release...", end=" ", flush=True)
try:
release = api("GET", f"/repos/{REPO}/releases/tags/{tag}", args.token)
except urllib.error.HTTPError:
print("SALTATO (release non trovata)")
continue
release_id = release["id"]
print(f"id={release_id}, aggiorno body...", end=" ", flush=True)
try:
api("PATCH", f"/repos/{REPO}/releases/{release_id}", args.token, {"body": body})
print("OK")
except urllib.error.HTTPError:
print("FALLITO")
if __name__ == "__main__":
main()