Skip to content

Commit 565908f

Browse files
Fix Windows OpenSSL build issues
- Install OpenSSL via vcpkg in Windows build action - Set OPENSSL_NO_VENDOR=1 to prevent building from source - Set OPENSSL_STATIC=1 for static linking - Add Windows-specific build step in build_cli_target action - Configure OpenSSL environment variables for all CLI tools builds on Windows This resolves the Perl module dependency issues when building OpenSSL from source on Windows runners.
1 parent 924f4d0 commit 565908f

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

.github/actions/build_cli_target/action.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ runs:
2626

2727
- name: Build CLI ${{ inputs.target }} target
2828
uses: houseabsolute/[email protected]
29-
# Cross-rs does not directly support cross compilation with macOS targets
30-
if: ${{ !contains(inputs.target, 'darwin') }}
29+
# Cross-rs does not directly support cross compilation with macOS and Windows targets
30+
if: ${{ !contains(inputs.target, 'darwin') && !contains(inputs.target, 'windows') }}
3131
with:
3232
command: build
3333
target: ${{ inputs.target }}
@@ -43,6 +43,16 @@ runs:
4343
run: |
4444
cargo build -p trunk-analytics-cli --profile=${{ inputs.profile }} --target=${{ inputs.target }} ${{ (inputs.force-sentry-dev == 'true' && '--features force-sentry-env-dev') || '' }}
4545
46+
- name: Build CLI ${{ inputs.target }} target
47+
shell: bash
48+
if: ${{ contains(inputs.target, 'windows') }}
49+
# NOTE: DO NOT BUILD WORKSPACE OTHERWISE THE CLI MAY BE LINKED TO UNNECESSARY LIBRARIES
50+
run: |
51+
cargo build -p trunk-analytics-cli --profile=${{ inputs.profile }} --target=${{ inputs.target }} ${{ (inputs.force-sentry-dev == 'true' && '--features force-sentry-env-dev') || '' }}
52+
env:
53+
OPENSSL_STATIC: 1
54+
OPENSSL_NO_VENDOR: 1
55+
4656
- name: Create binary with debug info
4757
shell: bash
4858
run: |

.github/actions/build_cli_tools/action.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ runs:
6767
else
6868
cross build -p bundle --profile=release-with-debug --target=${{ inputs.target }} --features build-binary
6969
fi
70+
env:
71+
OPENSSL_STATIC: ${{ contains(inputs.os-name, 'windows') && '1' || '' }}
72+
OPENSSL_NO_VENDOR: ${{ contains(inputs.os-name, 'windows') && '1' || '' }}
7073

7174
- name: Build XCResult CLI
7275
shell: bash
@@ -76,6 +79,9 @@ runs:
7679
else
7780
cross build -p xcresult --profile=release-with-debug --target=${{ inputs.target }}
7881
fi
82+
env:
83+
OPENSSL_STATIC: ${{ contains(inputs.os-name, 'windows') && '1' || '' }}
84+
OPENSSL_NO_VENDOR: ${{ contains(inputs.os-name, 'windows') && '1' || '' }}
7985

8086
- name: Build Codeowners CLI
8187
shell: bash
@@ -85,3 +91,6 @@ runs:
8591
else
8692
cross build -p codeowners --profile=release-with-debug --target=${{ inputs.target }}
8793
fi
94+
env:
95+
OPENSSL_STATIC: ${{ contains(inputs.os-name, 'windows') && '1' || '' }}
96+
OPENSSL_NO_VENDOR: ${{ contains(inputs.os-name, 'windows') && '1' || '' }}

.github/actions/build_cli_windows_target/action.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,24 @@ inputs:
1313
runs:
1414
using: composite
1515
steps:
16+
- name: Install OpenSSL with vcpkg
17+
shell: pwsh
18+
run: |
19+
vcpkg install openssl:x64-windows-static
20+
echo "OPENSSL_DIR=$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows-static" >> $env:GITHUB_ENV
21+
echo "OPENSSL_STATIC=1" >> $env:GITHUB_ENV
22+
echo "OPENSSL_NO_VENDOR=1" >> $env:GITHUB_ENV
23+
1624
- name: Build CLI ${{ inputs.target }} target
1725
uses: ./.github/actions/build_cli_target
1826
with:
1927
target: ${{ inputs.target }}
2028
profile: ${{ inputs.profile }}
2129
force-sentry-dev: ${{ inputs.force-sentry-dev }}
30+
env:
31+
OPENSSL_DIR: ${{ env.OPENSSL_DIR }}
32+
OPENSSL_STATIC: 1
33+
OPENSSL_NO_VENDOR: 1
2234

2335
- name: Check binary exists
2436
shell: pwsh
@@ -29,4 +41,3 @@ runs:
2941
exit 1
3042
}
3143
Get-Item $binaryPath | Select-Object FullName, Length
32-

0 commit comments

Comments
 (0)