Hilfsskripte in PowerShell statt Node.js
This commit is contained in:
1 parent
c8014d6f5e
commit
302faa395c
12 files changed
+311
-288
No files matched your search
@@ -17,24 +17,25 @@ aktualisiert – **komplett lokal**, ohne GitHub/GitLab. Das Repo liegt einfach
|
|||||||
│ └── src/{Core,Api}/*.csproj
|
│ └── src/{Core,Api}/*.csproj
|
||||||
├── renovate.json # Repo-Konfiguration für Renovate (Regeln, Gruppierung)
|
├── renovate.json # Repo-Konfiguration für Renovate (Regeln, Gruppierung)
|
||||||
├── renovate/config.js # Bot-Konfiguration für den lokalen Lauf
|
├── renovate/config.js # Bot-Konfiguration für den lokalen Lauf
|
||||||
└── scripts/*.mjs # Hilfsskripte in Node.js (Windows, Linux, macOS)
|
└── scripts/*.ps1 # Hilfsskripte in PowerShell
|
||||||
```
|
```
|
||||||
|
|
||||||
Alle Pakete sind absichtlich auf älteren Versionen, damit Renovate etwas zu tun hat.
|
Alle Pakete sind absichtlich auf älteren Versionen, damit Renovate etwas zu tun hat.
|
||||||
|
|
||||||
## Voraussetzungen
|
## Voraussetzungen
|
||||||
|
|
||||||
|
- Windows PowerShell 5.1 oder PowerShell 7 (die npm-Scripts rufen `powershell` auf)
|
||||||
- Node.js ≥ 24.11 (mit Volta automatisch über `"volta"` in `package.json`). Renovate wird per `npx`
|
- Node.js ≥ 24.11 (mit Volta automatisch über `"volta"` in `package.json`). Renovate wird per `npx`
|
||||||
in einer festen Version geladen, siehe `scripts/lib.mjs`
|
in einer festen Version geladen, siehe `scripts/lib.ps1`
|
||||||
- Git
|
- Git
|
||||||
- Podman oder Docker, nur für Variante 2 (wird automatisch erkannt; `CONTAINER_ENGINE=docker` erzwingt Docker)
|
- Podman oder Docker, nur für Variante 2 (wird automatisch erkannt; `CONTAINER_ENGINE=docker` erzwingt Docker)
|
||||||
- Läuft unter Windows (PowerShell), Linux und macOS. Getestet habe ich bisher nur unter Linux
|
- Unter Linux/macOS mit PowerShell 7 die Skripte direkt starten, z. B. `pwsh scripts/renovate-update.ps1`
|
||||||
- Internetzugang zu `registry.npmjs.org` und `api.nuget.org` (für die Versions-Lookups)
|
- Internetzugang zu `registry.npmjs.org` und `api.nuget.org` (für die Versions-Lookups)
|
||||||
- Ein .NET SDK ist **nicht** nötig (es gibt keine NuGet-Lockfiles)
|
- Ein .NET SDK ist **nicht** nötig (es gibt keine NuGet-Lockfiles)
|
||||||
|
|
||||||
## Variante 1: Nur prüfen (`--platform=local`)
|
## Variante 1: Nur prüfen (`--platform=local`)
|
||||||
|
|
||||||
```bash
|
```powershell
|
||||||
npm run renovate:check
|
npm run renovate:check
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ geändert**. Ausgabe: Liste aller verfügbaren Updates, plus JSON-Report in `.re
|
|||||||
|
|
||||||
## Variante 2: Prüfen und aktualisieren (lokales Forgejo)
|
## Variante 2: Prüfen und aktualisieren (lokales Forgejo)
|
||||||
|
|
||||||
```bash
|
```powershell
|
||||||
npm run renovate:update
|
npm run renovate:update
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -61,13 +62,13 @@ Das Skript
|
|||||||
|
|
||||||
**Jeder Lauf erzeugt einen neuen Branch + PR** mit Zeitstempel (lokale Zeit, `yyyy-MM-dd-HH-mm-ss-SSS`),
|
**Jeder Lauf erzeugt einen neuen Branch + PR** mit Zeitstempel (lokale Zeit, `yyyy-MM-dd-HH-mm-ss-SSS`),
|
||||||
z. B. Branch `renovate/2026-10-11-14-03-22-123-all` mit PR „Update all dependencies (2026-10-11-14-03-22-123)“.
|
z. B. Branch `renovate/2026-10-11-14-03-22-123-all` mit PR „Update all dependencies (2026-10-11-14-03-22-123)“.
|
||||||
Dafür setzt `scripts/renovate-update.mjs` pro Lauf `branchPrefix` (und `branchPrefixOld`) auf `renovate/<zeitstempel>-`.
|
Dafür setzt `scripts/renovate-update.ps1` pro Lauf `branchPrefix` (und `branchPrefixOld`) auf `renovate/<zeitstempel>-`.
|
||||||
Renovate verwaltet nur Branches mit dem aktuellen Präfix – PRs früherer Läufe bleiben unverändert offen
|
Renovate verwaltet nur Branches mit dem aktuellen Präfix – PRs früherer Läufe bleiben unverändert offen
|
||||||
und müssen bei Bedarf manuell geschlossen werden. Gibt es keine Updates, wird nichts erstellt.
|
und müssen bei Bedarf manuell geschlossen werden. Gibt es keine Updates, wird nichts erstellt.
|
||||||
|
|
||||||
Updates übernehmen:
|
Updates übernehmen:
|
||||||
|
|
||||||
```bash
|
```powershell
|
||||||
git branch -r --list 'forgejo/renovate/*' # alle Update-Branches
|
git branch -r --list 'forgejo/renovate/*' # alle Update-Branches
|
||||||
git diff main...forgejo/renovate/<zeitstempel>-all # Änderungen ansehen
|
git diff main...forgejo/renovate/<zeitstempel>-all # Änderungen ansehen
|
||||||
git merge forgejo/renovate/<zeitstempel>-all # lokal übernehmen
|
git merge forgejo/renovate/<zeitstempel>-all # lokal übernehmen
|
||||||
@@ -84,18 +85,26 @@ Läuft das Ganze in einem Container (z. B. jgcl-code), muss Port 3000 zum Host f
|
|||||||
|
|
||||||
Aufräumen:
|
Aufräumen:
|
||||||
|
|
||||||
```bash
|
```powershell
|
||||||
npm run forgejo:down # Forgejo stoppen (Daten bleiben)
|
npm run forgejo:down # Forgejo stoppen (Daten bleiben)
|
||||||
npm run forgejo:purge # Container, Volume, Token und Git-Remote entfernen
|
npm run forgejo:purge # Container, Volume, Token und Git-Remote entfernen
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Ohne npm geht es auch direkt:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\scripts\renovate-check.ps1
|
||||||
|
.\scripts\renovate-update.ps1
|
||||||
|
.\scripts\forgejo-down.ps1 -Purge
|
||||||
|
```
|
||||||
|
|
||||||
## Konfiguration
|
## Konfiguration
|
||||||
|
|
||||||
| Datei | Zweck |
|
| Datei | Zweck |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `renovate.json` | `config:recommended` + `group:all`: **alle Updates (inkl. Major) in einem PR** „Update all dependencies“, Workspace-Pakete `@demo/*` ausgenommen |
|
| `renovate.json` | `config:recommended` + `group:all`: **alle Updates (inkl. Major) in einem PR** „Update all dependencies“, Workspace-Pakete `@demo/*` ausgenommen |
|
||||||
| `renovate/config.js` | Plattform `forgejo`, kein Onboarding, keine PR-Limits |
|
| `renovate/config.js` | Plattform `forgejo`, kein Onboarding, keine PR-Limits |
|
||||||
| `scripts/lib.mjs` | Renovate-Version, Forgejo-Image/Port/User – alles per Env-Variable überschreibbar |
|
| `scripts/lib.ps1` | Renovate-Version, Forgejo-Image/Port/User – alles per Env-Variable überschreibbar |
|
||||||
|
|
||||||
Nützliche Env-Variablen:
|
Nützliche Env-Variablen:
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -8,11 +8,11 @@
|
|||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"renovate:check": "node scripts/renovate-check.mjs",
|
"renovate:check": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/renovate-check.ps1",
|
||||||
"renovate:update": "node scripts/renovate-update.mjs",
|
"renovate:update": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/renovate-update.ps1",
|
||||||
"forgejo:up": "node scripts/forgejo-up.mjs",
|
"forgejo:up": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/forgejo-up.ps1",
|
||||||
"forgejo:down": "node scripts/forgejo-down.mjs",
|
"forgejo:down": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/forgejo-down.ps1",
|
||||||
"forgejo:purge": "node scripts/forgejo-down.mjs --purge"
|
"forgejo:purge": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/forgejo-down.ps1 -Purge"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "3.0.0"
|
"prettier": "3.0.0"
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
// Stoppt das lokale Forgejo. Mit --purge werden Container, Daten-Volume, Token und Git-Remote gelöscht.
|
|
||||||
import fs from "node:fs";
|
|
||||||
import {
|
|
||||||
STATE_DIR, FORGEJO_CONTAINER, FORGEJO_VOLUME, GIT_REMOTE, log, run, containerEngine, main,
|
|
||||||
} from "./lib.mjs";
|
|
||||||
|
|
||||||
main(async () => {
|
|
||||||
const engine = containerEngine();
|
|
||||||
const quiet = { capture: true, allowFail: true };
|
|
||||||
|
|
||||||
run(engine, ["stop", FORGEJO_CONTAINER], quiet);
|
|
||||||
if (process.argv.includes("--purge")) {
|
|
||||||
run(engine, ["rm", "-f", FORGEJO_CONTAINER], quiet);
|
|
||||||
run(engine, ["volume", "rm", "-f", FORGEJO_VOLUME], quiet);
|
|
||||||
fs.rmSync(STATE_DIR, { recursive: true, force: true });
|
|
||||||
run("git", ["remote", "remove", GIT_REMOTE], quiet);
|
|
||||||
log("Forgejo inkl. Daten entfernt");
|
|
||||||
} else {
|
|
||||||
log("Forgejo gestoppt (Daten bleiben erhalten; --purge zum Löschen)");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Stoppt das lokale Forgejo. Mit -Purge werden Container, Daten-Volume, Token und Git-Remote gelöscht.
|
||||||
|
param([switch]$Purge)
|
||||||
|
. "$PSScriptRoot\lib.ps1"
|
||||||
|
|
||||||
|
Invoke-Main {
|
||||||
|
$engine = Get-ContainerEngine
|
||||||
|
Invoke-Native $engine @('stop', $ForgejoContainer) -Capture -AllowFail | Out-Null
|
||||||
|
if ($Purge) {
|
||||||
|
Invoke-Native $engine @('rm', '-f', $ForgejoContainer) -Capture -AllowFail | Out-Null
|
||||||
|
Invoke-Native $engine @('volume', 'rm', '-f', $ForgejoVolume) -Capture -AllowFail | Out-Null
|
||||||
|
if (Test-Path $StateDir) { Remove-Item -Recurse -Force $StateDir }
|
||||||
|
Invoke-Native 'git' @('remote', 'remove', $GitRemote) -Capture -AllowFail | Out-Null
|
||||||
|
Write-Step 'Forgejo inkl. Daten entfernt'
|
||||||
|
} else {
|
||||||
|
Write-Step 'Forgejo gestoppt (Daten bleiben erhalten; -Purge zum Löschen)'
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
// Startet ein lokales Forgejo (Git-Server) in Podman/Docker, legt Bot-User, Token und
|
|
||||||
// Repository an und pusht den aktuellen Stand des lokalen Repos dorthin.
|
|
||||||
import fs from "node:fs";
|
|
||||||
import path from "node:path";
|
|
||||||
import { pathToFileURL } from "node:url";
|
|
||||||
import {
|
|
||||||
STATE_DIR, FORGEJO_IMAGE, FORGEJO_CONTAINER, FORGEJO_VOLUME, FORGEJO_PORT, FORGEJO_URL,
|
|
||||||
FORGEJO_USER, FORGEJO_PASSWORD, FORGEJO_REPO, GIT_REMOTE, log, run, containerEngine, main,
|
|
||||||
} from "./lib.mjs";
|
|
||||||
|
|
||||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
||||||
|
|
||||||
async function healthy() {
|
|
||||||
try {
|
|
||||||
return (await fetch(`${FORGEJO_URL}/api/healthz`)).ok;
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function forgejoUp() {
|
|
||||||
fs.mkdirSync(STATE_DIR, { recursive: true });
|
|
||||||
const engine = containerEngine();
|
|
||||||
|
|
||||||
const exists = !run(engine, ["container", "inspect", FORGEJO_CONTAINER], { capture: true, allowFail: true }).status;
|
|
||||||
if (!exists) {
|
|
||||||
log(`Starte Forgejo (${FORGEJO_IMAGE}) auf ${FORGEJO_URL} via ${engine}`);
|
|
||||||
run(engine, [
|
|
||||||
"run", "-d", "--name", FORGEJO_CONTAINER,
|
|
||||||
"-p", `${FORGEJO_PORT}:3000`,
|
|
||||||
"-v", `${FORGEJO_VOLUME}:/data`,
|
|
||||||
"-e", "USER_UID=1000", "-e", "USER_GID=1000",
|
|
||||||
"-e", "FORGEJO__security__INSTALL_LOCK=true",
|
|
||||||
"-e", `FORGEJO__server__ROOT_URL=${FORGEJO_URL}/`,
|
|
||||||
"-e", "FORGEJO__server__HTTP_PORT=3000",
|
|
||||||
"-e", "FORGEJO__database__DB_TYPE=sqlite3",
|
|
||||||
"-e", "FORGEJO__service__DISABLE_REGISTRATION=true",
|
|
||||||
"-e", "FORGEJO__repository__DEFAULT_BRANCH=main",
|
|
||||||
FORGEJO_IMAGE,
|
|
||||||
], { capture: true });
|
|
||||||
} else {
|
|
||||||
run(engine, ["start", FORGEJO_CONTAINER], { capture: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
log("Warte auf Forgejo …");
|
|
||||||
for (let i = 0; i < 60 && !(await healthy()); i++) await sleep(1000);
|
|
||||||
if (!(await healthy())) throw new Error(`Forgejo unter ${FORGEJO_URL} nicht erreichbar`);
|
|
||||||
|
|
||||||
const forgejoCli = (...args) =>
|
|
||||||
run(engine, ["exec", "-u", "git", FORGEJO_CONTAINER, "forgejo", ...args], { capture: true }).stdout;
|
|
||||||
|
|
||||||
const users = forgejoCli("admin", "user", "list").split("\n").map((l) => l.trim().split(/\s+/)[1]);
|
|
||||||
if (!users.includes(FORGEJO_USER)) {
|
|
||||||
log(`Lege Admin-/Bot-User '${FORGEJO_USER}' an`);
|
|
||||||
forgejoCli("admin", "user", "create", "--admin", "--username", FORGEJO_USER,
|
|
||||||
"--password", FORGEJO_PASSWORD, "--email", "renovate@localhost", "--must-change-password=false");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Token wiederverwenden, solange Forgejo es kennt (nach Neuaufsetzen von Forgejo ist es ungültig)
|
|
||||||
const tokenFile = path.join(STATE_DIR, "token");
|
|
||||||
let token = fs.existsSync(tokenFile) ? fs.readFileSync(tokenFile, "utf8").trim() : "";
|
|
||||||
if (!token || !(await fetch(`${FORGEJO_URL}/api/v1/user`, { headers: { Authorization: `token ${token}` } })).ok) {
|
|
||||||
log("Erzeuge Access-Token");
|
|
||||||
token = forgejoCli("admin", "user", "generate-access-token", "--username", FORGEJO_USER,
|
|
||||||
"--token-name", `renovate-${Date.now()}`, "--scopes", "all", "--raw").trim();
|
|
||||||
fs.writeFileSync(tokenFile, token);
|
|
||||||
}
|
|
||||||
const headers = { Authorization: `token ${token}`, "Content-Type": "application/json" };
|
|
||||||
|
|
||||||
const repoRes = await fetch(`${FORGEJO_URL}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}`, { headers });
|
|
||||||
if (!repoRes.ok) {
|
|
||||||
log(`Lege Repository ${FORGEJO_USER}/${FORGEJO_REPO} an`);
|
|
||||||
const res = await fetch(`${FORGEJO_URL}/api/v1/user/repos`, {
|
|
||||||
method: "POST",
|
|
||||||
headers,
|
|
||||||
body: JSON.stringify({ name: FORGEJO_REPO, default_branch: "main", private: false }),
|
|
||||||
});
|
|
||||||
if (!res.ok) throw new Error(`Repository anlegen fehlgeschlagen: ${res.status} ${await res.text()}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const remoteUrl = `http://${FORGEJO_USER}:${token}@localhost:${FORGEJO_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}.git`;
|
|
||||||
const hasRemote = !run("git", ["remote", "get-url", GIT_REMOTE], { capture: true, allowFail: true }).status;
|
|
||||||
run("git", ["remote", hasRemote ? "set-url" : "add", GIT_REMOTE, remoteUrl]);
|
|
||||||
|
|
||||||
log("Pushe lokalen Branch 'main' nach Forgejo");
|
|
||||||
run("git", ["push", "-q", GIT_REMOTE, "main:main"]);
|
|
||||||
|
|
||||||
log(`Forgejo läuft: ${FORGEJO_URL} (Login: ${FORGEJO_USER} / ${FORGEJO_PASSWORD})`);
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (import.meta.url === pathToFileURL(process.argv[1]).href) main(forgejoUp);
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Startet ein lokales Forgejo (Git-Server) in Podman/Docker, legt Bot-User, Token und
|
||||||
|
# Repository an und pusht den aktuellen Stand des lokalen Repos dorthin.
|
||||||
|
. "$PSScriptRoot\lib.ps1"
|
||||||
|
|
||||||
|
Invoke-Main { Start-Forgejo | Out-Null }
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
// Gemeinsame Einstellungen und Helfer für die Renovate-Skripte (plattformunabhängig: Windows/Linux/macOS).
|
|
||||||
import { spawnSync } from "node:child_process";
|
|
||||||
import { fileURLToPath } from "node:url";
|
|
||||||
import path from "node:path";
|
|
||||||
|
|
||||||
const env = process.env;
|
|
||||||
|
|
||||||
export const ROOT_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
||||||
export const STATE_DIR = path.join(ROOT_DIR, ".renovate-local");
|
|
||||||
|
|
||||||
export const RENOVATE_VERSION = env.RENOVATE_VERSION ?? "44.149.3";
|
|
||||||
|
|
||||||
export const FORGEJO_IMAGE = env.FORGEJO_IMAGE ?? "codeberg.org/forgejo/forgejo:11";
|
|
||||||
export const FORGEJO_CONTAINER = env.FORGEJO_CONTAINER ?? "renovate-forgejo";
|
|
||||||
export const FORGEJO_VOLUME = env.FORGEJO_VOLUME ?? "renovate-forgejo-data";
|
|
||||||
export const FORGEJO_PORT = env.FORGEJO_PORT ?? "3000";
|
|
||||||
export const FORGEJO_URL = `http://localhost:${FORGEJO_PORT}`;
|
|
||||||
export const FORGEJO_USER = env.FORGEJO_USER ?? "renovate";
|
|
||||||
export const FORGEJO_PASSWORD = env.FORGEJO_PASSWORD ?? "renovate-local-123";
|
|
||||||
export const FORGEJO_REPO = env.FORGEJO_REPO ?? "monorepo";
|
|
||||||
export const GIT_REMOTE = env.GIT_REMOTE ?? "forgejo";
|
|
||||||
|
|
||||||
const isWindows = process.platform === "win32";
|
|
||||||
|
|
||||||
export function log(msg) {
|
|
||||||
console.log(`\x1b[1;34m==>\x1b[0m ${msg}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Führt einen Befehl aus. Bricht bei Fehler ab, außer `allowFail` ist gesetzt. */
|
|
||||||
export function run(cmd, args, { capture = false, allowFail = false, extraEnv = {} } = {}) {
|
|
||||||
const res = spawnSync(cmd, args, {
|
|
||||||
cwd: ROOT_DIR,
|
|
||||||
stdio: capture ? ["ignore", "pipe", "pipe"] : "inherit",
|
|
||||||
encoding: "utf8",
|
|
||||||
env: { ...env, ...extraEnv },
|
|
||||||
// npx/npm sind unter Windows .cmd-Dateien und brauchen eine Shell
|
|
||||||
shell: isWindows && (cmd === "npx" || cmd === "npm"),
|
|
||||||
});
|
|
||||||
if (res.error) {
|
|
||||||
if (allowFail) return res;
|
|
||||||
throw new Error(`'${cmd}' konnte nicht gestartet werden: ${res.error.message}`);
|
|
||||||
}
|
|
||||||
if (res.status !== 0 && !allowFail) {
|
|
||||||
if (capture) process.stderr.write(res.stderr ?? "");
|
|
||||||
throw new Error(`'${cmd} ${args.join(" ")}' endete mit Exit-Code ${res.status}`);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function renovateCli(args, extraEnv = {}) {
|
|
||||||
return run("npx", ["--yes", `renovate@${RENOVATE_VERSION}`, ...args], { extraEnv });
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Podman bevorzugen, sonst Docker (CONTAINER_ENGINE=docker erzwingt Docker). */
|
|
||||||
export function containerEngine() {
|
|
||||||
const candidates = env.CONTAINER_ENGINE ? [env.CONTAINER_ENGINE] : ["podman", "docker"];
|
|
||||||
for (const c of candidates) {
|
|
||||||
if (!run(c, ["--version"], { capture: true, allowFail: true }).error) return c;
|
|
||||||
}
|
|
||||||
throw new Error("Weder podman noch docker gefunden – wird für Forgejo benötigt.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Startet ein Skript-main() mit sauberer Fehlerausgabe. */
|
|
||||||
export function main(fn) {
|
|
||||||
fn().catch((err) => {
|
|
||||||
console.error(`\x1b[1;31mFehler:\x1b[0m ${err.message}`);
|
|
||||||
// exitCode statt process.exit(): verhindert unter Windows einen libuv-Absturz bei offenen fetch-Handles
|
|
||||||
process.exitCode = 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
+183
@@ -0,0 +1,183 @@
|
|||||||
|
# Gemeinsame Einstellungen und Helfer für die Renovate-Skripte.
|
||||||
|
# Kompatibel mit Windows PowerShell 5.1 und PowerShell 7+. Wird per Dot-Sourcing eingebunden: . "$PSScriptRoot\lib.ps1"
|
||||||
|
Set-StrictMode -Version 3
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
|
function Get-EnvOrDefault([string]$Name, [string]$Default) {
|
||||||
|
$value = [Environment]::GetEnvironmentVariable($Name)
|
||||||
|
if ($value) { return $value } else { return $Default }
|
||||||
|
}
|
||||||
|
|
||||||
|
$RootDir = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
||||||
|
$StateDir = Join-Path $RootDir '.renovate-local'
|
||||||
|
|
||||||
|
$RenovateVersion = Get-EnvOrDefault 'RENOVATE_VERSION' '44.149.3'
|
||||||
|
|
||||||
|
$ForgejoImage = Get-EnvOrDefault 'FORGEJO_IMAGE' 'codeberg.org/forgejo/forgejo:11'
|
||||||
|
$ForgejoContainer = Get-EnvOrDefault 'FORGEJO_CONTAINER' 'renovate-forgejo'
|
||||||
|
$ForgejoVolume = Get-EnvOrDefault 'FORGEJO_VOLUME' 'renovate-forgejo-data'
|
||||||
|
$ForgejoPort = Get-EnvOrDefault 'FORGEJO_PORT' '3000'
|
||||||
|
$ForgejoUrl = "http://localhost:$ForgejoPort"
|
||||||
|
$ForgejoUser = Get-EnvOrDefault 'FORGEJO_USER' 'renovate'
|
||||||
|
$ForgejoPassword = Get-EnvOrDefault 'FORGEJO_PASSWORD' 'renovate-local-123'
|
||||||
|
$ForgejoRepo = Get-EnvOrDefault 'FORGEJO_REPO' 'monorepo'
|
||||||
|
$GitRemote = Get-EnvOrDefault 'GIT_REMOTE' 'forgejo'
|
||||||
|
|
||||||
|
function Write-Step([string]$Message) {
|
||||||
|
Write-Host '==> ' -ForegroundColor Cyan -NoNewline
|
||||||
|
Write-Host $Message
|
||||||
|
}
|
||||||
|
|
||||||
|
# Führt ein externes Programm aus. Mit -Capture wird stdout als String zurückgegeben (stderr verworfen),
|
||||||
|
# sonst geht die Ausgabe direkt auf die Konsole. Bricht bei Exit-Code <> 0 ab, außer mit -AllowFail.
|
||||||
|
# Liefert ohne -Capture den Exit-Code zurück.
|
||||||
|
function Invoke-Native {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory)][string]$Command,
|
||||||
|
[string[]]$Arguments = @(),
|
||||||
|
[hashtable]$Environment = @{},
|
||||||
|
[switch]$Capture,
|
||||||
|
[switch]$AllowFail
|
||||||
|
)
|
||||||
|
$saved = @{}
|
||||||
|
foreach ($key in $Environment.Keys) {
|
||||||
|
$saved[$key] = [Environment]::GetEnvironmentVariable($key)
|
||||||
|
[Environment]::SetEnvironmentVariable($key, [string]$Environment[$key])
|
||||||
|
}
|
||||||
|
# stderr nativer Programme darf unter Windows PowerShell 5.1 kein Abbruch auslösen
|
||||||
|
$oldPreference = $ErrorActionPreference
|
||||||
|
$ErrorActionPreference = 'Continue'
|
||||||
|
Push-Location $RootDir
|
||||||
|
try {
|
||||||
|
if ($Capture) {
|
||||||
|
$output = & $Command @Arguments 2>$null
|
||||||
|
} else {
|
||||||
|
& $Command @Arguments | Out-Host
|
||||||
|
}
|
||||||
|
$exitCode = $LASTEXITCODE
|
||||||
|
} finally {
|
||||||
|
Pop-Location
|
||||||
|
$ErrorActionPreference = $oldPreference
|
||||||
|
foreach ($key in $saved.Keys) { [Environment]::SetEnvironmentVariable($key, $saved[$key]) }
|
||||||
|
}
|
||||||
|
if ($exitCode -ne 0 -and -not $AllowFail) {
|
||||||
|
throw "'$Command $($Arguments -join ' ')' endete mit Exit-Code $exitCode"
|
||||||
|
}
|
||||||
|
if ($Capture) { return (@($output) -join "`n") } else { return $exitCode }
|
||||||
|
}
|
||||||
|
|
||||||
|
function Invoke-Renovate([string[]]$Arguments, [hashtable]$Environment = @{}) {
|
||||||
|
Invoke-Native -Command 'npx' -Arguments (@('--yes', "renovate@$RenovateVersion") + $Arguments) -Environment $Environment | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Podman bevorzugen, sonst Docker (CONTAINER_ENGINE=docker erzwingt Docker)
|
||||||
|
function Get-ContainerEngine {
|
||||||
|
$candidates = @('podman', 'docker')
|
||||||
|
if ($env:CONTAINER_ENGINE) { $candidates = @($env:CONTAINER_ENGINE) }
|
||||||
|
foreach ($candidate in $candidates) {
|
||||||
|
if (Get-Command $candidate -ErrorAction SilentlyContinue) { return $candidate }
|
||||||
|
}
|
||||||
|
throw 'Weder podman noch docker gefunden – wird für Forgejo benötigt.'
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-ForgejoHealthy {
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri "$ForgejoUrl/api/healthz" -UseBasicParsing -TimeoutSec 2 | Out-Null
|
||||||
|
return $true
|
||||||
|
} catch {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-ForgejoToken([string]$Token) {
|
||||||
|
if (-not $Token) { return $false }
|
||||||
|
try {
|
||||||
|
Invoke-RestMethod -Uri "$ForgejoUrl/api/v1/user" -Headers @{ Authorization = "token $Token" } | Out-Null
|
||||||
|
return $true
|
||||||
|
} catch {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Startet ein lokales Forgejo (Git-Server) in Podman/Docker, legt Bot-User, Token und Repository an,
|
||||||
|
# pusht den lokalen Branch 'main' dorthin und gibt das Access-Token zurück.
|
||||||
|
function Start-Forgejo {
|
||||||
|
New-Item -ItemType Directory -Force -Path $StateDir | Out-Null
|
||||||
|
$engine = Get-ContainerEngine
|
||||||
|
|
||||||
|
Invoke-Native $engine @('container', 'inspect', $ForgejoContainer) -Capture -AllowFail | Out-Null
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Step "Starte Forgejo ($ForgejoImage) auf $ForgejoUrl via $engine"
|
||||||
|
Invoke-Native $engine @(
|
||||||
|
'run', '-d', '--name', $ForgejoContainer,
|
||||||
|
'-p', "${ForgejoPort}:3000",
|
||||||
|
'-v', "${ForgejoVolume}:/data",
|
||||||
|
'-e', 'USER_UID=1000', '-e', 'USER_GID=1000',
|
||||||
|
'-e', 'FORGEJO__security__INSTALL_LOCK=true',
|
||||||
|
'-e', "FORGEJO__server__ROOT_URL=$ForgejoUrl/",
|
||||||
|
'-e', 'FORGEJO__server__HTTP_PORT=3000',
|
||||||
|
'-e', 'FORGEJO__database__DB_TYPE=sqlite3',
|
||||||
|
'-e', 'FORGEJO__service__DISABLE_REGISTRATION=true',
|
||||||
|
'-e', 'FORGEJO__repository__DEFAULT_BRANCH=main',
|
||||||
|
$ForgejoImage
|
||||||
|
) -Capture | Out-Null
|
||||||
|
} else {
|
||||||
|
Invoke-Native $engine @('start', $ForgejoContainer) -Capture | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Step 'Warte auf Forgejo …'
|
||||||
|
for ($i = 0; $i -lt 60 -and -not (Test-ForgejoHealthy); $i++) { Start-Sleep -Seconds 1 }
|
||||||
|
if (-not (Test-ForgejoHealthy)) { throw "Forgejo unter $ForgejoUrl nicht erreichbar" }
|
||||||
|
|
||||||
|
$forgejoCli = { param([string[]]$CliArgs) Invoke-Native $engine (@('exec', '-u', 'git', $ForgejoContainer, 'forgejo') + $CliArgs) -Capture }
|
||||||
|
|
||||||
|
$users = (& $forgejoCli @('admin', 'user', 'list')) -split "`n" | ForEach-Object { ($_.Trim() -split '\s+')[1] }
|
||||||
|
if ($users -notcontains $ForgejoUser) {
|
||||||
|
Write-Step "Lege Admin-/Bot-User '$ForgejoUser' an"
|
||||||
|
& $forgejoCli @('admin', 'user', 'create', '--admin', '--username', $ForgejoUser,
|
||||||
|
'--password', $ForgejoPassword, '--email', 'renovate@localhost', '--must-change-password=false') | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Token wiederverwenden, solange Forgejo es kennt (nach Neuaufsetzen von Forgejo ist es ungültig)
|
||||||
|
$tokenFile = Join-Path $StateDir 'token'
|
||||||
|
$token = ''
|
||||||
|
if (Test-Path $tokenFile) { $token = ([IO.File]::ReadAllText($tokenFile)).Trim() }
|
||||||
|
if (-not (Test-ForgejoToken $token)) {
|
||||||
|
Write-Step 'Erzeuge Access-Token'
|
||||||
|
$token = (& $forgejoCli @('admin', 'user', 'generate-access-token', '--username', $ForgejoUser,
|
||||||
|
'--token-name', "renovate-$([DateTimeOffset]::Now.ToUnixTimeMilliseconds())", '--scopes', 'all', '--raw')).Trim()
|
||||||
|
[IO.File]::WriteAllText($tokenFile, $token)
|
||||||
|
}
|
||||||
|
$headers = @{ Authorization = "token $token" }
|
||||||
|
|
||||||
|
try {
|
||||||
|
Invoke-RestMethod -Uri "$ForgejoUrl/api/v1/repos/$ForgejoUser/$ForgejoRepo" -Headers $headers | Out-Null
|
||||||
|
} catch {
|
||||||
|
Write-Step "Lege Repository $ForgejoUser/$ForgejoRepo an"
|
||||||
|
$body = @{ name = $ForgejoRepo; default_branch = 'main'; private = $false } | ConvertTo-Json
|
||||||
|
Invoke-RestMethod -Method Post -Uri "$ForgejoUrl/api/v1/user/repos" -Headers $headers `
|
||||||
|
-ContentType 'application/json' -Body $body | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
$remoteUrl = "http://${ForgejoUser}:${token}@localhost:${ForgejoPort}/${ForgejoUser}/${ForgejoRepo}.git"
|
||||||
|
Invoke-Native 'git' @('remote', 'get-url', $GitRemote) -Capture -AllowFail | Out-Null
|
||||||
|
$remoteAction = if ($LASTEXITCODE -eq 0) { 'set-url' } else { 'add' }
|
||||||
|
Invoke-Native 'git' @('remote', $remoteAction, $GitRemote, $remoteUrl) | Out-Null
|
||||||
|
|
||||||
|
Write-Step "Pushe lokalen Branch 'main' nach Forgejo"
|
||||||
|
Invoke-Native 'git' @('push', '-q', $GitRemote, 'main:main') | Out-Null
|
||||||
|
|
||||||
|
Write-Step "Forgejo läuft: $ForgejoUrl (Login: $ForgejoUser / $ForgejoPassword)"
|
||||||
|
return $token
|
||||||
|
}
|
||||||
|
|
||||||
|
# Führt einen Skriptblock aus und beendet bei Fehler mit lesbarer Meldung und Exit-Code 1.
|
||||||
|
function Invoke-Main([scriptblock]$Body) {
|
||||||
|
try {
|
||||||
|
& $Body
|
||||||
|
} catch {
|
||||||
|
Write-Host 'Fehler: ' -ForegroundColor Red -NoNewline
|
||||||
|
Write-Host $_.Exception.Message
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
// Nur prüfen: Renovate läuft mit --platform=local direkt auf diesem Verzeichnis.
|
|
||||||
// Es werden keine Dateien geändert; das Ergebnis (gefundene Updates) landet im Log
|
|
||||||
// und als JSON-Report in .renovate-local/report.json.
|
|
||||||
import fs from "node:fs";
|
|
||||||
import path from "node:path";
|
|
||||||
import { ROOT_DIR, STATE_DIR, RENOVATE_VERSION, log, renovateCli, main } from "./lib.mjs";
|
|
||||||
|
|
||||||
main(async () => {
|
|
||||||
fs.mkdirSync(STATE_DIR, { recursive: true });
|
|
||||||
const reportPath = path.join(STATE_DIR, "report.json");
|
|
||||||
|
|
||||||
log(`Renovate ${RENOVATE_VERSION} – Dry-Run (lookup) auf ${ROOT_DIR}`);
|
|
||||||
renovateCli(
|
|
||||||
["--platform=local", "--dry-run=lookup", "--report-type=file", `--report-path=${reportPath}`],
|
|
||||||
{ LOG_LEVEL: process.env.LOG_LEVEL ?? "info" },
|
|
||||||
);
|
|
||||||
|
|
||||||
log("Gefundene Updates:");
|
|
||||||
const report = JSON.parse(fs.readFileSync(reportPath, "utf8"));
|
|
||||||
for (const repo of Object.values(report.repositories)) {
|
|
||||||
for (const [manager, files] of Object.entries(repo.packageFiles)) {
|
|
||||||
for (const f of files)
|
|
||||||
for (const d of f.deps)
|
|
||||||
for (const u of d.updates ?? [])
|
|
||||||
console.log(` [${manager}] ${f.packageFile}: ${d.depName} ${d.currentValue} -> ${u.newValue} (${u.updateType})`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Nur prüfen: Renovate läuft mit --platform=local direkt auf diesem Verzeichnis.
|
||||||
|
# Es werden keine Dateien geändert; das Ergebnis (gefundene Updates) landet im Log
|
||||||
|
# und als JSON-Report in .renovate-local\report.json.
|
||||||
|
. "$PSScriptRoot\lib.ps1"
|
||||||
|
|
||||||
|
Invoke-Main {
|
||||||
|
New-Item -ItemType Directory -Force -Path $StateDir | Out-Null
|
||||||
|
$reportPath = Join-Path $StateDir 'report.json'
|
||||||
|
$logLevel = Get-EnvOrDefault 'LOG_LEVEL' 'info'
|
||||||
|
|
||||||
|
Write-Step "Renovate $RenovateVersion – Dry-Run (lookup) auf $RootDir"
|
||||||
|
Invoke-Renovate @('--platform=local', '--dry-run=lookup', '--report-type=file', "--report-path=$reportPath") @{ LOG_LEVEL = $logLevel }
|
||||||
|
|
||||||
|
Write-Step 'Gefundene Updates:'
|
||||||
|
$report = [IO.File]::ReadAllText($reportPath) | ConvertFrom-Json
|
||||||
|
foreach ($repo in $report.repositories.PSObject.Properties.Value) {
|
||||||
|
foreach ($manager in $repo.packageFiles.PSObject.Properties) {
|
||||||
|
foreach ($file in $manager.Value) {
|
||||||
|
foreach ($dep in $file.deps) {
|
||||||
|
if (-not ($dep.PSObject.Properties.Name -contains 'updates')) { continue }
|
||||||
|
foreach ($update in $dep.updates) {
|
||||||
|
Write-Host " [$($manager.Name)] $($file.packageFile): $($dep.depName) $($dep.currentValue) -> $($update.newValue) ($($update.updateType))"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
// Vollständiger Renovate-Lauf, komplett lokal:
|
|
||||||
// Jeder Lauf erzeugt einen NEUEN Branch + PR mit Zeitstempel (renovate/yyyy-MM-dd-HH-mm-ss-SSS-all).
|
|
||||||
//
|
|
||||||
// 1. lokales Forgejo starten + aktuellen Stand pushen (forgejo-up.mjs)
|
|
||||||
// 2. Renovate-CLI gegen das lokale Forgejo laufen lassen (Branches + PRs + Dependency Dashboard)
|
|
||||||
// 3. die Renovate-Branches zurück ins lokale Repo holen (forgejo/renovate/*)
|
|
||||||
import path from "node:path";
|
|
||||||
import { forgejoUp } from "./forgejo-up.mjs";
|
|
||||||
import {
|
|
||||||
ROOT_DIR, STATE_DIR, RENOVATE_VERSION, FORGEJO_URL, FORGEJO_USER, FORGEJO_REPO, GIT_REMOTE,
|
|
||||||
log, run, renovateCli, main,
|
|
||||||
} from "./lib.mjs";
|
|
||||||
|
|
||||||
/** Lokale Zeit als yyyy-MM-dd-HH-mm-ss-SSS */
|
|
||||||
function timestamp(d = new Date()) {
|
|
||||||
const p = (n, len = 2) => String(n).padStart(len, "0");
|
|
||||||
return [d.getFullYear(), p(d.getMonth() + 1), p(d.getDate()), p(d.getHours()), p(d.getMinutes()),
|
|
||||||
p(d.getSeconds()), p(d.getMilliseconds(), 3)].join("-");
|
|
||||||
}
|
|
||||||
|
|
||||||
main(async () => {
|
|
||||||
const token = await forgejoUp();
|
|
||||||
const ts = timestamp();
|
|
||||||
// Eigenes Branch-Präfix pro Lauf: Renovate verwaltet nur Branches mit dem aktuellen Präfix,
|
|
||||||
// ältere Läufe (Branches + PRs) bleiben dadurch unangetastet bestehen.
|
|
||||||
const branchPrefix = `renovate/${ts}-`;
|
|
||||||
|
|
||||||
const extraEnv = {
|
|
||||||
RENOVATE_CONFIG_FILE: path.join(ROOT_DIR, "renovate", "config.js"),
|
|
||||||
RENOVATE_ENDPOINT: `${FORGEJO_URL}/api/v1`,
|
|
||||||
RENOVATE_TOKEN: token,
|
|
||||||
RENOVATE_BASE_DIR: path.join(STATE_DIR, "renovate-cache"),
|
|
||||||
RENOVATE_BRANCH_PREFIX: branchPrefix,
|
|
||||||
// Sonst sucht Renovate unter dem Standard-Präfix "renovate/" nach alten Branches und übernimmt deren PR
|
|
||||||
RENOVATE_BRANCH_PREFIX_OLD: branchPrefix,
|
|
||||||
RENOVATE_COMMIT_MESSAGE_SUFFIX: `(${ts})`, // landet auch im PR-Titel
|
|
||||||
LOG_LEVEL: process.env.LOG_LEVEL ?? "info",
|
|
||||||
};
|
|
||||||
// Optional: GitHub-Token (nur lesend) für Release Notes/Changelogs in den PRs
|
|
||||||
if (process.env.GITHUB_TOKEN && !process.env.RENOVATE_GITHUB_COM_TOKEN) {
|
|
||||||
extraEnv.RENOVATE_GITHUB_COM_TOKEN = process.env.GITHUB_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
log(`Starte Renovate ${RENOVATE_VERSION} gegen ${FORGEJO_URL} (${FORGEJO_USER}/${FORGEJO_REPO})`);
|
|
||||||
renovateCli([`${FORGEJO_USER}/${FORGEJO_REPO}`, ...process.argv.slice(2)], extraEnv);
|
|
||||||
|
|
||||||
log("Hole Renovate-Branches ins lokale Repo");
|
|
||||||
run("git", ["fetch", "-q", "--prune", GIT_REMOTE, `+refs/heads/*:refs/remotes/${GIT_REMOTE}/*`]);
|
|
||||||
const branches = run("git", ["branch", "-r", "--list", `${GIT_REMOTE}/${branchPrefix}*`], { capture: true }).stdout;
|
|
||||||
if (branches.trim()) {
|
|
||||||
log("Neu in diesem Lauf:");
|
|
||||||
process.stdout.write(branches.replace(/^(?=.)/gm, " "));
|
|
||||||
} else {
|
|
||||||
log("Keine Updates gefunden – kein neuer Branch/PR erstellt");
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`
|
|
||||||
Fertig. Nächste Schritte:
|
|
||||||
- PRs ansehen: ${FORGEJO_URL}/${FORGEJO_USER}/${FORGEJO_REPO}/pulls
|
|
||||||
- Änderungen ansehen: git diff main...${GIT_REMOTE}/renovate/<branch>
|
|
||||||
- lokal übernehmen: git merge ${GIT_REMOTE}/renovate/<branch>
|
|
||||||
- oder PR in Forgejo mergen und dann: git pull ${GIT_REMOTE} main`);
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Vollständiger Renovate-Lauf, komplett lokal.
|
||||||
|
# Jeder Lauf erzeugt einen NEUEN Branch + PR mit Zeitstempel (renovate/yyyy-MM-dd-HH-mm-ss-fff-all).
|
||||||
|
#
|
||||||
|
# 1. lokales Forgejo starten + aktuellen Stand pushen (Start-Forgejo in lib.ps1)
|
||||||
|
# 2. Renovate-CLI gegen das lokale Forgejo laufen lassen (Branch + PR + Dependency Dashboard)
|
||||||
|
# 3. die Renovate-Branches zurück ins lokale Repo holen (forgejo/renovate/*)
|
||||||
|
# Zusätzliche Argumente werden an Renovate durchgereicht, z. B. .\scripts\renovate-update.ps1 --dry-run=full
|
||||||
|
. "$PSScriptRoot\lib.ps1"
|
||||||
|
$renovateArgs = $args
|
||||||
|
|
||||||
|
Invoke-Main {
|
||||||
|
$token = Start-Forgejo
|
||||||
|
$ts = Get-Date -Format 'yyyy-MM-dd-HH-mm-ss-fff'
|
||||||
|
# Eigenes Branch-Präfix pro Lauf: Renovate verwaltet nur Branches mit dem aktuellen Präfix,
|
||||||
|
# ältere Läufe (Branches + PRs) bleiben dadurch unangetastet bestehen.
|
||||||
|
$branchPrefix = "renovate/$ts-"
|
||||||
|
|
||||||
|
$environment = @{
|
||||||
|
RENOVATE_CONFIG_FILE = Join-Path (Join-Path $RootDir 'renovate') 'config.js'
|
||||||
|
RENOVATE_ENDPOINT = "$ForgejoUrl/api/v1"
|
||||||
|
RENOVATE_TOKEN = $token
|
||||||
|
RENOVATE_BASE_DIR = Join-Path $StateDir 'renovate-cache'
|
||||||
|
RENOVATE_BRANCH_PREFIX = $branchPrefix
|
||||||
|
# Sonst sucht Renovate unter dem Standard-Präfix "renovate/" nach alten Branches und übernimmt deren PR
|
||||||
|
RENOVATE_BRANCH_PREFIX_OLD = $branchPrefix
|
||||||
|
RENOVATE_COMMIT_MESSAGE_SUFFIX = "($ts)" # landet auch im PR-Titel
|
||||||
|
LOG_LEVEL = Get-EnvOrDefault 'LOG_LEVEL' 'info'
|
||||||
|
}
|
||||||
|
# Optional: GitHub-Token (nur lesend) für Release Notes/Changelogs in den PRs
|
||||||
|
if ($env:GITHUB_TOKEN -and -not $env:RENOVATE_GITHUB_COM_TOKEN) {
|
||||||
|
$environment.RENOVATE_GITHUB_COM_TOKEN = $env:GITHUB_TOKEN
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Step "Starte Renovate $RenovateVersion gegen $ForgejoUrl ($ForgejoUser/$ForgejoRepo)"
|
||||||
|
Invoke-Renovate (@("$ForgejoUser/$ForgejoRepo") + $renovateArgs) $environment
|
||||||
|
|
||||||
|
Write-Step 'Hole Renovate-Branches ins lokale Repo'
|
||||||
|
Invoke-Native 'git' @('fetch', '-q', '--prune', $GitRemote, "+refs/heads/*:refs/remotes/$GitRemote/*") | Out-Null
|
||||||
|
$branches = Invoke-Native 'git' @('branch', '-r', '--list', "$GitRemote/$branchPrefix*") -Capture
|
||||||
|
if ($branches.Trim()) {
|
||||||
|
Write-Step 'Neu in diesem Lauf:'
|
||||||
|
$branches -split "`n" | ForEach-Object { Write-Host " $_" }
|
||||||
|
} else {
|
||||||
|
Write-Step 'Keine Updates gefunden – kein neuer Branch/PR erstellt'
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host @"
|
||||||
|
|
||||||
|
Fertig. Nächste Schritte:
|
||||||
|
- PRs ansehen: $ForgejoUrl/$ForgejoUser/$ForgejoRepo/pulls
|
||||||
|
- Änderungen ansehen: git diff main...$GitRemote/renovate/<zeitstempel>-all
|
||||||
|
- lokal übernehmen: git merge $GitRemote/renovate/<zeitstempel>-all
|
||||||
|
- oder PR in Forgejo mergen und dann: git pull $GitRemote main
|
||||||
|
"@
|
||||||
|
}
|
||||||
Reference in new issue
Block a user