Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b97d9f2d7f |
@ -1,9 +1,6 @@
|
|||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$Token,
|
[string]$Token
|
||||||
|
|
||||||
[Parameter(Mandatory=$false)]
|
|
||||||
[switch]$Build
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Token aus Umgebungsvariable laden falls nicht als Parameter übergeben
|
# Token aus Umgebungsvariable laden falls nicht als Parameter übergeben
|
||||||
@ -12,6 +9,7 @@ if (-not $Token) {
|
|||||||
if (-not $Token) {
|
if (-not $Token) {
|
||||||
Write-Host "Fehler: Kein Token angegeben und GITEA_TOKEN Umgebungsvariable nicht gesetzt!" -ForegroundColor Red
|
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
|
Write-Host "Verwendung: .\create_release.ps1 -Token 'your_token' oder setze GITEA_TOKEN Umgebungsvariable" -ForegroundColor Yellow
|
||||||
|
Write-Host "Das Script führt automatisch einen Build durch und lädt alle Artefakte hoch." -ForegroundColor Cyan
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
Write-Host "Token aus Umgebungsvariable GITEA_TOKEN geladen" -ForegroundColor Green
|
Write-Host "Token aus Umgebungsvariable GITEA_TOKEN geladen" -ForegroundColor Green
|
||||||
@ -43,8 +41,7 @@ if ($lastTag -match "^v(\d+)\.(\d+)\.(\d+)(.*)$") {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build falls gewünscht
|
# Build durchführen
|
||||||
if ($Build) {
|
|
||||||
Write-Host "Führe Build durch..." -ForegroundColor Yellow
|
Write-Host "Führe Build durch..." -ForegroundColor Yellow
|
||||||
if (Test-Path "scripts\build_thinkpad.bat") {
|
if (Test-Path "scripts\build_thinkpad.bat") {
|
||||||
Write-Host "Verwende scripts\build_thinkpad.bat..." -ForegroundColor Yellow
|
Write-Host "Verwende scripts\build_thinkpad.bat..." -ForegroundColor Yellow
|
||||||
@ -57,7 +54,7 @@ if ($Build) {
|
|||||||
Write-Host "Build fehlgeschlagen!" -ForegroundColor Red
|
Write-Host "Build fehlgeschlagen!" -ForegroundColor Red
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
Write-Host "Build erfolgreich abgeschlossen!" -ForegroundColor Green
|
||||||
|
|
||||||
# Änderungen committen
|
# Änderungen committen
|
||||||
$status = git status --porcelain
|
$status = git status --porcelain
|
||||||
@ -72,7 +69,7 @@ git tag -a $newVersion -m "Release $newVersion"
|
|||||||
git push origin $newVersion
|
git push origin $newVersion
|
||||||
|
|
||||||
# Release erstellen
|
# 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"
|
$releaseBody = "## What is New in $newVersion`n`n- AUTOMATED: Release created by script`n- VERSION: Bumped from $lastTag to $newVersion`n- BUILD: Automatic build with build_thinkpad.bat`n`n## Build Artifacts`n`nBuild-Artefakte werden automatisch hochgeladen und hier angezeigt.`n`nTypische Artefakte:`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 = @{
|
$releaseData = @{
|
||||||
tag_name = $newVersion
|
tag_name = $newVersion
|
||||||
@ -93,3 +90,59 @@ $release = Invoke-RestMethod -Uri $releaseUri -Method Post -Headers $headers -Bo
|
|||||||
Write-Host "Release erstellt: $($release.id)" -ForegroundColor Green
|
Write-Host "Release erstellt: $($release.id)" -ForegroundColor Green
|
||||||
Write-Host "URL: $($release.html_url)" -ForegroundColor Green
|
Write-Host "URL: $($release.html_url)" -ForegroundColor Green
|
||||||
|
|
||||||
|
# Build-Artefakte zum Release hinzufügen
|
||||||
|
Write-Host "Füge Build-Artefakte hinzu..." -ForegroundColor Yellow
|
||||||
|
|
||||||
|
# Artefakte aus dem dist-Ordner finden
|
||||||
|
$distPath = "dist"
|
||||||
|
if (Test-Path $distPath) {
|
||||||
|
$artifacts = Get-ChildItem -Path $distPath -Recurse -File | Where-Object {
|
||||||
|
$_.Extension -match "\.(dll|lib|exe|h|zip)$"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($artifacts) {
|
||||||
|
Write-Host "Gefundene Artefakte:" -ForegroundColor Green
|
||||||
|
foreach ($artifact in $artifacts) {
|
||||||
|
Write-Host " - $($artifact.Name)" -ForegroundColor White
|
||||||
|
}
|
||||||
|
|
||||||
|
# Artefakte hochladen
|
||||||
|
foreach ($artifact in $artifacts) {
|
||||||
|
Write-Host "Lade hoch: $($artifact.Name)..." -ForegroundColor Yellow
|
||||||
|
|
||||||
|
$uploadUri = "https://gitea.medisoftware.org/api/v1/repos/Markus/lib-privatebin/releases/$($release.id)/assets"
|
||||||
|
|
||||||
|
$boundary = [System.Guid]::NewGuid().ToString()
|
||||||
|
$LF = "`r`n"
|
||||||
|
$bodyLines = @(
|
||||||
|
"--$boundary",
|
||||||
|
"Content-Disposition: form-data; name=`"attachment`"; filename=`"$($artifact.Name)`"",
|
||||||
|
"Content-Type: application/octet-stream",
|
||||||
|
"",
|
||||||
|
[System.IO.File]::ReadAllBytes($artifact.FullName),
|
||||||
|
"--$boundary--"
|
||||||
|
)
|
||||||
|
|
||||||
|
$body = $bodyLines -join $LF
|
||||||
|
|
||||||
|
$uploadHeaders = @{
|
||||||
|
"Authorization" = "token $Token"
|
||||||
|
"Content-Type" = "multipart/form-data; boundary=$boundary"
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$uploadResponse = Invoke-RestMethod -Uri $uploadUri -Method Post -Headers $uploadHeaders -Body $body
|
||||||
|
Write-Host " ✓ $($artifact.Name) erfolgreich hochgeladen" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host " ✗ Fehler beim Hochladen von $($artifact.Name): $($_.Exception.Message)" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "Keine Build-Artefakte im dist-Ordner gefunden!" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "dist-Ordner nicht gefunden!" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Release-Erstellung abgeschlossen!" -ForegroundColor Green
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user