From 3da6f338b7729e178e7080cc740549efdbedd418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Eggert=20Lundsteen=20Olsen?= Date: Thu, 1 Oct 2026 07:35:49 +0200 Subject: [PATCH] Download the newest MSI with installer/get-latest-msi.ps1 Forgejo 10 has no releases/latest/download/ URL, so the versionless second copy of the MSI in each release was useless. Releases now carry the MSI once; get-latest-msi.ps1 finds it through GET /releases/latest (no login). Co-Authored-By: Claude Opus 5.5 (1M context) --- .forgejo/workflows/ci.yml | 6 +++--- docs/installation.md | 2 +- installer/get-latest-msi.ps1 | 21 +++++++++++++++++++++ installer/publish-release.py | 7 ++----- 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 installer/get-latest-msi.ps1 diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 95b7ee0..b479135 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -42,9 +42,9 @@ jobs: name: SQLInsight-Pro-msi path: dist/*.msi - name: Udgiv som release - # Kun tags (v1.2.0): MSI'en vedhæftes releasen og kan hentes uden login fra - # /releases/latest/download/SQLInsight-Pro-x64.msi. RELEASE_TOKEN (valgfri secret) bruges, - # hvis Actions' automatiske token ikke må oprette releases. + # Kun tags (v1.2.0): MSI'en vedhæftes releasen og kan hentes uden login, nyeste med + # installer/get-latest-msi.ps1. RELEASE_TOKEN (valgfri secret) bruges, hvis Actions' automatiske + # token ikke må oprette releases. if: startsWith(github.ref, 'refs/tags/v') env: TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }} diff --git a/docs/installation.md b/docs/installation.md index edce41b..fa27e83 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -13,7 +13,7 @@ Begge bruger en **repository-database** på en SQL Server 2016+-instans, der hel ## Hurtigst: MSI-installeren -`SQLInsight-Pro--x64.msi` installerer agent og web som Windows-tjenester. .NET er indbygget, så serveren behøver ingen runtime. Opret først repository-databasen (trin 2) og giv rettigheder (trin 3). Kør derefter installeren som administrator: +`SQLInsight-Pro--x64.msi` installerer agent og web som Windows-tjenester. .NET er indbygget, så serveren behøver ingen runtime. Hent den nyeste under [Releases](https://git.seosoft.dk/seo/sqlinsight-pro/releases), eller med `installer\get-latest-msi.ps1`. Opret først repository-databasen (trin 2) og giv rettigheder (trin 3). Kør derefter installeren som administrator: - **Med installationsguiden:** Første side spørger om forbindelsesstrengen til repositoriet, den første SQL Server, tjenestekonti og port. - **Stille, fx med SCCM/Intune:** diff --git a/installer/get-latest-msi.ps1 b/installer/get-latest-msi.ps1 new file mode 100644 index 0000000..9d7c36f --- /dev/null +++ b/installer/get-latest-msi.ps1 @@ -0,0 +1,21 @@ +<# +.SYNOPSIS + Henter den nyeste SQLInsight Pro-MSI fra Forgejo-releases (ingen login kræves). +.EXAMPLE + .\installer\get-latest-msi.ps1 # gemmer i den aktuelle mappe + .\installer\get-latest-msi.ps1 -OutDir C:\Temp +#> +param( + [string]$OutDir = (Get-Location).Path, + [string]$Repo = 'https://git.seosoft.dk/api/v1/repos/seo/sqlinsight-pro' +) +$ErrorActionPreference = 'Stop' +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +$release = Invoke-RestMethod "$Repo/releases/latest" +$asset = $release.assets | Where-Object name -like 'SQLInsight-Pro-*-x64.msi' | Select-Object -First 1 +if (-not $asset) { throw "Releasen $($release.tag_name) har ingen MSI." } + +$target = Join-Path $OutDir $asset.name +Invoke-WebRequest $asset.browser_download_url -OutFile $target -UseBasicParsing +Write-Output "$($release.name): $target" diff --git a/installer/publish-release.py b/installer/publish-release.py index 6209500..13c6628 100755 --- a/installer/publish-release.py +++ b/installer/publish-release.py @@ -4,8 +4,8 @@ publish-release.py dist/SQLInsight-Pro-1.2.0-x64.msi Environment (set by Forgejo Actions): GITHUB_SERVER_URL, GITHUB_REPOSITORY, GITHUB_REF_NAME, and TOKEN with write -access to the repository. The MSI is attached twice: under its own name and as SQLInsight-Pro-x64.msi, so the -newest one can always be fetched from .../releases/latest/download/SQLInsight-Pro-x64.msi. +access to the repository. Forgejo has no .../releases/latest/download/ URL; installer/get-latest-msi.ps1 finds the +newest MSI through the API (GET /repos/{repo}/releases/latest) instead. """ import json import os @@ -14,8 +14,6 @@ import urllib.error import urllib.request import uuid -LATEST_NAME = "SQLInsight-Pro-x64.msi" - SERVER = os.environ["GITHUB_SERVER_URL"].rstrip("/") REPO = os.environ["GITHUB_REPOSITORY"] TAG = os.environ["GITHUB_REF_NAME"] @@ -64,7 +62,6 @@ def main(): }) print(f"release {TAG} oprettet") upload(release, msi, os.path.basename(msi)) - upload(call("GET", f"{API}/releases/{release['id']}"), msi, LATEST_NAME) print(f"{SERVER}/{REPO}/releases/tag/{TAG}")