-
Notifications
You must be signed in to change notification settings - Fork 7
189 lines (163 loc) · 6.42 KB
/
installers.yml
File metadata and controls
189 lines (163 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Installer Scripts
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
jobs:
install-sh:
name: install.sh (${{ matrix.name }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
runner: ubuntu-latest
asset: dw-linux-x86_64
port: 18080
- name: macos-aarch64
runner: macos-14
asset: dw-macos-aarch64
port: 18081
steps:
- uses: actions/checkout@v4
- name: Build fixture release
shell: bash
run: |
set -eu
download_dir="$RUNNER_TEMP/release/latest/download"
mkdir -p "$download_dir"
cat > "$download_dir/${{ matrix.asset }}" <<'SH'
#!/usr/bin/env sh
echo "dw fixture 0.0.0"
SH
chmod +x "$download_dir/${{ matrix.asset }}"
cd "$download_dir"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "${{ matrix.asset }}" > SHA256SUMS
else
shasum -a 256 "${{ matrix.asset }}" > SHA256SUMS
fi
- name: Serve fixture release
shell: bash
run: |
set -eu
python3 -m http.server "${{ matrix.port }}" --directory "$RUNNER_TEMP/release" \
> "$RUNNER_TEMP/install-http.log" 2>&1 &
echo "$!" > "$RUNNER_TEMP/install-http.pid"
sleep 2
- name: Install with verified checksum
shell: bash
env:
DURABLE_WORKFLOW_RELEASE_BASE_URL: http://127.0.0.1:${{ matrix.port }}
DURABLE_WORKFLOW_INSTALL_DIR: ${{ runner.temp }}/dw-bin
run: |
set -eu
sh static/install.sh
"$DURABLE_WORKFLOW_INSTALL_DIR/dw" --version
- name: Reject checksum mismatch
shell: bash
env:
DURABLE_WORKFLOW_RELEASE_BASE_URL: http://127.0.0.1:${{ matrix.port }}
run: |
set -eu
printf '%064d %s\n' 0 "${{ matrix.asset }}" > "$RUNNER_TEMP/release/latest/download/SHA256SUMS"
bad_dir="$RUNNER_TEMP/dw-bad"
if DURABLE_WORKFLOW_INSTALL_DIR="$bad_dir" sh static/install.sh; then
echo "installer accepted a mismatched checksum" >&2
exit 1
fi
test ! -e "$bad_dir/dw"
- name: Stop fixture release
if: always()
shell: bash
run: |
if [ -f "$RUNNER_TEMP/install-http.pid" ]; then
kill "$(cat "$RUNNER_TEMP/install-http.pid")" 2>/dev/null || true
fi
install-ps1:
name: install.ps1 (windows-x86_64)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Build fixture release
shell: pwsh
run: |
$downloadDir = Join-Path $env:RUNNER_TEMP 'release\latest\download'
$appDir = Join-Path $env:RUNNER_TEMP 'fake-dw'
$publishDir = Join-Path $env:RUNNER_TEMP 'fake-dw-publish'
New-Item -ItemType Directory -Force -Path $downloadDir | Out-Null
dotnet new console --output $appDir
@'
Console.WriteLine("dw fixture 0.0.0");
'@ | Set-Content -Path (Join-Path $appDir 'Program.cs') -Encoding utf8
dotnet publish $appDir --configuration Release --runtime win-x64 --self-contained false `
-p:PublishSingleFile=true --output $publishDir
$asset = Join-Path $downloadDir 'dw-windows-x86_64.exe'
Copy-Item -Path (Join-Path $publishDir 'fake-dw.exe') -Destination $asset
$hash = (Get-FileHash -Algorithm SHA256 -Path $asset).Hash.ToLowerInvariant()
"$hash dw-windows-x86_64.exe" | Set-Content -Path (Join-Path $downloadDir 'SHA256SUMS') -Encoding ascii
- name: Exercise installer
shell: pwsh
env:
DURABLE_WORKFLOW_RELEASE_BASE_URL: http://127.0.0.1:18082
DURABLE_WORKFLOW_INSTALL_DIR: ${{ runner.temp }}\dw-bin
run: |
$releaseDir = Join-Path $env:RUNNER_TEMP 'release'
$stdout = Join-Path $env:RUNNER_TEMP 'install-http.log'
$stderr = Join-Path $env:RUNNER_TEMP 'install-http.err'
$python = (Get-Command python).Source
$server = Start-Process -FilePath $python `
-ArgumentList @('-m', 'http.server', '18082', '--bind', '127.0.0.1', '--directory', $releaseDir) `
-PassThru `
-RedirectStandardOutput $stdout `
-RedirectStandardError $stderr
$server.Id | Set-Content -Path (Join-Path $env:RUNNER_TEMP 'install-http.pid') -Encoding ascii
try {
$ready = $false
for ($attempt = 1; $attempt -le 15; $attempt++) {
try {
Invoke-WebRequest -Uri 'http://127.0.0.1:18082/latest/download/SHA256SUMS' -UseBasicParsing | Out-Null
$ready = $true
break
} catch {
if ($server.HasExited) {
Get-Content -Path $stdout, $stderr -ErrorAction SilentlyContinue
throw 'fixture HTTP server exited before it became ready'
}
Start-Sleep -Seconds 1
}
}
if (-not $ready) {
Get-Content -Path $stdout, $stderr -ErrorAction SilentlyContinue
throw 'fixture HTTP server did not become ready'
}
& ./static/install.ps1
& (Join-Path $env:DURABLE_WORKFLOW_INSTALL_DIR 'dw.exe') --version
$downloadDir = Join-Path $env:RUNNER_TEMP 'release\latest\download'
'0000000000000000000000000000000000000000000000000000000000000000 dw-windows-x86_64.exe' |
Set-Content -Path (Join-Path $downloadDir 'SHA256SUMS') -Encoding ascii
$badDir = Join-Path $env:RUNNER_TEMP 'dw-bad'
$env:DURABLE_WORKFLOW_INSTALL_DIR = $badDir
$failed = $false
try {
& ./static/install.ps1
} catch {
$failed = $true
Write-Host $_
}
if (-not $failed) {
throw 'installer accepted a mismatched checksum'
}
if (Test-Path (Join-Path $badDir 'dw.exe')) {
throw 'installer wrote dw.exe after checksum mismatch'
}
} finally {
Stop-Process -Id $server.Id -Force -ErrorAction SilentlyContinue
}