Add shared runner dependency setup for Linux and Windows
CI / Real Minecraft installs (manual) (push) Skipped
CI / Windows launcher (push) Failing after 13s
CI / Rust, web and container (push) Canceled after 0s
Server integrations / paper (push) Canceled after 0s
Server integrations / Fabric and Forge / 1.20.1 (push) Canceled after 0s
Server integrations / Fabric and Forge / 1.21.1 (push) Canceled after 0s
Server integrations / Fabric and Forge / 26.1.2 (push) Canceled after 0s
Server integrations / Fabric and Forge / 26.2 (push) Canceled after 0s
Server integrations / Fabric and Forge / 26.3 (push) Canceled after 0s
CI / Real Minecraft installs (manual) (push) Skipped
CI / Windows launcher (push) Failing after 13s
CI / Rust, web and container (push) Canceled after 0s
Server integrations / paper (push) Canceled after 0s
Server integrations / Fabric and Forge / 1.20.1 (push) Canceled after 0s
Server integrations / Fabric and Forge / 1.21.1 (push) Canceled after 0s
Server integrations / Fabric and Forge / 26.1.2 (push) Canceled after 0s
Server integrations / Fabric and Forge / 26.2 (push) Canceled after 0s
Server integrations / Fabric and Forge / 26.3 (push) Canceled after 0s
This commit is contained in:
1 parent
23ab34ab72
commit
a378f9904c
7 files changed
+262
-83
No files matched your search
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install job-local dependencies on Linux Actions runners.
|
||||
set -euo pipefail
|
||||
|
||||
mode="${1:-}"
|
||||
case "$mode" in
|
||||
rust|image|java|release) ;;
|
||||
*) echo "Usage: $0 {rust|image|java|release}" >&2; exit 2 ;;
|
||||
esac
|
||||
[[ "$(uname -s)" == Linux ]] || { echo 'This setup tool requires Linux.' >&2; exit 1; }
|
||||
|
||||
add_path() {
|
||||
export PATH="$1:$PATH"
|
||||
for path_file in "${GITHUB_PATH:-}" "${GITEA_PATH:-}"; do
|
||||
[[ -z "$path_file" ]] || printf '%s\n' "$1" >> "$path_file"
|
||||
done
|
||||
}
|
||||
|
||||
install_packages() {
|
||||
local apt=()
|
||||
local missing=()
|
||||
command -v apt-get >/dev/null || { echo 'Automatic system package installation requires apt-get (Ubuntu/Debian runner).' >&2; exit 1; }
|
||||
for package in "$@"; do
|
||||
dpkg-query -W -f='${Status}' "$package" 2>/dev/null | grep -q 'install ok installed' || missing+=("$package")
|
||||
done
|
||||
[[ ${#missing[@]} -gt 0 ]] || return 0
|
||||
if [[ "$(id -u)" != 0 ]]; then
|
||||
command -v sudo >/dev/null || { echo 'System packages require root or passwordless sudo.' >&2; exit 1; }
|
||||
sudo -n true || { echo 'Passwordless sudo is required for system packages.' >&2; exit 1; }
|
||||
apt=(sudo -n)
|
||||
fi
|
||||
"${apt[@]}" apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive "${apt[@]}" apt-get install -y --no-install-recommends "${missing[@]}"
|
||||
}
|
||||
|
||||
require() {
|
||||
command -v "$1" >/dev/null || { echo "Missing $1 after dependency setup." >&2; exit 1; }
|
||||
}
|
||||
|
||||
case "$mode" in
|
||||
rust)
|
||||
install_packages build-essential curl file libayatana-appindicator3-dev librsvg2-dev libssl-dev libwebkit2gtk-4.1-dev libxdo-dev pkg-config wget
|
||||
if ! command -v rustup >/dev/null; then
|
||||
installer="$(mktemp)"
|
||||
trap 'rm -f "$installer"' EXIT
|
||||
curl -fsSL https://sh.rustup.rs -o "$installer"
|
||||
sh "$installer" -y --profile minimal --default-toolchain stable
|
||||
fi
|
||||
add_path "${CARGO_HOME:-$HOME/.cargo}/bin"
|
||||
rustup toolchain install stable --profile minimal --component rustfmt --component clippy
|
||||
rustup default stable
|
||||
require cargo
|
||||
require rustc
|
||||
require node
|
||||
require npm
|
||||
[[ "$(node -p 'process.versions.node.split(".")[0]')" -ge 22 ]] || { echo 'Node 22+ is required.' >&2; exit 1; }
|
||||
pkg-config --exists webkit2gtk-4.1 ayatana-appindicator3-0.1 librsvg-2.0
|
||||
;;
|
||||
image)
|
||||
require docker
|
||||
docker info >/dev/null || { echo 'Docker daemon is unavailable. Mount the host socket or run a Docker-capable host runner.' >&2; exit 1; }
|
||||
docker buildx version >/dev/null || { echo 'Docker Buildx is missing. Install the Docker buildx plugin on the host runner.' >&2; exit 1; }
|
||||
;;
|
||||
java)
|
||||
require java
|
||||
[[ -n "${2:-}" ]] || { echo 'Java major version is required.' >&2; exit 2; }
|
||||
java -version 2>&1 | grep -q "${2}\." || { echo "Java $2 is required for this integration build." >&2; exit 1; }
|
||||
require bash
|
||||
;;
|
||||
release)
|
||||
if ! command -v curl >/dev/null || ! command -v jq >/dev/null; then install_packages curl jq; fi
|
||||
require curl
|
||||
require jq
|
||||
;;
|
||||
esac
|
||||
echo "Linux $mode dependencies are ready."
|
||||
@@ -0,0 +1,70 @@
|
||||
# Installs job-local PowerShell and Rust dependencies for the Windows launcher.
|
||||
param([ValidateSet('Launcher')][string]$Mode = 'Launcher')
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if (-not [Environment]::OSVersion.Platform.ToString().StartsWith('Win')) {
|
||||
throw 'This setup tool requires Windows.'
|
||||
}
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
if (-not $env:RUNNER_TEMP) { $env:RUNNER_TEMP = $env:TEMP }
|
||||
|
||||
function Add-RunnerPath([string]$Directory) {
|
||||
$env:PATH = "$Directory;$env:PATH"
|
||||
foreach ($pathFile in @($env:GITHUB_PATH, $env:GITEA_PATH)) {
|
||||
if ($pathFile) { Add-Content -Path $pathFile -Value $Directory }
|
||||
}
|
||||
}
|
||||
|
||||
$pwsh = Get-Command pwsh.exe -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty Source
|
||||
if (-not $pwsh) {
|
||||
$machinePwsh = Join-Path $env:ProgramFiles 'PowerShell\7\pwsh.exe'
|
||||
if (Test-Path $machinePwsh) { $pwsh = $machinePwsh }
|
||||
}
|
||||
if (-not $pwsh) {
|
||||
$version = '7.6.6'
|
||||
$installDir = Join-Path $env:RUNNER_TEMP "scopenet-pwsh-$version"
|
||||
$pwsh = Join-Path $installDir 'pwsh.exe'
|
||||
if (-not (Test-Path $pwsh)) {
|
||||
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
|
||||
$archive = Join-Path $env:RUNNER_TEMP "PowerShell-$version-win-x64.zip"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/PowerShell/PowerShell/releases/download/v$version/PowerShell-$version-win-x64.zip" -OutFile $archive
|
||||
Expand-Archive -Path $archive -DestinationPath $installDir -Force
|
||||
Remove-Item $archive
|
||||
}
|
||||
}
|
||||
Add-RunnerPath (Split-Path $pwsh)
|
||||
Write-Host "PowerShell $(& $pwsh -NoProfile -Command '$PSVersionTable.PSVersion.ToString()') is ready."
|
||||
|
||||
$cargoBin = Join-Path $env:USERPROFILE '.cargo\bin'
|
||||
Add-RunnerPath $cargoBin
|
||||
if (-not (Get-Command rustup.exe -ErrorAction SilentlyContinue)) {
|
||||
$installer = Join-Path $env:RUNNER_TEMP 'scopenet-rustup-init.exe'
|
||||
Invoke-WebRequest -UseBasicParsing -Uri 'https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe' -OutFile $installer
|
||||
& $installer -y --profile minimal --default-toolchain stable
|
||||
if ($LASTEXITCODE -ne 0) { throw "rustup installer failed with exit code $LASTEXITCODE" }
|
||||
Remove-Item $installer
|
||||
}
|
||||
& rustup toolchain install stable-x86_64-pc-windows-msvc --profile minimal --component clippy --component rustfmt
|
||||
if ($LASTEXITCODE -ne 0) { throw "Rust toolchain install failed with exit code $LASTEXITCODE" }
|
||||
& rustup default stable-x86_64-pc-windows-msvc
|
||||
if ($LASTEXITCODE -ne 0) { throw "Rust toolchain selection failed with exit code $LASTEXITCODE" }
|
||||
|
||||
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
|
||||
$vsPath = if (Test-Path $vswhere) { & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath }
|
||||
if (-not $vsPath) {
|
||||
$installer = Join-Path $env:RUNNER_TEMP 'scopenet-vs-buildtools.exe'
|
||||
Invoke-WebRequest -UseBasicParsing -Uri 'https://aka.ms/vs/17/release/vs_buildtools.exe' -OutFile $installer
|
||||
$arguments = @('--quiet', '--wait', '--norestart', '--add', 'Microsoft.VisualStudio.Workload.VCTools', '--includeRecommended')
|
||||
$process = Start-Process -FilePath $installer -ArgumentList $arguments -Wait -PassThru
|
||||
if ($process.ExitCode -eq 3010) { throw 'Microsoft C++ Build Tools installed, but Windows must be restarted before this runner can build.' }
|
||||
if ($process.ExitCode -ne 0) { throw "Microsoft C++ Build Tools installation failed with exit code $($process.ExitCode). Run the runner with administrator rights." }
|
||||
Remove-Item $installer
|
||||
$vsPath = if (Test-Path $vswhere) { & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath }
|
||||
if (-not $vsPath) { throw 'Microsoft C++ Build Tools installation did not provide the x64 MSVC compiler.' }
|
||||
}
|
||||
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.' }
|
||||
Write-Host "Windows $Mode dependencies are ready."
|
||||
Reference in new issue
Block a user