add static build #36
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
# https://github.com/sqlitebrowser/sqlitebrowser/wiki/Win64-setup-%E2%80%94-Compiling-SQLCipher | |
name: Build - Windows | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
paths: | |
- ".github/workflows/build-windows.yml" | |
jobs: | |
build: | |
name: Build | |
runs-on: ${{ matrix.os }} | |
env: | |
VCPKG_DEFAULT_TRIPLET: ${{ matrix.arch == 'Win32' && 'x86' || matrix.arch == 'Win64' && 'x64' }}-windows-static | |
SQLCIPHER_NMAKE_VARS: USE_AMALGAMATION=1 NO_TCL=1 SQLITE3DLL=sqlcipher.dll SQLITE3LIB=sqlcipher.lib SQLITE3EXE=sqlcipher.exe | |
SQLCIPHER_NMAKE_OPT_FEATURE_FLAGS: -DSQLITE_TEMP_STORE=2 -DSQLITE_HAS_CODEC=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_STAT4=1 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_RTREE=1 -DSQLCIPHER_CRYPTO_OPENSSL=1 -DSQLITE_MAX_ATTACHED=125 | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-2022] | |
arch: ["Win32", "Win64"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup OpenSSL 1.1.1 for Win32 | |
if: matrix.arch == 'Win32' | |
# https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1 & Win32OpenSSL.exe /? & Win32OpenSSL.exe /LOG="a.log" /SAVEINF="inf.inf" | |
run: | | |
$url = "https://slproweb.com/download/Win32OpenSSL-1_1_1w.exe" | |
$path = "C:\temp\Win32OpenSSL.exe" | |
Invoke-WebRequest -Uri $url -OutFile $path | |
Start-Process -FilePath $path -ArgumentList "/silent","/sp-","/suppressmsgboxes","/DIR=`"$env:ProgramFiles\OpenSSL`"","/TASKS=copytobin" -Wait | |
- name: Setup MSVC | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: ${{ matrix.arch == 'Win32' && 'amd64_x86' || matrix.arch == 'Win64' && 'amd64'}} | |
- name: Setup vcpkg cache | |
# https://learn.microsoft.com/zh-cn/vcpkg/users/binarycaching#gha | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
- name: Setup OpenSSL (static) | |
# https://blog.hamaluik.ca/posts/statically-linking-sqlcipher-on-windows | |
run: | | |
vcpkg install openssl:${{ env.VCPKG_DEFAULT_TRIPLET }} --binarysource="clear;x-gha,readwrite" | |
- name: Init folders | |
continue-on-error: true | |
run: | | |
mkdir -p C:\temp\${{ matrix.arch }}\ | |
mkdir -p C:\dev | |
mkdir -p C:\dev\SQLCipher-${{ matrix.arch }} | |
- name: Checkout SQLCipher | |
run: | | |
git clone -q https://github.com/sqlcipher/sqlcipher.git . | |
git reset --hard $(git describe --tags --abbrev=0) | |
mkdir sqlcipher | |
working-directory: C:\dev\SQLCipher-${{ matrix.arch }} | |
- name: Build SQLCipher (statically linked) | |
# ref: https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1#L12 | |
run: | | |
nmake /f Makefile.msc clean | |
nmake /f Makefile.msc ${{ env.SQLCIPHER_NMAKE_VARS }} LTLINKOPTS="`"$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}\lib\libcrypto.lib`"" TCCOPTS="`"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}\include`"" RCCOPTS="`"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}\include`"" LTLIBPATHS="`"/LIBPATH:$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}\lib`"" OPT_FEATURE_FLAGS="${{ env.SQLCIPHER_NMAKE_OPT_FEATURE_FLAGS }} `"-I$env:VCPKG_INSTALLATION_ROOT\packages\openssl_${{ env.VCPKG_DEFAULT_TRIPLET }}\include`"" LTLIBS="libcrypto.lib libssl.lib WS2_32.Lib Gdi32.Lib AdvAPI32.Lib Crypt32.Lib User32.Lib" | |
copy sqlcipher.exe,"$env:ProgramFiles\OpenSSL\libcrypto-*" sqlcipher | |
copy sqlcipher.exe sqlcipher-${{ matrix.arch == 'Win32' && 'x86' || matrix.arch == 'Win64' && 'x64' }}.exe | |
working-directory: C:\dev\SQLCipher-${{ matrix.arch }} | |
- name: Build SQLCipher (dynamically linked) | |
# ref: https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-OpenSSL.ps1#L12 | |
run: | | |
nmake /f Makefile.msc clean | |
nmake /f Makefile.msc ${{ env.SQLCIPHER_NMAKE_VARS }} LTLINKOPTS="`"$env:ProgramFiles\OpenSSL\lib\libcrypto.lib`"" OPT_FEATURE_FLAGS="${{ env.SQLCIPHER_NMAKE_OPT_FEATURE_FLAGS }} `"-I$env:ProgramFiles\OpenSSL\include`"" | |
move sqlcipher.exe sqlcipher-dynamic.exe | |
copy sqlite3.c,sqlite3.h,sqlcipher.dll,sqlcipher.lib,sqlcipher-dynamic.exe,"$env:ProgramFiles\OpenSSL\libcrypto-*" sqlcipher | |
working-directory: C:\dev\SQLCipher-${{ matrix.arch }} | |
- name: Prepare artifacts | |
run: | | |
Compress-Archive -Path C:\dev\SQLCipher-${{ matrix.arch }}\sqlcipher -DestinationPath build-artifacts-${{ matrix.arch }}.zip | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts-${{ matrix.arch }} | |
path: build-artifacts-${{ matrix.arch }}.zip | |
retention-days: 7 | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: latest | |
files: | | |
build-artifacts-${{ matrix.arch }}.zip | |
C:\dev\SQLCipher-${{ matrix.arch }}\sqlcipher-${{ matrix.arch == 'Win32' && 'x86' || matrix.arch == 'Win64' && 'x64' }}.exe |