Build OpenSSL on Windows #62
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build OpenSSL on Windows | |
on: | |
workflow_dispatch: | |
env: | |
REPO_URL: https://github.com/openssl/openssl.git | |
REPO_BRANCH: master # 默认最新版 | |
major: 3 | |
minor: 5 | |
patch: 0 | |
instctx: openssl | |
instbuild32: C:\OpenSSL_build_x32 | |
instbuild64: C:\OpenSSL_build_x64 | |
instlicense: ../openssl/LICENSE.txt | |
TZ: China Standard Time | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@main # 检出代码 | |
- name: Install dependencies | |
run: | | |
choco install strawberryperl | |
choco install nasm | |
choco install make | |
# 安装其他可能需要的依赖,如VC++ Build Tools等,如果需要可以添加 | |
- name: add NASM to path | |
shell: cmd | |
run: | | |
set path="C:\Program Files\NASM" # 将NASM添加进环境变量中 | |
- name: Clone source code | |
run: | | |
git clone $env:REPO_URL -b $env:REPO_BRANCH | |
- name: Create x64 and x32 Folder | |
run: | | |
mkdir openssl_x64 | |
mkdir openssl_x32 | |
- name: Configure OpenSSL x64 | |
run: | | |
cd openssl_x64 # 假设你的OpenSSL源代码在仓库的openssl目录下 | |
perl ..\openssl\Configure VC-WIN64A no-asm --prefix=$env:instbuild64 # 根据你的需求配置OpenSSL | |
- name: Configure OpenSSL x32 | |
run: | | |
cd openssl_x32 # 假设你的OpenSSL源代码在仓库的openssl目录下 | |
perl ..\openssl\Configure VC-WIN32 no-asm --prefix=$env:instbuild32 # 根据你的需求配置OpenSSL | |
- name: Build OpenSSL x64 | |
shell: cmd | |
run: | | |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" | |
cd openssl_x64 | |
nmake /S | |
nmake /S install | |
- name: Build OpenSSL x32 | |
shell: cmd | |
run: | | |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsamd64_x86.bat" | |
cd openssl_x32 | |
nmake /S | |
nmake /S install | |
- name: Build installer | |
shell: cmd | |
run: | | |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" | |
cd windows-installer | |
nmake /S INSTMAJOR=$env:major INSTMINOR=$env:minor INSTPATCH=$env:patch INSTCTX=$env:instctx INSTBUILD32=$env:instbuild32 INSTBUILD64=$env:instbuild64 INSTLICENSE=$env:instlicense | |
- name: Archive artifacts | |
uses: actions/upload-artifact@main | |
with: | |
name: openssl-windows_x64 | |
path: ${{ env.instbuild64 }} # 上传编译好的OpenSSL文件作为构建产物 | |
- name: Archive artifacts | |
uses: actions/upload-artifact@main | |
with: | |
name: openssl-windows_x32 | |
path: ${{ env.instbuild32 }} # 上传编译好的OpenSSL文件作为构建产物 | |
- name: Upload installer as artifact | |
uses: actions/upload-artifact@main | |
with: | |
name: openssl-installer | |
path: windows-installer/openssl*.exe | |
- name: Generate release tag | |
id: tag | |
run: | | |
Set-TimeZone -ID “$env:TZ” | |
cd C:\ | |
7z a openssl-for-windows_x64.zip .\OpenSSL_build_x64\ | |
7z a openssl-for-windows_x32.zip .\OpenSSL_build_x32\ | |
echo "tag-name=$(date +"%Y.%m.%d-%H%M")" >> $env:GITHUB_OUTPUT | |
echo "status=success" >> $env:GITHUB_OUTPUT | |
- name: Upload firmware to release | |
if: steps.tag.outputs.status == 'success' | |
uses: softprops/action-gh-release@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag.outputs.tag-name }} | |
files: | | |
C:\openssl-for-windows*.zip | |
windows-installer/openssl*.exe |