mirror of
https://github.com/hansjone/netx.git
synced 2026-10-15 04:53:20 +08:00
- packaging/linux: netx-<ver>-linux-x86_64.tar.gz with bundled Python 3.12, PostgreSQL 16 and web/dist (glibc >= 2.17). install.sh (install/update/ reinstall), netxctl (start/stop/status/logs, set-port, set-bind, set-pg-port, reconfigure-db, check-update/update/auto-update, backup, uninstall), systemd units, nohup fallback without systemd. Privilege drop, detaching and tar go through the bundled Python, so bare images without su/runuser/setsid/tar work. - Updates: same GitHub/Forgejo/manifest sources as Windows, sha256 verified, pre-update pg_dump, automatic rollback when the new version does not come up. - Non-loopback bind: generated bootstrap admin password and NETX_UME_VERIFY_TLS=true, as security_bootstrap requires. - Build in manylinux2014 + check_bundle.sh (GLIBC <= 2.17, no missing libs); release-linux.yml builds on v* tags and smoke-tests offline on CentOS 7, Rocky 9, Ubuntu 18.04/24.04, Debian 12, openSUSE Leap 15 and openEuler 22.03 before attaching to the release. - Windows: Setup DB page gets a bundled PG port field and /BundledPgPort=; set_pg_port.ps1 + tray "Built-in database port"; reconfigure keeps the configured port; postgresql.conf is written without a BOM (PS 5.1 Set-Content -Encoding utf8 broke postgres). - Forgejo/GitHub publish scripts include the Linux package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
150 lines
5.3 KiB
PowerShell
150 lines
5.3 KiB
PowerShell
param(
|
|
[string]$Version = "",
|
|
[string]$ForgejoBase = "https://git.avelo.top",
|
|
[string]$Owner = "hansjone",
|
|
[string]$Repo = "netx",
|
|
[string]$Token = "",
|
|
[string]$ReleaseDir = ""
|
|
)
|
|
|
|
# Publish Windows Setup.exe (+ the Linux tar.gz when present in the release dir) to Forgejo/Gitea (mirror sync does NOT copy GitHub Release files).
|
|
# Requires a Forgejo token with repo write (Settings → Applications → Generate New Token).
|
|
# Default: https://git.avelo.top (public domain). LAN IP only when explicitly reachable.
|
|
#
|
|
# Example:
|
|
# $env:NETX_FORGEJO_TOKEN = "..." # or User env NETX_FORGEJO_TOKEN
|
|
# .\packaging\publish_forgejo_release.ps1 -Version 0.4.11
|
|
#
|
|
# Optional LAN (when 10.0.0.131 is reachable):
|
|
# .\packaging\publish_forgejo_release.ps1 -Version 0.4.11 -ForgejoBase "http://10.0.0.131:3000"
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
. "$PSScriptRoot\_common.ps1"
|
|
|
|
$repoRoot = Get-NetxRepoRoot
|
|
if (-not $Version) {
|
|
$Version = Get-NetxVersion -ProgramRoot $repoRoot
|
|
}
|
|
$tag = "v$Version"
|
|
$relDir = if ($ReleaseDir) { $ReleaseDir } else { Join-Path $PSScriptRoot "release" }
|
|
$setup = Join-Path $relDir "NetX-Setup-$Version.exe"
|
|
$checksum = "$setup.sha256"
|
|
# Linux package from CI (gh release download vX -p 'netx-*-linux-*' -D packaging\release) or a local build.
|
|
$linuxPkg = Join-Path $relDir "netx-$Version-linux-x86_64.tar.gz"
|
|
$linuxSum = "$linuxPkg.sha256"
|
|
|
|
if (-not $Token) {
|
|
$Token = $env:NETX_FORGEJO_TOKEN
|
|
if (-not $Token) { $Token = $env:FORGEJO_TOKEN }
|
|
}
|
|
if (-not $Token) {
|
|
throw "forgejo_token_required: set NETX_FORGEJO_TOKEN or pass -Token"
|
|
}
|
|
if (-not (Test-Path $setup)) {
|
|
throw "missing_setup: $setup (run build_release.ps1 + ISCC first)"
|
|
}
|
|
$hash = (Get-FileHash -LiteralPath $setup -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
Set-Content -LiteralPath $checksum -Value $hash -Encoding ascii -NoNewline
|
|
$apiBase = "$ForgejoBase/api/v1/repos/$Owner/$Repo"
|
|
$headers = @{
|
|
"Authorization" = "token $Token"
|
|
"Accept" = "application/json"
|
|
}
|
|
|
|
function Invoke-ForgejoJson {
|
|
param(
|
|
[string]$Method,
|
|
[string]$Url,
|
|
[object]$Body = $null
|
|
)
|
|
$params = @{
|
|
Method = $Method
|
|
Uri = $Url
|
|
Headers = $headers
|
|
ContentType = "application/json"
|
|
}
|
|
if ($null -ne $Body) {
|
|
$params["Body"] = ($Body | ConvertTo-Json -Depth 5)
|
|
}
|
|
return Invoke-RestMethod @params
|
|
}
|
|
|
|
Write-Host "==> Forgejo publish $tag -> $ForgejoBase/$Owner/$Repo"
|
|
|
|
# Ensure git tag exists on Forgejo (mirror usually already has it).
|
|
try {
|
|
$null = Invoke-ForgejoJson -Method GET -Url "$apiBase/git/refs/tags/$tag"
|
|
Write-Host " tag $tag present on Forgejo"
|
|
} catch {
|
|
Write-Host "[WARN] tag $tag not found on Forgejo yet — run mirror-sync or push tag first" -ForegroundColor Yellow
|
|
}
|
|
|
|
$existing = $null
|
|
try {
|
|
$existing = Invoke-ForgejoJson -Method GET -Url "$apiBase/releases/tags/$tag"
|
|
} catch {
|
|
$existing = $null
|
|
}
|
|
|
|
$notes = @"
|
|
NetX $Version (published from GitHub release build).
|
|
|
|
- NetX-Setup-$Version.exe — Windows installer
|
|
"@
|
|
if (Test-Path $linuxPkg) {
|
|
$notes += "`n- netx-$Version-linux-x86_64.tar.gz — Linux x86_64 offline package (``sudo ./install.sh``)"
|
|
} else {
|
|
Write-Host "[WARN] Linux package not found ($linuxPkg); publishing Windows only" -ForegroundColor Yellow
|
|
}
|
|
|
|
if ($existing -and $existing.id) {
|
|
Write-Host "==> Release $tag already exists (id=$($existing.id)); deleting old release to re-upload assets"
|
|
Invoke-ForgejoJson -Method DELETE -Url "$apiBase/releases/$($existing.id)" | Out-Null
|
|
}
|
|
|
|
Write-Host "==> Creating release $tag"
|
|
$rel = Invoke-ForgejoJson -Method POST -Url "$apiBase/releases" -Body @{
|
|
tag_name = $tag
|
|
target = "main"
|
|
name = "NetX $Version"
|
|
body = $notes
|
|
draft = $false
|
|
prerelease = $false
|
|
}
|
|
$relId = $rel.id
|
|
if (-not $relId) { throw "forgejo_create_release_failed" }
|
|
|
|
function Upload-ForgejoAsset {
|
|
param([string]$Path)
|
|
if (-not (Test-Path $Path)) { return }
|
|
$name = Split-Path -Leaf $Path
|
|
Write-Host "==> Uploading $name ..."
|
|
$url = "$apiBase/releases/$relId/assets"
|
|
$curl = Get-Command curl.exe -ErrorAction SilentlyContinue
|
|
if (-not $curl) { throw "curl.exe required for asset upload" }
|
|
# --ssl-no-revoke: schannel CRYPT_E_REVOCATION_OFFLINE often fails via proxy/offline CA.
|
|
# --noproxy: a desktop proxy in HTTP(S)_PROXY cannot reach a LAN Forgejo (502).
|
|
$forgejoHost = ([Uri]$ForgejoBase).Host
|
|
& $curl.Source -f -sS --ssl-no-revoke --noproxy $forgejoHost -X POST `
|
|
-H "Authorization: token $Token" `
|
|
-F "attachment=@$Path" `
|
|
$url
|
|
if ($LASTEXITCODE -ne 0) { throw "upload_failed: $name" }
|
|
Write-Host " OK $name" -ForegroundColor Green
|
|
}
|
|
|
|
Upload-ForgejoAsset -Path $setup
|
|
Upload-ForgejoAsset -Path $checksum
|
|
if (Test-Path $linuxPkg) {
|
|
if (-not (Test-Path $linuxSum)) {
|
|
$lh = (Get-FileHash -LiteralPath $linuxPkg -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
Set-Content -LiteralPath $linuxSum -Value "$lh $(Split-Path -Leaf $linuxPkg)" -Encoding ascii -NoNewline
|
|
}
|
|
Upload-ForgejoAsset -Path $linuxPkg
|
|
Upload-ForgejoAsset -Path $linuxSum
|
|
}
|
|
|
|
$releaseUrl = "$ForgejoBase/$Owner/$Repo/releases/tag/$tag"
|
|
Write-Host ""
|
|
Write-Host "==> Forgejo release ready: $releaseUrl" -ForegroundColor Green
|
|
Write-Host " Update API: $ForgejoBase/api/v1/repos/$Owner/$Repo/releases/latest"
|