-
Notifications
You must be signed in to change notification settings - Fork 6
149 lines (127 loc) · 5.73 KB
/
build-release.yml
File metadata and controls
149 lines (127 loc) · 5.73 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
name: QuickView Build & Release
on:
push:
tags:
- 'v*'
workflow_dispatch: # Allow manual trigger
jobs:
build-and-release:
name: Build & Pack (${{ matrix.platform }})
runs-on: windows-latest
permissions:
contents: write
strategy:
matrix:
# Build for both x64 and ARM64
platform: [x64, ARM64]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive # Recursively fetch submodules like vcpkg
fetch-depth: 0 # Fetch full history to support vcpkg versioning
- name: Install Essential Visual Studio 2026 (v145) Components
shell: pwsh
run: |
# Precision installation based on code analysis:
# 1. Workload.VCTools: Core compiler & MSBuild
# 2. Windows11SDK.22621: DirectX, WinRT, and System headers
# 3. VC.Tools.ARM64: Essential for the ARM64 release matrix
# 4. VC.ATL: Included for safe linking with some vcpkg dependencies
choco install visualstudio2026buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.Windows11SDK.22621 --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.ATL --includeRecommended --passive --norestart --locale en-US"
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
# [Optimization] Restore vcpkg installed artifacts to skip compilation
- name: Restore vcpkg Cache
id: vcpkg-cache
uses: actions/cache@v4
with:
path: |
QuickView/vcpkg_installed
${{ github.workspace }}/third_party/vcpkg/installed
${{ env.LOCALAPPDATA }}/vcpkg/archives
key: vcpkg-${{ matrix.platform }}-${{ hashFiles('QuickView/vcpkg.json') }}
restore-keys: |
vcpkg-${{ matrix.platform }}-
- name: Bootstrap vcpkg
shell: pwsh
run: |
cd third_party/vcpkg
if (-not (Test-Path "vcpkg.exe")) {
./bootstrap-vcpkg.bat
}
- name: Build Project
shell: pwsh
run: |
# Build Release configuration using project's native v145 toolset
msbuild QuickView\QuickView.sln /p:Configuration=Release /p:Platform=${{ matrix.platform }} /m
- name: Prepare Portable Version
shell: pwsh
run: |
$arch = "${{ matrix.platform }}".ToLower()
$archUpper = if ("${{ matrix.platform }}" -eq "x64") { "X64" } else { "ARM64" }
# Extract actual version from the compiled EXE to ensure filename accuracy
$exePath = "QuickView\bin\${{ matrix.platform }}\Release\QuickView.exe"
if (-not (Test-Path $exePath)) { Write-Error "EXE not found"; exit 1 }
$rawVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($exePath).ProductVersion
# Format version (ensure it starts with 'v')
$tag = if ($rawVersion -like "v*") { $rawVersion } else { "v$rawVersion" }
# [Optimization] Trim trailing .0 for 4-digit versions (e.g., 5.3.0.0 -> v5.3.0)
# to match semantic versioning and ensure update mechanism compatibility.
if ($tag -match '^v\d+\.\d+\.\d+\.0$') {
$tag = $tag.Substring(0, $tag.LastIndexOf('.'))
}
echo "DETECTED_TAG=$tag" >> $env:GITHUB_ENV
echo "Detected version from EXE: $tag"
# Create temporary staging dir
New-Item -ItemType Directory -Force "Release/$arch"
New-Item -ItemType Directory -Force "Release/dist"
# Copy exe
Copy-Item $exePath "Release/$arch/QuickView.exe"
# Pack portable version Zip
$zipName = "QuickView_${tag}_${archUpper}.zip"
Compress-Archive -Path "Release/$arch/QuickView.exe" -DestinationPath "Release/dist/$zipName" -Force
- name: Build Inno Setup Installer
shell: pwsh
run: |
$arch = "${{ matrix.platform }}".ToLower()
$archUpper = if ("${{ matrix.platform }}" -eq "x64") { "X64" } else { "ARM64" }
$tag = "${{ env.DETECTED_TAG }}"
$version = $tag.TrimStart('v')
# Invoke ISCC, Output to Release/dist directly
$outputName = "QuickView_Installer_${tag}_${archUpper}"
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DMyAppVersion=$version /DAppArch=$arch /DOutputName=$outputName /O"Release\dist" installer\QuickView.iss
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
# Use a unique name per matrix job to avoid conflicts in v4
name: QuickView-Staging-${{ matrix.platform }}
path: Release/dist/*
# New job to merge everything into one single "4-file" distribution
publish-final:
needs: build-and-release
runs-on: windows-latest
name: Consolidate & Release
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: QuickView-Staging-*
path: final-dist
merge-multiple: true # This flattens the structure!
- name: Upload Consolidated Artifact
uses: actions/upload-artifact@v4
with:
name: QuickView-Standard-Distribution
path: final-dist/*
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: final-dist/*
draft: true # Create as draft for manual review
generate_release_notes: true # Automatically summarize commits
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}