v0.1.1.4: Build scripts moved to scripts/ directory; enhanced documentation; automated release script
This commit is contained in:
95
scripts/create_release.ps1
Normal file
95
scripts/create_release.ps1
Normal file
@ -0,0 +1,95 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$Token,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[switch]$Build
|
||||
)
|
||||
|
||||
# Token aus Umgebungsvariable laden falls nicht als Parameter übergeben
|
||||
if (-not $Token) {
|
||||
$Token = $env:GITEA_TOKEN
|
||||
if (-not $Token) {
|
||||
Write-Host "Fehler: Kein Token angegeben und GITEA_TOKEN Umgebungsvariable nicht gesetzt!" -ForegroundColor Red
|
||||
Write-Host "Verwendung: .\create_release.ps1 -Token 'your_token' oder setze GITEA_TOKEN Umgebungsvariable" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
Write-Host "Token aus Umgebungsvariable GITEA_TOKEN geladen" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host "=== lib-privatebin Release Creator ===" -ForegroundColor Cyan
|
||||
|
||||
# Aktuelle Version ermitteln
|
||||
$lastTag = git describe --tags --abbrev=0 2>$null
|
||||
if (-not $lastTag) {
|
||||
$lastTag = "v0.1.0"
|
||||
}
|
||||
|
||||
Write-Host "Letzter Tag: $lastTag" -ForegroundColor Green
|
||||
|
||||
# Version parsen
|
||||
if ($lastTag -match "^v(\d+)\.(\d+)\.(\d+)(.*)$") {
|
||||
$major = [int]$matches[1]
|
||||
$minor = [int]$matches[2]
|
||||
$patch = [int]$matches[3]
|
||||
$suffix = $matches[4]
|
||||
|
||||
$newPatch = $patch + 1
|
||||
$newVersion = "v$major.$minor.$newPatch$suffix"
|
||||
|
||||
Write-Host "Neue Version: $newVersion" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Fehler: Ungültiges Versionsformat: $lastTag" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Build falls gewünscht
|
||||
if ($Build) {
|
||||
Write-Host "Führe Build durch..." -ForegroundColor Yellow
|
||||
if (Test-Path "scripts\build_thinkpad.bat") {
|
||||
Write-Host "Verwende scripts\build_thinkpad.bat..." -ForegroundColor Yellow
|
||||
cmd /c scripts\build_thinkpad.bat
|
||||
} else {
|
||||
Write-Host "Verwende scripts\build_windows.ps1..." -ForegroundColor Yellow
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_windows.ps1
|
||||
}
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Build fehlgeschlagen!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Änderungen committen
|
||||
$status = git status --porcelain
|
||||
if ($status) {
|
||||
git add -A
|
||||
git commit -m "Release $newVersion prepare for release"
|
||||
git push origin HEAD
|
||||
}
|
||||
|
||||
# Tag erstellen und pushen
|
||||
git tag -a $newVersion -m "Release $newVersion"
|
||||
git push origin $newVersion
|
||||
|
||||
# Release erstellen
|
||||
$releaseBody = "## What is New in $newVersion`n`n- AUTOMATED: Release created by script`n- VERSION: Bumped from $lastTag to $newVersion`n`n## Build Artifacts`n`n- privatebinapi.dll - Windows Dynamic Link Library`n- privatebinapi.lib - Windows Import Library`n- example.exe - Combined example program`n- privatebinapi.h - C++ header file"
|
||||
|
||||
$releaseData = @{
|
||||
tag_name = $newVersion
|
||||
name = "$newVersion - Automated Release"
|
||||
body = $releaseBody
|
||||
draft = $false
|
||||
prerelease = $false
|
||||
} | ConvertTo-Json -Depth 10
|
||||
|
||||
$headers = @{
|
||||
"Authorization" = "token $Token"
|
||||
"Content-Type" = "application/json"
|
||||
}
|
||||
|
||||
$releaseUri = "https://gitea.medisoftware.org/api/v1/repos/Markus/lib-privatebin/releases"
|
||||
$release = Invoke-RestMethod -Uri $releaseUri -Method Post -Headers $headers -Body $releaseData
|
||||
|
||||
Write-Host "Release erstellt: $($release.id)" -ForegroundColor Green
|
||||
Write-Host "URL: $($release.html_url)" -ForegroundColor Green
|
||||
|
||||
Reference in New Issue
Block a user