-
Notifications
You must be signed in to change notification settings - Fork 4
197 lines (166 loc) · 7.7 KB
/
release.yml
File metadata and controls
197 lines (166 loc) · 7.7 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
190
191
192
193
194
195
196
197
name: release
on:
push:
tags:
- "v*"
defaults:
run:
working-directory: .
permissions:
contents: write
jobs:
build-and-publish:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Derive release version
shell: pwsh
run: |
$refName = $env:GITHUB_REF_NAME
if ([string]::IsNullOrWhiteSpace($refName)) {
throw "GITHUB_REF_NAME is not available."
}
$candidate = $refName.Split('/')[-1]
if ($candidate.StartsWith('v')) {
$candidate = $candidate.Substring(1)
}
if ($candidate -match '(?<version>\d+(?:\.\d+){1,3})') {
$version = $Matches.version
} else {
$version = $candidate
}
Write-Host "Using release version $version"
Add-Content -Path $env:GITHUB_ENV -Value "RELEASE_VERSION=$version"
- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Restore dependencies
run: |
dotnet restore src/TidyWindow.sln
dotnet restore src/TidyWindow.App/TidyWindow.App.csproj --runtime win-x64 -p:PublishReadyToRun=true
- name: Build solution
shell: pwsh
run: |
if (-not $env:RELEASE_VERSION) {
throw "RELEASE_VERSION is not set."
}
dotnet build src/TidyWindow.sln `
--configuration Release `
--no-restore `
/p:Version=$env:RELEASE_VERSION `
/p:FileVersion=$env:RELEASE_VERSION `
/p:InformationalVersion=$env:RELEASE_VERSION
- name: Publish self-contained package
shell: pwsh
run: |
if (-not $env:RELEASE_VERSION) {
throw "RELEASE_VERSION is not set."
}
$repoRoot = $env:GITHUB_WORKSPACE
if ([string]::IsNullOrWhiteSpace($repoRoot)) {
throw "GITHUB_WORKSPACE is not available."
}
$publishDir = Join-Path $repoRoot "artifacts/publish/win-x64"
dotnet publish src/TidyWindow.App/TidyWindow.App.csproj `
--configuration Release `
--runtime win-x64 `
--self-contained true `
--output $publishDir `
/p:PublishReadyToRun=true `
/p:DebugType=None `
/p:DebugSymbols=false `
--no-build `
/p:Version=$env:RELEASE_VERSION `
/p:FileVersion=$env:RELEASE_VERSION `
/p:InformationalVersion=$env:RELEASE_VERSION
- name: Verify packaged automation assets
shell: pwsh
run: |
$repoRoot = $env:GITHUB_WORKSPACE
if ([string]::IsNullOrWhiteSpace($repoRoot)) {
throw "GITHUB_WORKSPACE is not available."
}
$publishDir = Join-Path $repoRoot "artifacts/publish/win-x64"
if (-not (Test-Path $publishDir)) {
throw "Publish directory not found: $publishDir"
}
$assetRoots = @(
@{ Source = Join-Path $repoRoot "automation"; Target = Join-Path $publishDir "automation"; Label = "automation" },
@{ Source = Join-Path $repoRoot "data"; Target = Join-Path $publishDir "data"; Label = "data" }
)
$missing = [System.Collections.Generic.List[string]]::new()
foreach ($spec in $assetRoots) {
if (-not (Test-Path $spec.Source)) {
throw "Source asset root missing: $($spec.Label)"
}
Get-ChildItem -Path $spec.Source -File -Recurse | ForEach-Object {
$relative = [System.IO.Path]::GetRelativePath($spec.Source, $_.FullName)
$targetPath = Join-Path $spec.Target $relative
if (-not (Test-Path $targetPath)) {
$normalized = ($relative -replace '\\', '/')
$missing.Add("$($spec.Label)/$normalized") | Out-Null
}
}
}
if ($missing.Count -gt 0) {
$details = $missing | ForEach-Object { " - $_" }
throw "Missing packaged assets:`n$($details -join [Environment]::NewLine)"
}
- name: Prepare portable bundle
shell: pwsh
run: |
$repoRoot = $env:GITHUB_WORKSPACE
if ([string]::IsNullOrWhiteSpace($repoRoot)) {
throw "GITHUB_WORKSPACE is not available."
}
$publishDir = Join-Path $repoRoot "artifacts/publish/win-x64"
if (-not (Test-Path $publishDir)) {
throw "Publish directory not found: $publishDir"
}
$versionTag = $env:RELEASE_VERSION
$packageName = "TidyWindow-$versionTag-win-x64"
$staging = "artifacts"
New-Item -ItemType Directory -Force -Path $staging | Out-Null
$portableDir = Join-Path $staging $packageName
New-Item -ItemType Directory -Force -Path $portableDir | Out-Null
Copy-Item -Path (Join-Path $publishDir '*') -Destination $portableDir -Recurse -Force
$zipPath = Join-Path $staging "$packageName.zip"
Compress-Archive -Path (Join-Path $portableDir '*') -DestinationPath $zipPath -Force
Remove-Item $portableDir -Recurse -Force
Get-ChildItem $staging
- name: Install Inno Setup
run: choco install innosetup --no-progress -y
- name: Build installer
shell: pwsh
run: |
$repoRoot = $env:GITHUB_WORKSPACE
if ([string]::IsNullOrWhiteSpace($repoRoot)) {
throw "GITHUB_WORKSPACE is not available."
}
$publishDir = (Resolve-Path (Join-Path $repoRoot "artifacts/publish/win-x64")).Path
$version = $env:RELEASE_VERSION
$iscc = "C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
if (-not (Test-Path $iscc)) {
throw "ISCC.exe not found at $iscc"
}
& $iscc /Qp "/DMyAppVersion=$version" "/DBuildOutput=$publishDir" "installer\TidyWindowInstaller.iss"
$outputDir = "installer\Output"
if (Test-Path $outputDir) {
Copy-Item "$outputDir\*.exe" "artifacts" -Force
} else {
throw "Installer output not found at $outputDir"
}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows-packages
path: artifacts/*
- name: Publish GitHub release asset
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}