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"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
|
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
|
||||||
xmlns:ui="http://schemas.microsoft.com/wix/2010/ui">
|
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"
|
Manufacturer="HIM-Tools"
|
||||||
UpgradeCode="12345678-1234-1234-1234-123456789012">
|
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]$ClearCredentials,
|
||||||
|
|
||||||
|
[switch]$SkipExe,
|
||||||
|
|
||||||
[string]$ForgejoUrl = "https://git.him-tools.de",
|
[string]$ForgejoUrl = "https://git.him-tools.de",
|
||||||
[string]$Repo = "HIM-public/webdrop-bridge",
|
[string]$Repo = "HIM-public/webdrop-bridge",
|
||||||
[string]$ExePath = "build\dist\windows\WebDropBridge.exe",
|
[string]$ExePath = "build\dist\windows\WebDropBridge\WebDropBridge.exe",
|
||||||
[string]$ChecksumPath = "build\dist\windows\WebDropBridge.exe.sha256",
|
[string]$ChecksumPath = "build\dist\windows\WebDropBridge\WebDropBridge.exe.sha256"
|
||||||
[string]$MsiPath = "build\dist\windows\WebDropBridge-1.0.0-Setup.msi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
@ -107,32 +108,44 @@ if (-not $Version) {
|
||||||
Write-Host "Using version: $Version" -ForegroundColor Green
|
Write-Host "Using version: $Version" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
# Verify files exist
|
# Define MSI path with resolved version
|
||||||
if (-not (Test-Path $ExePath)) {
|
$MsiPath = Join-Path $projectRoot "build\dist\windows\WebDropBridge-$Version-Setup.msi"
|
||||||
Write-Host "ERROR: Executable not found at $ExePath" -ForegroundColor Red
|
|
||||||
exit 1
|
# Verify files exist (exe/checksum optional, MSI required)
|
||||||
|
if (-not $SkipExe) {
|
||||||
|
if (-not (Test-Path $ExePath)) {
|
||||||
|
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 $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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not (Test-Path $ChecksumPath)) {
|
# MSI is the primary release artifact
|
||||||
Write-Host "ERROR: Checksum file not found at $ChecksumPath" -ForegroundColor Red
|
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
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# MSI is optional (only available on Windows after build)
|
|
||||||
$hasMsi = Test-Path $MsiPath
|
|
||||||
|
|
||||||
Write-Host "Creating WebDropBridge $Version release on Forgejo..." -ForegroundColor Cyan
|
Write-Host "Creating WebDropBridge $Version release on Forgejo..." -ForegroundColor Cyan
|
||||||
|
|
||||||
# Get file info
|
# Get file info
|
||||||
$exeSize = (Get-Item $ExePath).Length / 1MB
|
$msiSize = (Get-Item $MsiPath).Length / 1MB
|
||||||
$checksum = Get-Content $ChecksumPath -Raw
|
Write-Host "Primary Artifact: WebDropBridge-$Version-Setup.msi ($([math]::Round($msiSize, 2)) MB)"
|
||||||
|
|
||||||
Write-Host "File: WebDropBridge.exe ($([math]::Round($exeSize, 2)) MB)"
|
if (-not $SkipExe) {
|
||||||
if ($hasMsi) {
|
$exeSize = (Get-Item $ExePath).Length / 1MB
|
||||||
$msiSize = (Get-Item $MsiPath).Length / 1MB
|
$checksum = Get-Content $ChecksumPath -Raw
|
||||||
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))..."
|
||||||
}
|
}
|
||||||
Write-Host "Checksum: $($checksum.Substring(0, 16))..."
|
|
||||||
|
|
||||||
# Create basic auth header
|
# Create basic auth header
|
||||||
$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${ForgejoUser}:${ForgejoPW}"))
|
$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${ForgejoUser}:${ForgejoPW}"))
|
||||||
|
|
@ -146,10 +159,17 @@ $headers = @{
|
||||||
Write-Host "`nCreating release v$Version..." -ForegroundColor Yellow
|
Write-Host "`nCreating release v$Version..." -ForegroundColor Yellow
|
||||||
$releaseUrl = "$ForgejoUrl/api/v1/repos/$Repo/releases"
|
$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 = @{
|
$releaseData = @{
|
||||||
tag_name = "v$Version"
|
tag_name = "v$Version"
|
||||||
name = "WebDropBridge v$Version"
|
name = "WebDropBridge v$Version"
|
||||||
body = "WebDropBridge v$Version`n`nChecksum: $checksum"
|
body = $releaseBody
|
||||||
draft = $false
|
draft = $false
|
||||||
prerelease = $false
|
prerelease = $false
|
||||||
} | ConvertTo-Json
|
} | ConvertTo-Json
|
||||||
|
|
@ -172,71 +192,70 @@ catch {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 2: Upload executable as asset using curl
|
# Setup curl authentication
|
||||||
Write-Host "Uploading executable asset..." -ForegroundColor Yellow
|
$curlAuth = "$ForgejoUser`:$ForgejoPW"
|
||||||
|
$uploadUrl = "$ForgejoUrl/api/v1/repos/$Repo/releases/$releaseId/assets"
|
||||||
|
|
||||||
try {
|
# Step 2: Upload MSI installer as primary artifact
|
||||||
$curlAuth = "$ForgejoUser`:$ForgejoPW"
|
Write-Host "`nUploading MSI installer (primary artifact)..." -ForegroundColor Yellow
|
||||||
$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 {
|
try {
|
||||||
$response = curl.exe -s -X POST `
|
$response = curl.exe -s -X POST `
|
||||||
-u $curlAuth `
|
-u $curlAuth `
|
||||||
-F "attachment=@$ChecksumPath" `
|
-F "attachment=@$MsiPath" `
|
||||||
$uploadUrl
|
$uploadUrl
|
||||||
|
|
||||||
if ($response -like "*error*" -or $response -like "*404*") {
|
if ($response -like "*error*" -or $response -like "*404*") {
|
||||||
Write-Host "ERROR uploading checksum: $response" -ForegroundColor Red
|
Write-Host "ERROR uploading MSI: $response" -ForegroundColor Red
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "[OK] Checksum uploaded" -ForegroundColor Green
|
Write-Host "[OK] MSI installer uploaded" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host "ERROR uploading checksum: $_" -ForegroundColor Red
|
Write-Host "ERROR uploading MSI: $_" -ForegroundColor Red
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 4: Upload MSI as asset (if available)
|
# Step 3: Upload executable as optional artifact (if available)
|
||||||
if ($hasMsi) {
|
if (-not $SkipExe) {
|
||||||
Write-Host "Uploading MSI installer asset..." -ForegroundColor Yellow
|
Write-Host "`nUploading executable (optional portable version)..." -ForegroundColor Yellow
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = curl.exe -s -X POST `
|
$response = curl.exe -s -X POST `
|
||||||
-u $curlAuth `
|
-u $curlAuth `
|
||||||
-F "attachment=@$MsiPath" `
|
-F "attachment=@$ExePath" `
|
||||||
$uploadUrl
|
$uploadUrl
|
||||||
|
|
||||||
if ($response -like "*error*" -or $response -like "*404*") {
|
if ($response -like "*error*" -or $response -like "*404*") {
|
||||||
Write-Host "ERROR uploading MSI: $response" -ForegroundColor Red
|
Write-Host "WARNING: Could not upload executable: $response" -ForegroundColor Yellow
|
||||||
exit 1
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "[OK] Executable uploaded" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "[OK] MSI uploaded" -ForegroundColor Green
|
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host "ERROR uploading MSI: $_" -ForegroundColor Red
|
Write-Host "WARNING: Could not upload executable: $_" -ForegroundColor Yellow
|
||||||
exit 1
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue