|
| 1 | +name: Installer Smoke |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + one-liner: |
| 12 | + name: one-liner (${{ matrix.label }}) |
| 13 | + runs-on: ${{ matrix.runner }} |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - label: linux-x64 |
| 19 | + runner: ubuntu-latest |
| 20 | + - label: linux-arm64 |
| 21 | + runner: ubuntu-24.04-arm |
| 22 | + - label: macos-x64 |
| 23 | + runner: macos-13 |
| 24 | + - label: macos-arm64 |
| 25 | + runner: macos-latest |
| 26 | + - label: windows-x64 |
| 27 | + runner: windows-latest |
| 28 | + - label: windows-arm64 |
| 29 | + runner: windows-11-arm |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Set up Dart |
| 35 | + uses: dart-lang/setup-dart@v1 |
| 36 | + |
| 37 | + - name: Install dependencies |
| 38 | + run: dart pub get |
| 39 | + |
| 40 | + - name: Build local payload (Linux/macOS) |
| 41 | + if: runner.os != 'Windows' |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + set -euo pipefail |
| 45 | + os_raw="$(uname -s | tr '[:upper:]' '[:lower:]')" |
| 46 | + case "$os_raw" in |
| 47 | + linux*) os="linux" ;; |
| 48 | + darwin*) os="macos" ;; |
| 49 | + *) echo "Unsupported OS: $os_raw"; exit 1 ;; |
| 50 | + esac |
| 51 | + arch_raw="$(uname -m | tr '[:upper:]' '[:lower:]')" |
| 52 | + case "$arch_raw" in |
| 53 | + x86_64|amd64) arch="x64" ;; |
| 54 | + arm64|aarch64) arch="arm64" ;; |
| 55 | + *) echo "Unsupported architecture: $arch_raw"; exit 1 ;; |
| 56 | + esac |
| 57 | + asset="drx-${os}-${arch}" |
| 58 | +
|
| 59 | + serve_root="$RUNNER_TEMP/serve" |
| 60 | + mkdir -p "$serve_root/download" "$serve_root/tool" |
| 61 | +
|
| 62 | + dart compile exe bin/drx.dart -o "$serve_root/download/$asset" |
| 63 | + shasum -a 256 "$serve_root/download/$asset" > "$serve_root/download/$asset.sha256" |
| 64 | +
|
| 65 | + cp tool/install.sh "$serve_root/tool/install.sh" |
| 66 | +
|
| 67 | + - name: Build local payload (Windows) |
| 68 | + if: runner.os == 'Windows' |
| 69 | + shell: pwsh |
| 70 | + run: | |
| 71 | + $archRaw = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant() |
| 72 | + switch ($archRaw) { |
| 73 | + 'x64' { $arch = 'x64' } |
| 74 | + 'arm64' { $arch = 'arm64' } |
| 75 | + default { throw "Unsupported architecture: $archRaw" } |
| 76 | + } |
| 77 | + $asset = "drx-windows-$arch.exe" |
| 78 | +
|
| 79 | + $serveRoot = Join-Path $env:RUNNER_TEMP "serve" |
| 80 | + New-Item -ItemType Directory -Path (Join-Path $serveRoot "download") -Force | Out-Null |
| 81 | + New-Item -ItemType Directory -Path (Join-Path $serveRoot "tool") -Force | Out-Null |
| 82 | +
|
| 83 | + $assetPath = Join-Path $serveRoot "download/$asset" |
| 84 | + dart compile exe bin/drx.dart -o $assetPath |
| 85 | +
|
| 86 | + $hash = (Get-FileHash -Algorithm SHA256 $assetPath).Hash.ToLower() |
| 87 | + "$hash $asset" | Out-File -Encoding ascii (Join-Path $serveRoot "download/$asset.sha256") |
| 88 | +
|
| 89 | + Copy-Item tool/install.ps1 (Join-Path $serveRoot "tool/install.ps1") |
| 90 | +
|
| 91 | + - name: Test one-liner install (Linux/macOS) |
| 92 | + if: runner.os != 'Windows' |
| 93 | + shell: bash |
| 94 | + run: | |
| 95 | + set -euo pipefail |
| 96 | + port=18080 |
| 97 | + serve_root="$RUNNER_TEMP/serve" |
| 98 | +
|
| 99 | + python3 -m http.server "$port" --directory "$serve_root" >"$RUNNER_TEMP/http.log" 2>&1 & |
| 100 | + server_pid=$! |
| 101 | + trap 'kill "$server_pid"' EXIT INT TERM |
| 102 | + sleep 2 |
| 103 | +
|
| 104 | + curl -fsSL "http://127.0.0.1:${port}/tool/install.sh" | \ |
| 105 | + DRX_REPO=example/drx \ |
| 106 | + DRX_DOWNLOAD_BASE="http://127.0.0.1:${port}/download" \ |
| 107 | + DRX_INSTALL_DIR="$RUNNER_TEMP/bin" \ |
| 108 | + sh |
| 109 | +
|
| 110 | + "$RUNNER_TEMP/bin/drx" --version |
| 111 | + "$RUNNER_TEMP/bin/drx" cache list --json |
| 112 | +
|
| 113 | + - name: Test one-liner install (Windows) |
| 114 | + if: runner.os == 'Windows' |
| 115 | + shell: pwsh |
| 116 | + run: | |
| 117 | + $port = 18080 |
| 118 | + $serveRoot = Join-Path $env:RUNNER_TEMP "serve" |
| 119 | + $stdoutLog = Join-Path $env:RUNNER_TEMP "http-out.log" |
| 120 | + $stderrLog = Join-Path $env:RUNNER_TEMP "http-err.log" |
| 121 | + $server = Start-Process -FilePath python -ArgumentList "-m","http.server",$port,"--directory",$serveRoot -RedirectStandardOutput $stdoutLog -RedirectStandardError $stderrLog -PassThru |
| 122 | + Start-Sleep -Seconds 2 |
| 123 | +
|
| 124 | + try { |
| 125 | + $env:DRX_REPO = "example/drx" |
| 126 | + $env:DRX_DOWNLOAD_BASE = "http://127.0.0.1:$port/download" |
| 127 | + $env:DRX_INSTALL_DIR = Join-Path $env:RUNNER_TEMP "bin" |
| 128 | +
|
| 129 | + Invoke-WebRequest -Uri "http://127.0.0.1:$port/tool/install.ps1" -UseBasicParsing | Invoke-Expression |
| 130 | +
|
| 131 | + $drxExe = Join-Path (Join-Path $env:RUNNER_TEMP "bin") "drx.exe" |
| 132 | + & $drxExe --version |
| 133 | + & $drxExe cache list --json |
| 134 | + } |
| 135 | + finally { |
| 136 | + if (-not $server.HasExited) { |
| 137 | + Stop-Process -Id $server.Id -Force |
| 138 | + } |
| 139 | + } |
0 commit comments