refactor: Switch from Packages API to Releases API for distribution
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
This commit is contained in:
claudi 2026-01-28 15:11:46 +01:00
parent 9c8a8d269c
commit 72b0cfb496
3 changed files with 257 additions and 200 deletions

View file

@ -1,5 +1,5 @@
# Upload Windows Build to Forgejo Packages
# Usage: .\upload_to_packages.ps1 -Version 1.0.0
# 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
@ -57,13 +57,13 @@ if (-not $ForgejoUser -or -not $ForgejoPW) {
$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: .\upload_to_packages.ps1 -ClearCredentials" -ForegroundColor Gray
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: .\upload_to_packages.ps1 -Version 1.0.0" -ForegroundColor Yellow
Write-Host "Usage: .\create_release.ps1 -Version 1.0.0" -ForegroundColor Yellow
exit 1
}
@ -78,7 +78,7 @@ if (-not (Test-Path $ChecksumPath)) {
exit 1
}
Write-Host "Uploading WebDropBridge $Version to Forgejo Packages..." -ForegroundColor Cyan
Write-Host "Creating WebDropBridge $Version release on Forgejo..." -ForegroundColor Cyan
# Get file info
$exeSize = (Get-Item $ExePath).Length / 1MB
@ -90,47 +90,88 @@ Write-Host "Checksum: $($checksum.Substring(0, 16))..."
# Create basic auth header
$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${ForgejoUser}:${ForgejoPW}"))
# Upload executable
Write-Host "`nUploading executable..." -ForegroundColor Yellow
$exeUrl = "$ForgejoUrl/api/v1/repos/$Repo/packages/generic/webdrop-bridge/$Version/WebDropBridge.exe"
$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 $exeUrl `
-Method PUT `
$response = Invoke-WebRequest -Uri $releaseUrl `
-Method POST `
-Headers $headers `
-InFile $ExePath `
-ContentType "application/octet-stream" `
-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 successfully" -ForegroundColor Green
Write-Host "[OK] Executable uploaded" -ForegroundColor Green
}
catch {
Write-Host "ERROR uploading executable: $_" -ForegroundColor Red
exit 1
}
# Upload checksum
Write-Host "Uploading checksum..." -ForegroundColor Yellow
$checksumUrl = "$ForgejoUrl/api/v1/repos/$Repo/packages/generic/webdrop-bridge/$Version/WebDropBridge.exe.sha256"
# Step 3: Upload checksum as asset
Write-Host "Uploading checksum asset..." -ForegroundColor Yellow
try {
$response = Invoke-WebRequest -Uri $checksumUrl `
-Method PUT `
-Headers $headers `
-Body $checksum `
-ContentType "text/plain"
$checksumItem = Get-Item $ChecksumPath
Write-Host "[OK] Checksum uploaded successfully" -ForegroundColor Green
$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] Upload complete!" -ForegroundColor Green
Write-Host "View at: $ForgejoUrl/$Repo/packages" -ForegroundColor Cyan
Write-Host "`n[OK] Release complete!" -ForegroundColor Green
Write-Host "View at: $ForgejoUrl/$Repo/releases/tag/v$Version" -ForegroundColor Cyan

View file

@ -1,6 +1,6 @@
#!/bin/bash
# Upload macOS Build to Forgejo Packages
# Usage: ./upload_to_packages.sh -v 1.0.0
# Create Forgejo Release with Binary Assets
# Usage: ./create_release.sh -v 1.0.0
# Uses your Forgejo credentials (same as git)
# First run will prompt for credentials and save them to this session
@ -65,7 +65,18 @@ if [ -z "$FORGEJO_USER" ] || [ -z "$FORGEJO_PASS" ]; then
echo "Tip: Credentials will persist until you close the terminal or run: $0 --clear-credentials"
fi
echo "Uploading WebDropBridge $VERSION to Forgejo Packages..."
# Verify files exist
if [ ! -f "$DMG_PATH" ]; then
echo "ERROR: DMG file not found at $DMG_PATH"
exit 1
fi
if [ ! -f "$CHECKSUM_PATH" ]; then
echo "ERROR: Checksum file not found at $CHECKSUM_PATH"
exit 1
fi
echo "Creating WebDropBridge $VERSION release on Forgejo..."
# Get file info
DMG_SIZE=$(du -m "$DMG_PATH" | cut -f1)
@ -74,42 +85,70 @@ CHECKSUM=$(cat "$CHECKSUM_PATH")
echo "File: WebDropBridge.dmg ($DMG_SIZE MB)"
echo "Checksum: ${CHECKSUM:0:16}..."
# Create basic auth header
# Create basic auth
BASIC_AUTH=$(echo -n "${FORGEJO_USER}:${FORGEJO_PASS}" | base64)
# Upload DMG
# Step 1: Create release
echo ""
echo "Uploading DMG..."
DMG_URL="$FORGEJO_URL/api/v1/repos/$REPO/packages/generic/webdrop-bridge/$VERSION/WebDropBridge.dmg"
echo "Creating release v$VERSION..."
RELEASE_URL="$FORGEJO_URL/api/v1/repos/$REPO/releases"
HTTP_CODE=$(curl -s -w "%{http_code}" -X PUT \
RELEASE_DATA=$(cat <<EOF
{
"tag_name": "v$VERSION",
"name": "WebDropBridge v$VERSION",
"body": "WebDropBridge v$VERSION\n\nChecksum: $CHECKSUM",
"draft": false,
"prerelease": false
}
EOF
)
RESPONSE=$(curl -s -X POST \
-H "Authorization: Basic $BASIC_AUTH" \
--data-binary "@$DMG_PATH" \
-H "Content-Type: application/octet-stream" \
"$DMG_URL" \
-H "Content-Type: application/json" \
-d "$RELEASE_DATA" \
"$RELEASE_URL")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
if [ -z "$RELEASE_ID" ]; then
echo "ERROR creating release:"
echo "$RESPONSE"
exit 1
fi
echo "[OK] Release created (ID: $RELEASE_ID)"
# Step 2: Upload DMG as asset
echo "Uploading executable asset..."
UPLOAD_URL="$FORGEJO_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets"
HTTP_CODE=$(curl -s -w "%{http_code}" -X POST \
-H "Authorization: Basic $BASIC_AUTH" \
-F "attachment=@$DMG_PATH" \
"$UPLOAD_URL" \
-o /tmp/curl_response.txt)
if [ "$HTTP_CODE" -eq 201 ] || [ "$HTTP_CODE" -eq 200 ]; then
echo "✓ DMG uploaded successfully"
echo "[OK] DMG uploaded"
else
echo "ERROR uploading DMG (HTTP $HTTP_CODE)"
cat /tmp/curl_response.txt
exit 1
fi
# Upload checksum
echo "Uploading checksum..."
CHECKSUM_URL="$FORGEJO_URL/api/v1/repos/$REPO/packages/generic/webdrop-bridge/$VERSION/WebDropBridge.dmg.sha256"
# Step 3: Upload checksum as asset
echo "Uploading checksum asset..."
HTTP_CODE=$(curl -s -w "%{http_code}" -X PUT \
HTTP_CODE=$(curl -s -w "%{http_code}" -X POST \
-H "Authorization: Basic $BASIC_AUTH" \
-d "$CHECKSUM" \
-H "Content-Type: text/plain" \
"$CHECKSUM_URL" \
-F "attachment=@$CHECKSUM_PATH" \
"$UPLOAD_URL" \
-o /tmp/curl_response.txt)
if [ "$HTTP_CODE" -eq 201 ] || [ "$HTTP_CODE" -eq 200 ]; then
echo "✓ Checksum uploaded successfully"
echo "[OK] Checksum uploaded"
else
echo "ERROR uploading checksum (HTTP $HTTP_CODE)"
cat /tmp/curl_response.txt
@ -117,5 +156,5 @@ else
fi
echo ""
echo "✓ Upload complete!"
echo "View at: $FORGEJO_URL/$REPO/packages"
echo "[OK] Release complete!"
echo "View at: $FORGEJO_URL/$REPO/releases/tag/v$VERSION"