Repository navigation
103 lines (86 loc) · 3.02 KB
/
Copy pathwindows-installer.yml
File metadata and controls
103 lines (86 loc) · 3.02 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
name: Windows Installer
on:
workflow_dispatch:
inputs:
release_tag:
description: GitHub Release tag to upload the Windows installer to
required: true
default: v1.1.0
upload_to_release:
description: Upload the installer to the selected GitHub Release
required: true
default: 'true'
type: choice
options:
- 'true'
- 'false'
permissions:
contents: write
jobs:
windows-installer:
name: Build Windows Installer
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Inno Setup
run: choco install innosetup --yes --no-progress
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install flutter_distributor
run: dart pub global activate flutter_distributor
- name: Add Pub cache to PATH
shell: pwsh
run: |
"$env:PUB_CACHE\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Get dependencies
run: flutter pub get
- name: Build Windows installer
run: flutter_distributor release --name release --jobs windows-exe
- name: Smoke test Windows installer
shell: pwsh
run: |
$installer = Get-ChildItem -Path dist -Recurse -Filter *.exe | Select-Object -First 1
if (-not $installer) {
throw "No Windows installer was produced."
}
$installDir = Join-Path $env:RUNNER_TEMP "patterns-smoke"
$installLog = Join-Path $env:RUNNER_TEMP "patterns-install.log"
$installArgs = @(
"/VERYSILENT",
"/SUPPRESSMSGBOXES",
"/NORESTART",
"/DIR=$installDir",
"/LOG=$installLog"
)
$install = Start-Process -FilePath $installer.FullName -ArgumentList $installArgs -Wait -PassThru
if ($install.ExitCode -ne 0) {
if (Test-Path $installLog) {
Get-Content $installLog
}
throw "Installer failed with exit code $($install.ExitCode)."
}
$app = Join-Path $installDir "patterns.exe"
if (-not (Test-Path $app)) {
throw "Installed executable was not found at $app."
}
$process = Start-Process -FilePath $app -WorkingDirectory $installDir -PassThru
Start-Sleep -Seconds 8
if ($process.HasExited) {
throw "Installed app exited during smoke test with code $($process.ExitCode)."
}
Stop-Process -Id $process.Id -Force
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: patterns-windows-installer
path: dist/**/*.exe
- name: Upload installer to GitHub Release
if: inputs.upload_to_release == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ inputs.release_tag }}
files: dist/**/*.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}