Enhance release script to support optional executable uploads and improve error handling
- Added -SkipExe switch to allow skipping the upload of the executable and its checksum. - Updated paths for the executable and checksum files to reflect new directory structure. - Improved file existence checks with warnings instead of errors for optional artifacts. - Enhanced release body to include checksum information conditionally based on executable upload. - Refined upload process for MSI and executable, including better error handling and logging.
This commit is contained in:
parent
14dac17024
commit
9d39ed8201
5 changed files with 2954 additions and 2935 deletions
File diff suppressed because one or more lines are too long
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
|
||||
xmlns:ui="http://schemas.microsoft.com/wix/2010/ui">
|
||||
<Product Id="*" Name="WebDrop Bridge" Language="1033" Version="0.5.0"
|
||||
<Product Id="*" Name="WebDrop Bridge" Language="1033" Version="0.6.0"
|
||||
Manufacturer="HIM-Tools"
|
||||
UpgradeCode="12345678-1234-1234-1234-123456789012">
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
|
@ -16,11 +16,12 @@ param(
|
|||
|
||||
[switch]$ClearCredentials,
|
||||
|
||||
[switch]$SkipExe,
|
||||
|
||||
[string]$ForgejoUrl = "https://git.him-tools.de",
|
||||
[string]$Repo = "HIM-public/webdrop-bridge",
|
||||
[string]$ExePath = "build\dist\windows\WebDropBridge.exe",
|
||||
[string]$ChecksumPath = "build\dist\windows\WebDropBridge.exe.sha256",
|
||||
[string]$MsiPath = "build\dist\windows\WebDropBridge-1.0.0-Setup.msi"
|
||||
[string]$ExePath = "build\dist\windows\WebDropBridge\WebDropBridge.exe",
|
||||
[string]$ChecksumPath = "build\dist\windows\WebDropBridge\WebDropBridge.exe.sha256"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
|
@ -107,32 +108,44 @@ if (-not $Version) {
|
|||
Write-Host "Using version: $Version" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Verify files exist
|
||||
# Define MSI path with resolved version
|
||||
$MsiPath = Join-Path $projectRoot "build\dist\windows\WebDropBridge-$Version-Setup.msi"
|
||||
|
||||
# Verify files exist (exe/checksum optional, MSI required)
|
||||
if (-not $SkipExe) {
|
||||
if (-not (Test-Path $ExePath)) {
|
||||
Write-Host "ERROR: Executable not found at $ExePath" -ForegroundColor Red
|
||||
exit 1
|
||||
Write-Host "WARNING: Executable not found at $ExePath" -ForegroundColor Yellow
|
||||
Write-Host " Use -SkipExe flag to skip exe upload" -ForegroundColor Gray
|
||||
$SkipExe = $true
|
||||
}
|
||||
|
||||
if (-not (Test-Path $ChecksumPath)) {
|
||||
Write-Host "ERROR: Checksum file not found at $ChecksumPath" -ForegroundColor Red
|
||||
exit 1
|
||||
if (-not $SkipExe -and -not (Test-Path $ChecksumPath)) {
|
||||
Write-Host "WARNING: Checksum file not found at $ChecksumPath" -ForegroundColor Yellow
|
||||
Write-Host " Exe will not be uploaded" -ForegroundColor Gray
|
||||
$SkipExe = $true
|
||||
}
|
||||
}
|
||||
|
||||
# MSI is optional (only available on Windows after build)
|
||||
$hasMsi = Test-Path $MsiPath
|
||||
# MSI is the primary release artifact
|
||||
if (-not (Test-Path $MsiPath)) {
|
||||
Write-Host "ERROR: MSI installer not found at $MsiPath" -ForegroundColor Red
|
||||
Write-Host "Please build with MSI support:" -ForegroundColor Yellow
|
||||
Write-Host " python build\scripts\build_windows.py --msi" -ForegroundColor Cyan
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Creating WebDropBridge $Version release on Forgejo..." -ForegroundColor Cyan
|
||||
|
||||
# Get file info
|
||||
$msiSize = (Get-Item $MsiPath).Length / 1MB
|
||||
Write-Host "Primary Artifact: WebDropBridge-$Version-Setup.msi ($([math]::Round($msiSize, 2)) MB)"
|
||||
|
||||
if (-not $SkipExe) {
|
||||
$exeSize = (Get-Item $ExePath).Length / 1MB
|
||||
$checksum = Get-Content $ChecksumPath -Raw
|
||||
|
||||
Write-Host "File: WebDropBridge.exe ($([math]::Round($exeSize, 2)) MB)"
|
||||
if ($hasMsi) {
|
||||
$msiSize = (Get-Item $MsiPath).Length / 1MB
|
||||
Write-Host "File: WebDropBridge-1.0.0-Setup.msi ($([math]::Round($msiSize, 2)) MB)"
|
||||
}
|
||||
Write-Host "Optional Artifact: WebDropBridge.exe ($([math]::Round($exeSize, 2)) MB)"
|
||||
Write-Host " Checksum: $($checksum.Substring(0, 16))..."
|
||||
}
|
||||
|
||||
# Create basic auth header
|
||||
$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${ForgejoUser}:${ForgejoPW}"))
|
||||
|
|
@ -146,10 +159,17 @@ $headers = @{
|
|||
Write-Host "`nCreating release v$Version..." -ForegroundColor Yellow
|
||||
$releaseUrl = "$ForgejoUrl/api/v1/repos/$Repo/releases"
|
||||
|
||||
# Build release body with checksum info if exe is being uploaded
|
||||
$releaseBody = "WebDropBridge v$Version`n`n**Release Artifacts:**`n- MSI Installer (Windows Setup)`n"
|
||||
if (-not $SkipExe) {
|
||||
$checksum = Get-Content $ChecksumPath -Raw
|
||||
$releaseBody += "- Portable Executable`n`n**Checksum:**`n$checksum`n"
|
||||
}
|
||||
|
||||
$releaseData = @{
|
||||
tag_name = "v$Version"
|
||||
name = "WebDropBridge v$Version"
|
||||
body = "WebDropBridge v$Version`n`nChecksum: $checksum"
|
||||
body = $releaseBody
|
||||
draft = $false
|
||||
prerelease = $false
|
||||
} | ConvertTo-Json
|
||||
|
|
@ -172,54 +192,12 @@ catch {
|
|||
exit 1
|
||||
}
|
||||
|
||||
# Step 2: Upload executable as asset using curl
|
||||
Write-Host "Uploading executable asset..." -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
# Setup curl authentication
|
||||
$curlAuth = "$ForgejoUser`:$ForgejoPW"
|
||||
$uploadUrl = "$ForgejoUrl/api/v1/repos/$Repo/releases/$releaseId/assets"
|
||||
|
||||
$response = curl.exe -s -X POST `
|
||||
-u $curlAuth `
|
||||
-F "attachment=@$ExePath" `
|
||||
$uploadUrl
|
||||
|
||||
if ($response -like "*error*" -or $response -like "*404*") {
|
||||
Write-Host "ERROR uploading executable: $response" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "[OK] Executable uploaded" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Host "ERROR uploading executable: $_" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 3: Upload checksum as asset using curl
|
||||
Write-Host "Uploading checksum asset..." -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
$response = curl.exe -s -X POST `
|
||||
-u $curlAuth `
|
||||
-F "attachment=@$ChecksumPath" `
|
||||
$uploadUrl
|
||||
|
||||
if ($response -like "*error*" -or $response -like "*404*") {
|
||||
Write-Host "ERROR uploading checksum: $response" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "[OK] Checksum uploaded" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Host "ERROR uploading checksum: $_" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 4: Upload MSI as asset (if available)
|
||||
if ($hasMsi) {
|
||||
Write-Host "Uploading MSI installer asset..." -ForegroundColor Yellow
|
||||
# Step 2: Upload MSI installer as primary artifact
|
||||
Write-Host "`nUploading MSI installer (primary artifact)..." -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
$response = curl.exe -s -X POST `
|
||||
|
|
@ -232,12 +210,53 @@ if ($hasMsi) {
|
|||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "[OK] MSI uploaded" -ForegroundColor Green
|
||||
Write-Host "[OK] MSI installer uploaded" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Host "ERROR uploading MSI: $_" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 3: Upload executable as optional artifact (if available)
|
||||
if (-not $SkipExe) {
|
||||
Write-Host "`nUploading executable (optional portable version)..." -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
$response = curl.exe -s -X POST `
|
||||
-u $curlAuth `
|
||||
-F "attachment=@$ExePath" `
|
||||
$uploadUrl
|
||||
|
||||
if ($response -like "*error*" -or $response -like "*404*") {
|
||||
Write-Host "WARNING: Could not upload executable: $response" -ForegroundColor Yellow
|
||||
}
|
||||
else {
|
||||
Write-Host "[OK] Executable uploaded" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "WARNING: Could not upload executable: $_" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Step 4: Upload checksum as asset
|
||||
Write-Host "Uploading checksum..." -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
$response = curl.exe -s -X POST `
|
||||
-u $curlAuth `
|
||||
-F "attachment=@$ChecksumPath" `
|
||||
$uploadUrl
|
||||
|
||||
if ($response -like "*error*" -or $response -like "*404*") {
|
||||
Write-Host "WARNING: Could not upload checksum: $response" -ForegroundColor Yellow
|
||||
}
|
||||
else {
|
||||
Write-Host "[OK] Checksum uploaded" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "WARNING: Could not upload checksum: $_" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "`n[OK] Release complete!" -ForegroundColor Green
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue