diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 16da361..57a1e5d 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -61,11 +61,6 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v5 - - uses: actions/setup-node@v4 - with: - node-version: '22' - cache: npm - cache-dependency-path: launcher/package-lock.json - name: Install Windows build dependencies shell: powershell run: .\scripts\ci\install-windows.ps1 diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 72b7271..5ab9d9f 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -53,11 +53,6 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v5 - - uses: actions/setup-node@v4 - with: - node-version: 22 - cache: npm - cache-dependency-path: launcher/package-lock.json - name: Install Windows build dependencies shell: powershell run: .\scripts\ci\install-windows.ps1 diff --git a/.github/workflows/runner-setup.yml b/.github/workflows/runner-setup.yml index e0edfd0..a2e069e 100644 --- a/.github/workflows/runner-setup.yml +++ b/.github/workflows/runner-setup.yml @@ -40,9 +40,6 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v5 - - uses: actions/setup-node@v4 - with: - node-version: '22' - name: Install PowerShell, Rust and MSVC shell: powershell run: .\scripts\ci\install-windows.ps1 diff --git a/README.md b/README.md index ac72fa0..1a128ed 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The workflow builds the **Windows installer**, pushes the **panel image to Gitea ### Gitea runner setup -Register a Linux host runner with the `ubuntu-latest` label and a Windows host runner with `windows-latest`. Linux builds the panel Docker image and server JARs; Windows builds the NSIS installer. The workflows use [the Linux setup tool](scripts/ci/install-linux.sh) and [the Windows setup tool](scripts/ci/install-windows.ps1) to install or check job dependencies. Node 22 and Java 21/25 are downloaded by `setup-node` and `setup-java`; the Linux tool installs Rust, Tauri system packages, and release utilities, while the Windows tool installs Rust and downloads PowerShell 7.6.6 if the runner cannot find it. Docker and Buildx are set up by Docker's Actions. The Linux runner must allow a Docker daemon to start or provide one, and system package installation needs root or passwordless sudo. Enable Actions for the repository and allow its job token to write releases and packages. See [Gitea's runner labels](https://docs.gitea.com/runner/labels/) and [token permissions](https://docs.gitea.com/usage/actions/token-permissions/). +Register a Linux host runner with the `ubuntu-latest` label and a Windows host runner with `windows-latest`. Linux builds the panel Docker image and server JARs; Windows builds the NSIS installer. The workflows use [the Linux setup tool](scripts/ci/install-linux.sh) and [the Windows setup tool](scripts/ci/install-windows.ps1) to install or check job dependencies. Linux Node 22 and Java 21/25 are downloaded by `setup-node` and `setup-java`; the Linux tool installs Rust, Tauri system packages, and release utilities. The Windows tool downloads PowerShell 7.6.6 and Node 22 if unavailable, then installs Rust and Microsoft C++ Build Tools. Docker and Buildx are set up by Docker's Actions. The Linux runner must allow a Docker daemon to start or provide one, and system package installation needs root or passwordless sudo. Enable Actions for the repository and allow its job token to write releases and packages. See [Gitea's runner labels](https://docs.gitea.com/runner/labels/) and [token permissions](https://docs.gitea.com/usage/actions/token-permissions/). The setup tools also run directly on matching hosts: `bash scripts/ci/install-linux.sh rust` prepares Rust and Tauri builds, `bash scripts/ci/install-linux.sh image` checks Docker, `bash scripts/ci/install-linux.sh java 21` checks a Java integration runner, and `powershell -File scripts/ci/install-windows.ps1` prepares the Windows installer runner. Gitea uses them in CI and release jobs; GitHub provides a manual **Runner setup** workflow for both platforms. Run the Linux `rust` mode as root or with passwordless sudo; the Windows script may need administrator rights to install Microsoft C++ Build Tools. diff --git a/scripts/ci/install-windows.ps1 b/scripts/ci/install-windows.ps1 index 203424e..5ab6a3c 100644 --- a/scripts/ci/install-windows.ps1 +++ b/scripts/ci/install-windows.ps1 @@ -34,6 +34,22 @@ if (-not $pwsh) { Add-RunnerPath (Split-Path $pwsh) Write-Host "PowerShell $(& $pwsh -NoProfile -Command '$PSVersionTable.PSVersion.ToString()') is ready." +$node = Get-Command node.exe -ErrorAction SilentlyContinue +$nodeMajor = if ($node) { [int](& node -p 'process.versions.node.split(".")[0]') } else { 0 } +if ($nodeMajor -lt 22) { + $nodeVersion = '22.23.3' + $nodeArchive = Join-Path $env:RUNNER_TEMP "node-v$nodeVersion-win-x64.zip" + $nodeRoot = Join-Path $env:RUNNER_TEMP 'scopenet-node' + $nodeBin = Join-Path $nodeRoot "node-v$nodeVersion-win-x64" + if (-not (Test-Path (Join-Path $nodeBin 'node.exe'))) { + Invoke-WebRequest -UseBasicParsing -Uri "https://nodejs.org/dist/v$nodeVersion/node-v$nodeVersion-win-x64.zip" -OutFile $nodeArchive + Expand-Archive -Path $nodeArchive -DestinationPath $nodeRoot -Force + Remove-Item $nodeArchive + } + Add-RunnerPath $nodeBin +} +Write-Host "Node $(& node --version) is ready." + $cargoBin = Join-Path $env:USERPROFILE '.cargo\bin' Add-RunnerPath $cargoBin if (-not (Get-Command rustup.exe -ErrorAction SilentlyContinue)) { @@ -65,6 +81,5 @@ Write-Host "Microsoft C++ Build Tools are ready at $vsPath." foreach ($tool in @('cargo.exe', 'rustc.exe', 'node.exe', 'npm.cmd')) { if (-not (Get-Command $tool -ErrorAction SilentlyContinue)) { throw "Missing $tool after dependency setup." } } -$nodeMajor = [int](& node -p 'process.versions.node.split(".")[0]') -if ($nodeMajor -lt 22) { throw 'Node 22+ is required.' } +if ([int](& node -p 'process.versions.node.split(".")[0]') -lt 22) { throw 'Node 22+ is required.' } Write-Host "Windows $Mode dependencies are ready."