Some checks are pending
Tests & Quality Checks / Test on Python 3.11 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.10 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-2 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-2 (push) Waiting to run
Tests & Quality Checks / Build Artifacts (push) Blocked by required conditions
Tests & Quality Checks / Build Artifacts-1 (push) Blocked by required conditions
- Replace upload_to_packages scripts with create_release scripts - Use Forgejo Releases API instead (standard for binaries) - Windows: create_release.ps1 creates release and uploads exe + checksum - macOS: create_release.sh creates release and uploads dmg + checksum - Interactive credential prompts on first run - UpdateManager queries releases/latest for updates - Much simpler and matches standard open-source distribution - Rename FORGEJO_PACKAGES_SETUP.md to reflect Releases approach - Update documentation with Releases API examples
177 lines
5.2 KiB
PowerShell
177 lines
5.2 KiB
PowerShell
# Create Forgejo Release with Binary Assets
|
|
# Usage: .\create_release.ps1 -Version 1.0.0
|
|
# Uses your Forgejo credentials (same as git)
|
|
# First run will prompt for credentials and save them to this session
|
|
|
|
param(
|
|
[Parameter(Mandatory=$false)]
|
|
[string]$Version,
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
[string]$ForgejoUser,
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
[string]$ForgejoPW,
|
|
|
|
[switch]$ClearCredentials,
|
|
|
|
[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"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# Handle --ClearCredentials flag
|
|
if ($ClearCredentials) {
|
|
Remove-Item env:FORGEJO_USER -ErrorAction SilentlyContinue
|
|
Remove-Item env:FORGEJO_PASS -ErrorAction SilentlyContinue
|
|
Write-Host "[OK] Credentials cleared from this session" -ForegroundColor Green
|
|
exit 0
|
|
}
|
|
|
|
# Get credentials from sources (in order of priority)
|
|
if (-not $ForgejoUser) {
|
|
$ForgejoUser = $env:FORGEJO_USER
|
|
}
|
|
|
|
if (-not $ForgejoPW) {
|
|
$ForgejoPW = $env:FORGEJO_PASS
|
|
}
|
|
|
|
# If still no credentials, prompt user interactively
|
|
if (-not $ForgejoUser -or -not $ForgejoPW) {
|
|
Write-Host "Forgejo credentials not found. Enter your credentials:" -ForegroundColor Yellow
|
|
|
|
if (-not $ForgejoUser) {
|
|
$ForgejoUser = Read-Host "Username"
|
|
}
|
|
|
|
if (-not $ForgejoPW) {
|
|
$securePass = Read-Host "Password" -AsSecureString
|
|
$ForgejoPW = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($securePass))
|
|
}
|
|
|
|
# Save credentials to environment for this session
|
|
$env:FORGEJO_USER = $ForgejoUser
|
|
$env:FORGEJO_PASS = $ForgejoPW
|
|
Write-Host "[OK] Credentials saved to this PowerShell session" -ForegroundColor Green
|
|
Write-Host "Tip: Credentials will persist until you close PowerShell or run: .\create_release.ps1 -ClearCredentials" -ForegroundColor Gray
|
|
}
|
|
|
|
# Verify Version parameter
|
|
if (-not $Version) {
|
|
Write-Host "ERROR: Version parameter required" -ForegroundColor Red
|
|
Write-Host "Usage: .\create_release.ps1 -Version 1.0.0" -ForegroundColor Yellow
|
|
exit 1
|
|
}
|
|
|
|
# Verify files exist
|
|
if (-not (Test-Path $ExePath)) {
|
|
Write-Host "ERROR: Executable not found at $ExePath" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
if (-not (Test-Path $ChecksumPath)) {
|
|
Write-Host "ERROR: Checksum file not found at $ChecksumPath" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Creating WebDropBridge $Version release on Forgejo..." -ForegroundColor Cyan
|
|
|
|
# Get file info
|
|
$exeSize = (Get-Item $ExePath).Length / 1MB
|
|
$checksum = Get-Content $ChecksumPath -Raw
|
|
|
|
Write-Host "File: 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}"))
|
|
|
|
$headers = @{
|
|
"Authorization" = "Basic $auth"
|
|
"Content-Type" = "application/json"
|
|
}
|
|
|
|
# Step 1: Create release
|
|
Write-Host "`nCreating release v$Version..." -ForegroundColor Yellow
|
|
$releaseUrl = "$ForgejoUrl/api/v1/repos/$Repo/releases"
|
|
|
|
$releaseData = @{
|
|
tag_name = "v$Version"
|
|
name = "WebDropBridge v$Version"
|
|
body = "WebDropBridge v$Version`n`nChecksum: $checksum"
|
|
draft = $false
|
|
prerelease = $false
|
|
} | ConvertTo-Json
|
|
|
|
try {
|
|
$response = Invoke-WebRequest -Uri $releaseUrl `
|
|
-Method POST `
|
|
-Headers $headers `
|
|
-Body $releaseData `
|
|
-TimeoutSec 30 `
|
|
-ErrorAction Stop
|
|
|
|
$releaseInfo = $response.Content | ConvertFrom-Json
|
|
$releaseId = $releaseInfo.id
|
|
Write-Host "[OK] Release created (ID: $releaseId)" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host "ERROR creating release: $_" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# Step 2: Upload executable as asset
|
|
Write-Host "Uploading executable asset..." -ForegroundColor Yellow
|
|
$uploadUrl = "$ForgejoUrl/api/v1/repos/$Repo/releases/$releaseId/assets"
|
|
|
|
try {
|
|
$exeItem = Get-Item $ExePath
|
|
|
|
$form = @{
|
|
attachment = $exeItem
|
|
}
|
|
|
|
$response = Invoke-WebRequest -Uri $uploadUrl `
|
|
-Method POST `
|
|
-Headers @{ "Authorization" = "Basic $auth" } `
|
|
-Form $form `
|
|
-TimeoutSec 600 `
|
|
-ErrorAction Stop
|
|
|
|
Write-Host "[OK] Executable uploaded" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host "ERROR uploading executable: $_" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# Step 3: Upload checksum as asset
|
|
Write-Host "Uploading checksum asset..." -ForegroundColor Yellow
|
|
|
|
try {
|
|
$checksumItem = Get-Item $ChecksumPath
|
|
|
|
$form = @{
|
|
attachment = $checksumItem
|
|
}
|
|
|
|
$response = Invoke-WebRequest -Uri $uploadUrl `
|
|
-Method POST `
|
|
-Headers @{ "Authorization" = "Basic $auth" } `
|
|
-Form $form `
|
|
-TimeoutSec 30 `
|
|
-ErrorAction Stop
|
|
|
|
Write-Host "[OK] Checksum uploaded" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host "ERROR uploading checksum: $_" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "`n[OK] Release complete!" -ForegroundColor Green
|
|
Write-Host "View at: $ForgejoUrl/$Repo/releases/tag/v$Version" -ForegroundColor Cyan
|