Skip to content

Commit d1d1a63

Browse files
committed
fix: openssl install
1 parent 43a476b commit d1d1a63

4 files changed

Lines changed: 106 additions & 209 deletions

File tree

.github/workflows/windows-msvc.yml

Lines changed: 71 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,24 @@ jobs:
1313
os: windows-2022
1414
build_type: Release
1515
compiler_type: msvc2019_64
16+
build_arch: x64
1617
msvc_arch: x64
1718
qt_arch: win64_msvc2019_64
1819
qt_version: 5.15.2
1920
qt_target: desktop
20-
openssl_arch: x64
2121
openssl_root: C:\Program Files\OpenSSL-Win64
22-
bonjour_file: BonjourPSSetup.exe
23-
vcredist_file: vc_redist.x64.exe
24-
artifact_suffix: win64
2522
cmake_gen: Visual Studio 17 2022
26-
vcpkg_triplet: x64-windows
23+
vcpkg_triplet: x64-windows-release
2724
- name: win32_msvc
2825
os: windows-2022
2926
build_type: Release
3027
compiler_type: msvc2019
28+
build_arch: x86
3129
msvc_arch: Win32
3230
qt_arch: win32_msvc2019
3331
qt_version: 5.15.2
3432
qt_target: desktop
35-
openssl_arch: x86
3633
openssl_root: C:\Program Files (x86)\OpenSSL-Win32
37-
bonjour_file: BonjourPSSetup.exe
38-
vcredist_file: vc_redist.x86.exe
39-
artifact_suffix: win32
4034
cmake_gen: Visual Studio 17 2022
4135
vcpkg_triplet: x86-windows
4236
runs-on: ${{ matrix.os }}
@@ -49,95 +43,57 @@ jobs:
4943
OPENSSL_CRYPTO_LIBRARY: ${{ matrix.openssl_root }}\lib
5044
steps:
5145
# Cache OpenSSL to speed up builds
52-
- name: '⚙️ Cache OpenSSL'
53-
id: cache-openssl
54-
uses: actions/cache@v3
55-
with:
56-
path: ${{ matrix.openssl_root }}
57-
key: Windows-OpenSSL-${{ matrix.openssl_arch }}-3.2.6
58-
59-
# Install OpenSSL 3.2.6 for both x86 and x64 architectures
60-
- name: Install OpenSSL ${{ matrix.openssl_arch }}
61-
if: steps.cache-openssl.outputs.cache-hit != 'true'
62-
run: |
63-
choco install openssl --version 3.2.6 --allow-downgrade -y
64-
# shell: pwsh
65-
# run: |
66-
# $arch = "${{ matrix.openssl_arch }}"
67-
# $version = "3_2_6"
68-
# $opensslUrl = if ($arch -eq "x64") {
69-
# "https://slproweb.com/download/Win64OpenSSL-${version}.msi"
70-
# } else {
71-
# "https://slproweb.com/download/Win32OpenSSL-${version}.msi"
72-
# }
73-
# $installerPath = "$env:TEMP\OpenSSL-${version}_${arch}.msi"
74-
# $installDir = "${{ matrix.openssl_root }}"
75-
76-
# Write-Host "Downloading OpenSSL ${version} for ${arch}..."
77-
# Write-Host "URL: $opensslUrl"
78-
# Invoke-WebRequest -Uri $opensslUrl -OutFile $installerPath -UseBasicParsing
79-
80-
# Write-Host "Downloaded file size: $(Get-Item $installerPath).Length bytes"
81-
82-
# Write-Host "Installing OpenSSL ${version} for ${arch}..."
83-
# Write-Host "Target directory: $installDir"
84-
85-
# # Create target directory if it doesn't exist
86-
# if (-not (Test-Path $installDir)) {
87-
# New-Item -ItemType Directory -Path $installDir -Force | Out-Null
88-
# Write-Host "Created directory: $installDir"
89-
# }
90-
91-
# $installArgs = @(
92-
# "/i",
93-
# "`"$installerPath`"",
94-
# "/quiet",
95-
# "INSTALLDIR=`"$installDir`"",
96-
# "/norestart",
97-
# "/L*v", # Enable verbose logging
98-
# "`"$env:TEMP\openssl_install.log`""
99-
# )
100-
101-
# Write-Host "Running: msiexec $($installArgs -join ' ')"
102-
# $process = Start-Process msiexec -ArgumentList $installArgs -Wait -PassThru
103-
104-
# Write-Host "MSI install exit code: $($process.ExitCode)"
105-
106-
# # Wait for installation to complete
107-
# Start-Sleep -Seconds 5
108-
109-
# # Check if installation succeeded
110-
# $opensslExe = "$installDir\bin\openssl.exe"
111-
# Write-Host "Checking for OpenSSL at: $opensslExe"
112-
113-
# if (Test-Path $opensslExe) {
114-
# Write-Host "✓ OpenSSL installed successfully"
115-
# & $opensslExe version
116-
# } else {
117-
# Write-Host "✗ OpenSSL not found at expected location"
118-
# Write-Host "Listing install directory contents:"
119-
# Get-ChildItem -Path $installDir -Recurse -ErrorAction SilentlyContinue | Select-Object -First 20 FullName
120-
# Write-Host "Install log (last 50 lines):"
121-
# Get-Content "$env:TEMP\openssl_install.log" -Tail 50 -ErrorAction SilentlyContinue
122-
# exit 1
123-
# }
124-
125-
# Write-Host "OpenSSL ${version} (${arch}) installation completed"
46+
# - name: '⚙️ Cache OpenSSL'
47+
# id: cache-openssl
48+
# uses: actions/cache@v3
49+
# with:
50+
# path: ${{ matrix.openssl_root }}
51+
# key: Windows-OpenSSL-${{ matrix.build_arch }}-3.2.6
52+
53+
# # Install OpenSSL 3.2.6 for both x86 and x64 architectures
54+
# - name: Install OpenSSL ${{ matrix.build_arch }}
55+
# shell: pwsh
56+
# run: |
57+
# $arch = "${{ matrix.build_arch }}"
58+
# $version = "3_2_6"
59+
# $opensslUrl = if ($arch -eq "x64") {
60+
# "https://slproweb.com/download/Win64OpenSSL-${version}.msi"
61+
# } else {
62+
# "https://slproweb.com/download/Win32OpenSSL-${version}.msi"
63+
# }
64+
# $installerPath = "$env:TEMP\OpenSSL-${version}_${arch}.msi"
65+
# $installDir = "${{ matrix.openssl_root }}"
66+
67+
# # 下载安装包
68+
# Invoke-WebRequest -Uri $opensslUrl -OutFile $installerPath
69+
70+
# # 静默安装到指定目录并等待完成
71+
# Start-Process msiexec.exe -ArgumentList "/i $installerPath /quiet /qn INSTALLDIR=$installDir"
72+
73+
# # 等待安装完全完成
74+
# Start-Sleep -Seconds 10
75+
76+
# - name: Verify OpenSSL installation
77+
# run: |
78+
# openssl version
79+
# echo "OPENSSL_ROOT_DIR is: $env:OPENSSL_ROOT_DIR"
12680

12781

128-
- name: Verify OpenSSL cached
129-
if: steps.cache-openssl.outputs.cache-hit == 'true'
130-
shell: pwsh
131-
run: |
132-
Write-Host "Using cached OpenSSL:"
133-
& "${{ matrix.openssl_root }}\bin\openssl.exe" version
82+
# - name: Verify OpenSSL cached
83+
# if: steps.cache-openssl.outputs.cache-hit == 'true'
84+
# shell: pwsh
85+
# run: |
86+
# Write-Host "Using cached OpenSSL:"
87+
# & "${{ matrix.openssl_root }}\bin\openssl.exe" version
13488

13589
- name: '⚙️ Cache Qt'
13690
id: cache-qt
13791
uses: actions/cache@v3
13892
with:
139-
path: ..\Qt
140-
key: Windows-QtCache-${{ env.QT_VERSION }}
93+
path: ${{ env.HOME }}/Qt
94+
key: Windows-${{ matrix.os }}-Qt-${{ env.QT_VERSION }}-${{ matrix.qt_arch }}
95+
restore-keys: |
96+
Windows-${{ matrix.os }}-Qt-${{ env.QT_VERSION }}-
14197
14298
- name: Install Qt ${{ env.QT_VERSION }}
14399
uses: jurplel/install-qt-action@v3
@@ -147,28 +103,8 @@ jobs:
147103
target: ${{ matrix.qt_target }}
148104
arch: ${{ matrix.qt_arch }}
149105
# modules: 'qt5compat'
150-
# cached: 'false'
151106
cached: ${{ steps.cache-qt.outputs.cache-hit }}
152107

153-
- name: '⚙️ Cache vcpkg'
154-
id: cache-vcpkg
155-
uses: actions/cache@v3
156-
with:
157-
path: |
158-
${{ github.workspace }}/vcpkg
159-
~/.vcpkg
160-
key: Windows-vcpkg-${{ matrix.vcpkg_triplet }}-${{ hashFiles('**/vcpkg.json') }}
161-
restore-keys: |
162-
Windows-vcpkg-${{ matrix.vcpkg_triplet }}-
163-
164-
- name: Install vcpkg
165-
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
166-
shell: pwsh
167-
run: |
168-
git clone https://github.com/Microsoft/vcpkg.git
169-
.\vcpkg\bootstrap-vcpkg.bat -disableMetrics
170-
echo "VCPKG_INSTALLED_DIR=$env:GITHUB_WORKSPACE\vcpkg" >> $env:GITHUB_ENV
171-
172108
# Use CMake 3.31.x for better OpenSSL 3.x compatibility while supporting VS 2019
173109
- name: Setup cmake
174110
uses: lukka/get-cmake@latest
@@ -182,14 +118,23 @@ jobs:
182118
path: source
183119
fetch-depth: 0
184120

121+
- name: Build and cache vcpkg
122+
id: vcpkg
123+
uses: johnwason/vcpkg-action@v7
124+
with:
125+
pkgs: zlib openssl
126+
# manifest-dir: ${{ github.workspace }}\source
127+
extra-args: --classic --host-triplet=${{matrix.vcpkg_triplet}}
128+
triplet: ${{matrix.vcpkg_triplet}}
129+
token: ${{ github.token }}
130+
revision: master
131+
185132
- name: msvc-build
186133
id: build
187134
shell: cmd
188135
env:
136+
build_arch: ${{ matrix.build_arch }}
189137
vc_arch: ${{ matrix.msvc_arch }}
190-
openssl_arch: ${{ matrix.openssl_arch }}
191-
bonjour_file: ${{ matrix.bonjour_file }}
192-
vcredist_file: ${{ matrix.vcredist_file }}
193138
cmake_gen: ${{ matrix.cmake_gen }}
194139
COO_PROJECT: dde-cooperation
195140
DT_PROJECT: data-transfer
@@ -202,7 +147,7 @@ jobs:
202147
exit /b 1
203148
)
204149
echo Using Visual Studio 2022 at: %VS2022_PATH%
205-
call "%VS2022_PATH%\VC\Auxiliary\Build\vcvarsall.bat" %vc_arch%
150+
call "%VS2022_PATH%\VC\Auxiliary\Build\vcvarsall.bat" %build_arch%
206151
207152
REM Initialize OpenSSL environment (based on start.bat logic)
208153
echo ============== OpenSSL Initialization ==============
@@ -234,28 +179,24 @@ jobs:
234179
echo Using vcpkg triplet: ${{ matrix.vcpkg_triplet }}
235180
echo Vcpkg toolchain file: %GITHUB_WORKSPACE%\vcpkg\scripts\buildsystems\vcpkg.cmake
236181
237-
if exist "%GITHUB_WORKSPACE%\source\CMakeLists.txt" (
238-
echo Found CMakeLists.txt in source directory
239-
cmake -G "%cmake_gen%" -A %vc_arch% -D CMAKE_BUILD_TYPE=%BUILD_TYPE% ^
240-
-D CMAKE_TOOLCHAIN_FILE="%GITHUB_WORKSPACE%\vcpkg\scripts\buildsystems\vcpkg.cmake" ^
241-
-D VCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} ^
242-
-D APP_VERSION="${{ github.ref_name }}" "%GITHUB_WORKSPACE%\source"
243-
) else (
244-
echo ERROR: CMakeLists.txt not found in source directory
245-
dir "%GITHUB_WORKSPACE%\source"
246-
exit /b 1
247-
)
182+
cmake -G "%cmake_gen%" -A %vc_arch% -D CMAKE_BUILD_TYPE=%BUILD_TYPE% ^
183+
-D CMAKE_TOOLCHAIN_FILE="%GITHUB_WORKSPACE%\vcpkg\scripts\buildsystems\vcpkg.cmake" ^
184+
-D VCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} ^
185+
-D APP_VERSION="${{ github.ref_name }}" "%GITHUB_WORKSPACE%\source"
186+
248187
cmake --build . --config %BUILD_TYPE%
249188
250189
echo ------------copy files to output directory------------
251190
252191
REM Set architecture-specific file names
253-
if "%openssl_arch%"=="x86" (
192+
if "%build_arch%"=="x86" (
254193
set OPENSSL_CRYPTO=libcrypto-3.dll
255194
set OPENSSL_SSL=libssl-3.dll
195+
set BONJOUR_FILE=BonjourPSSetup.exe
256196
) else (
257197
set OPENSSL_CRYPTO=libcrypto-3-x64.dll
258198
set OPENSSL_SSL=libssl-3-x64.dll
199+
set BONJOUR_FILE=BonjourPSSetup.exe
259200
)
260201
261202
if exist output\%BUILD_TYPE% (
@@ -264,32 +205,11 @@ jobs:
264205
265206
copy "%OPENSSL_ROOT_DIR%\%OPENSSL_CRYPTO%" output\%COO_PROJECT%\%BUILD_TYPE%\ > NUL
266207
copy "%OPENSSL_ROOT_DIR%\%OPENSSL_SSL%" output\%COO_PROJECT%\%BUILD_TYPE%\ > NUL
267-
268-
mkdir installer-inno\%COO_PROJECT%
269-
copy "%BONJOUR_SDK%\%bonjour_file%" installer-inno\%COO_PROJECT%\ > NUL
270-
REM Copy VC Redist from dependencies directory if it exists there
271-
if exist "%BONJOUR_SDK%\%vcredist_file%" (
272-
copy "%BONJOUR_SDK%\%vcredist_file%" installer-inno\%COO_PROJECT%\ > NUL
273-
)
274-
REM If VC Redist was copied to output directory, move it
275-
if exist output\%COO_PROJECT%\%BUILD_TYPE%\%vcredist_file% (
276-
move output\%COO_PROJECT%\%BUILD_TYPE%\%vcredist_file% installer-inno\%COO_PROJECT%\ > NUL
277-
)
208+
copy "%B_BONJOUR%\%BONJOUR_FILE%" output\%COO_PROJECT%\%B_BUILD_TYPE%\ > NUL
278209
279210
copy output\%BUILD_TYPE%\quazip* output\%DT_PROJECT%\%BUILD_TYPE%\ > NUL
280-
281211
copy "%OPENSSL_ROOT_DIR%\%OPENSSL_CRYPTO%" output\%DT_PROJECT%\%BUILD_TYPE%\ > NUL
282212
copy "%OPENSSL_ROOT_DIR%\%OPENSSL_SSL%" output\%DT_PROJECT%\%BUILD_TYPE%\ > NUL
283-
mkdir installer-inno\%DT_PROJECT%
284-
copy "%BONJOUR_SDK%\%bonjour_file%" installer-inno\%DT_PROJECT%\ > NUL
285-
REM Copy VC Redist from dependencies directory if it exists there
286-
if exist "%BONJOUR_SDK%\%vcredist_file%" (
287-
copy "%BONJOUR_SDK%\%vcredist_file%" installer-inno\%DT_PROJECT%\ > NUL
288-
)
289-
REM If VC Redist was copied to output directory, move it
290-
if exist output\%DT_PROJECT%\%BUILD_TYPE%\%vcredist_file% (
291-
move output\%DT_PROJECT%\%BUILD_TYPE%\%vcredist_file% installer-inno\%DT_PROJECT%\ > NUL
292-
)
293213
) else (
294214
echo Remember to copy supporting binaries and configuration files!
295215
)
@@ -306,19 +226,12 @@ jobs:
306226
with:
307227
filepath: build/dde-cooperation-setup.iss
308228

309-
- name: Make Installer Directories
310-
run: |
311-
move build/installer-inno/deepin-cooperation-* build/installer-inno/dde-cooperation/ > NUL
312-
powershell -Command "Compress-Archive -Path build/installer-inno/dde-cooperation/* -DestinationPath build/installer-inno/dde-cooperation.zip"
313-
move build/installer-inno/deepin-datatransfer-* build/installer-inno/data-transfer/ > NUL
314-
powershell -Command "Compress-Archive -Path build/installer-inno/data-transfer/* -DestinationPath build/installer-inno/deepin-data-transfer.zip"
315-
316-
- name: Create Release
229+
- name: Upload to Release
317230
uses: softprops/action-gh-release@v1
318231
if: startsWith(github.ref, 'refs/tags/')
319232
env:
320233
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
321234
with:
322-
files: build/installer-inno/*.zip
235+
files: build/installer-inno/*.exe
323236
generate_release_notes: true
324237
draft: true

0 commit comments

Comments
 (0)