Repository navigation
131 lines (121 loc) · 5.8 KB
/
Copy pathwindows-msi.yml
File metadata and controls
131 lines (121 loc) · 5.8 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
name: Windows MSI
on:
workflow_call:
inputs:
version:
required: true
type: string
commit:
required: true
type: string
archive_sha256:
required: true
type: string
permissions:
contents: read
jobs:
build:
runs-on: windows-2022
timeout-minutes: 30
env:
VERSION: ${{ inputs.version }}
ARCHIVE_SHA256: ${{ inputs.archive_sha256 }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.commit }}
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-archives
path: ${{ runner.temp }}/release-archives
- name: Confirm WiX 7 EULA acceptance
shell: pwsh
env:
WIX7_EULA_ACCEPTED: ${{ vars.WIX7_EULA_ACCEPTED }}
run: |
if ($env:WIX7_EULA_ACCEPTED -cne 'true') {
throw 'Set WIX7_EULA_ACCEPTED=true only after the repository owner verifies the WiX 7 OSMF terms and accepts the wix7 EULA.'
}
- name: Verify exact archive from this run
shell: pwsh
run: |
if ($env:ARCHIVE_SHA256 -cnotmatch '^[0-9a-f]{64}$') {
throw 'invalid archive checksum'
}
$archive = Join-Path $env:RUNNER_TEMP "release-archives/d2-$env:VERSION-windows-amd64.tar.gz"
$actual = (Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash.ToLowerInvariant()
if ($actual -cne $env:ARCHIVE_SHA256) {
throw "archive SHA-256 is $actual, expected $env:ARCHIVE_SHA256"
}
- name: Install pinned WiX 7 toolset
shell: pwsh
run: |
dotnet tool install --tool-path "$env:RUNNER_TEMP\wix" wix --version 7.0.1
"$env:RUNNER_TEMP\wix" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Build and verify both MSIs
shell: pwsh
env:
WIX7_EULA_ACCEPTED: ${{ vars.WIX7_EULA_ACCEPTED }}
run: |
$inputs = @{
Version = $env:VERSION
ArchivePath = "$env:RUNNER_TEMP\release-archives\d2-$env:VERSION-windows-amd64.tar.gz"
OutputDirectory = "$env:RUNNER_TEMP\windows-msi"
}
./ci/release/windows/build.ps1 @inputs
./ci/release/windows/build.ps1 @inputs -CurrentUser
- name: Verify upgrades and uninstalls for both scopes
shell: pwsh
run: |
# Windows Server blocks unmanaged user installs by default. Exercise desktop
# behavior on this disposable runner with the test account still unelevated.
$policy = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer'
if (-not (Test-Path $policy)) { New-Item -Path $policy -Force | Out-Null }
New-ItemProperty -Path $policy -Name DisableMSI -PropertyType DWord -Value 0 -Force | Out-Null
# The standard account needs read access to its installers and test script.
$stage = New-Item -ItemType Directory -Path "$env:ProgramFiles\D2 MSI test"
Copy-Item -LiteralPath ./ci/release/windows/test-install.ps1 -Destination $stage
Copy-Item -LiteralPath ./ci/release/windows/d2.ico -Destination $stage
# Use a recognizable older payload and distinct MSI product codes. PR packages use version 0.0.0.
Set-Content -LiteralPath "$stage\d2.exe" -Value 'upgrade fixture'
Set-Content -LiteralPath "$stage\THIRD_PARTY_NOTICES.txt" -Value 'upgrade fixture'
Push-Location $stage
try {
foreach ($suffix in '', '-user') {
wix build -acceptEula wix7 -arch x64 -d D2Version=0.0.0 -o "previous$suffix.msi" `
"$env:GITHUB_WORKSPACE\ci\release\windows\d2$suffix.wxs"
if ($LASTEXITCODE -ne 0) { throw "Building the upgrade fixture failed" }
Copy-Item "$env:RUNNER_TEMP\windows-msi\d2-$env:VERSION-windows-amd64$suffix.msi" "d2$suffix.msi"
}
} finally {
Pop-Location
}
$password = ConvertTo-SecureString ("T1!" + [guid]::NewGuid().ToString("N")) -AsPlainText -Force
$user = New-LocalUser -Name 'D2MsiTest' -Password $password
try {
$users = Get-LocalGroup -SID 'S-1-5-32-545'
if ($user.SID -notin (Get-LocalGroupMember -Group $users).SID) {
Add-LocalGroupMember -Group $users -Member $user
}
$credential = [pscredential]::new("$env:COMPUTERNAME\$($user.Name)", $password)
$arguments = "-NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -File `"$stage\test-install.ps1`" -Scope User -Version $env:VERSION"
# Give msiexec the test user's profile and temp directory.
$test = Start-Process -FilePath (Get-Process -Id $PID).Path -ArgumentList $arguments `
-Credential $credential -LoadUserProfile -UseNewEnvironment -WorkingDirectory $stage -Wait -PassThru `
-RedirectStandardOutput "$env:RUNNER_TEMP\d2-user.out" -RedirectStandardError "$env:RUNNER_TEMP\d2-user.err"
Get-Content -LiteralPath "$env:RUNNER_TEMP\d2-user.out", "$env:RUNNER_TEMP\d2-user.err"
if ($test.ExitCode -ne 0) { throw "Standard-user test exited with $($test.ExitCode)" }
& "$stage\test-install.ps1" -Scope Machine -Version $env:VERSION
} finally {
Remove-LocalUser -Name $user.Name
Remove-Item -LiteralPath $stage -Recurse -Force
}
- name: Upload verified MSI artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: windows-msi
path: ${{ runner.temp }}/windows-msi/*.msi
if-no-files-found: error
compression-level: 0
retention-days: 30