Skip to content

Build (Windows)

Build (Windows) #6

name: Build (Windows)
on:
workflow_call:
inputs:
NIGHTLY:
default: false
type: boolean
secrets:
SIGNPATH_API_TOKEN:
required: false
SIGNPATH_ORGANIZATION_ID:
required: false
workflow_dispatch:
jobs:
build:
name: ${{ matrix.os }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
arch: [x86, x64]
os: [windows-2022]
env:
GH_TOKEN: ${{ github.token }}
OPENSSL_VERSION: 1.1.1.2100
QT_VERSION: 5.15.2
SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN || '' }}
SIGNPATH_ORGANIZATION_ID: ${{ secrets.SIGNPATH_ORGANIZATION_ID || '' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install dependencies
run: |
choco install --no-progress ninja
if ("${{ matrix.arch }}" -eq "x86") {
choco install --no-progress openssl --x86 --version=${{ env.OPENSSL_VERSION}}
} else {
choco install --no-progress openssl --version=${{ env.OPENSSL_VERSION}}
}
# When building SQLCipher, if we specify a path to OpenSSL and
# there are spaces in the path, an error will occur, so to
# avoid this, create the symlink.
New-Item -Path C:\dev -ItemType Directory
if ("${{ matrix.arch }}" -eq "x86") {
New-Item -Path "C:\dev\OpenSSL" -ItemType SymbolicLink -Value "C:\Program Files (x86)\OpenSSL-Win32\"
} else {
New-Item -Path "C:\dev\OpenSSL" -ItemType SymbolicLink -Value "C:\Program Files\OpenSSL"
}
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
arch: ${{ matrix.arch == 'x86' && 'win32_msvc2019' || matrix.arch == 'x64' && 'win64_msvc2019_64'}}
cache: true
cache-key-prefix: "cache"
version: ${{ env.QT_VERSION }}
- name: Install VS2019
run: choco install visualstudio2019community --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 --add Microsoft.VisualStudio.Component.VC.Redist.MSM"
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch == 'x86' && 'amd64_x86' || matrix.arch == 'x64' && 'amd64'}}
vsversion: 2019
- name: Build SQLite
run: |
$htmlContent = Invoke-WebRequest -Uri "https://sqlite.org/download.html" | Select-Object -ExpandProperty Content
$regex = [regex]::new('PRODUCT,(\d+\.\d+\.\d+),(\d+/sqlite-amalgamation-\d+\.zip),\d+,(.+)')
$match = $regex.Match($htmlContent)
$relativeUrl = $match.Groups[2].Value
$downloadLink = "https://sqlite.org/$relativeUrl"
Invoke-WebRequest -Uri $downloadLink -OutFile 'sqlite.zip'
Expand-Archive -Path sqlite.zip -DestinationPath C:\dev\
Move-Item -Path C:\dev\sqlite-amalgamation-* C:\dev\SQLite\
cd C:\dev\SQLite
cl sqlite3.c -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_STAT4 -DSQLITE_SOUNDEX -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_MAX_ATTACHED=125 -DSQLITE_API="__declspec(dllexport)" -link -dll -out:sqlite3.dll
- name: Download SQLean extension
run: |
if ("${{ matrix.arch }}" -eq "x86") {
# sqlean has discontinued x86 support starting from v0.28.0
gh release download 0.27.4 --pattern "sqlean-win-x86.zip" --repo "nalgeon/sqlean"
Expand-Archive -Path sqlean-win-x86.zip -DestinationPath .\sqlean
} else {
gh release download --pattern "sqlean-win-x64.zip" --repo "nalgeon/sqlean"
Expand-Archive -Path sqlean-win-x64.zip -DestinationPath .\sqlean
}
- name: Build 'formats' Extensions
run: |
cp .\src\extensions\extension-formats.c C:\dev\SQLite\
cp .\src\extensions\extension-formats.def C:\dev\SQLite\
cd C:\dev\SQLite
cl /MD extension-formats.c -link -dll -def:extension-formats.def -out:formats.dll
- name: Build SQLCipher
run: |
cd C:\dev
Invoke-WebRequest -Uri https://github.com/sqlcipher/sqlcipher/archive/refs/tags/v4.6.1.zip -OutFile 'sqlcipher.zip'
Expand-Archive -Path sqlcipher.zip -DestinationPath C:\dev\
Move-Item -Path C:\dev\sqlcipher-4.6.1 C:\dev\SQLCipher\
cd SQLCipher
nmake /f Makefile.msc sqlcipher.dll USE_AMALGAMATION=1 NO_TCL=1 SQLITE3DLL=sqlcipher.dll SQLITE3LIB=sqlcipher.lib SQLITE3EXE=sqlcipher.exe LTLINKOPTS="C:\dev\OpenSSL\lib\libcrypto.lib" 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 -IC:\dev\OpenSSL\include"
mkdir sqlcipher
copy sqlite3.h sqlcipher
- name: Configure build (SQLite)
run: |
mkdir release-sqlite && cd release-sqlite
cmake -G "Ninja Multi-Config" -DCMAKE_PREFIX_PATH="C:\dev\SQLite" ..\
- name: Build (SQLite)
run: |
cd release-sqlite
cmake --build . --config Release
- name: Configure build (SQLCipher)
run: |
mkdir release-sqlcipher && cd release-sqlcipher
cmake -G "Ninja Multi-Config" -Dsqlcipher=1 -DCMAKE_PREFIX_PATH="C:\dev\OpenSSL;C:\dev\SQLCipher" ..\
- name: Build (SQLCipher)
run: |
cd release-sqlcipher
cmake --build . --config Release
- if: github.event_name != 'pull_request'
name: Create MSI
env:
ExePath: ${{ github.workspace }}
OpenSSLPath: C:\dev\OpenSSL
SQLCipherPath: C:\dev\SQLCipher
SqleanPath: ${{ github.workspace }}\sqlean
SQLitePath: C:\dev\SQLite
run: |
cd installer/windows
./build.cmd "${{ matrix.arch }}".ToLower()
$DATE=$(Get-Date -Format "yyyyMMdd")
if ("${{ inputs.NIGHTLY }}" -eq "true") {
mv DB.Browser.for.SQLite-*.msi "DB.Browser.for.SQLite-$DATE-${{ matrix.arch }}.msi"
} else {
mv DB.Browser.for.SQLite-*.msi "DB.Browser.for.SQLite-dev-$(git rev-parse --short HEAD)-${{ matrix.arch }}.msi"
}
- if: github.event_name != 'pull_request' && env.SIGNPATH_API_TOKEN != '' && env.SIGNPATH_ORGANIZATION_ID != ''
name: Upload artifacts for code signing with SignPath
id: unsigned-artifacts
uses: actions/upload-artifact@v6
with:
name: build-artifacts-${{ matrix.os }}-${{ matrix.arch }}-unsigned
path: installer\windows\DB.Browser.for.SQLite-*.msi
# Change the signing-policy-slug when you release an RC, RTM or stable release.
- if: github.event_name != 'pull_request' && env.SIGNPATH_API_TOKEN != '' && env.SIGNPATH_ORGANIZATION_ID != ''
name: Code signing with SignPath
uses: signpath/github-action-submit-signing-request@v2
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
github-artifact-id: '${{ steps.unsigned-artifacts.outputs.artifact-id }}'
organization-id: '${{ secrets.SIGNPATH_ORGANIZATION_ID }}'
output-artifact-directory: .\installer\windows
project-slug: 'sqlitebrowser'
signing-policy-slug: 'test-signing'
wait-for-completion: true
- if: github.event_name != 'pull_request'
name: Create ZIP
run: |
$DATE=$(Get-Date -Format "yyyyMMdd")
if ("${{ inputs.NIGHTLY }}" -eq "true") {
$FILENAME_FORMAT="DB.Browser.for.SQLite-$DATE-${{ matrix.arch }}.zip"
} else {
$FILENAME_FORMAT="DB.Browser.for.SQLite-dev-$(git rev-parse --short HEAD)-${{ matrix.arch }}.zip"
}
Start-Process msiexec.exe -ArgumentList "/a $(dir installer\windows\DB.Browser.for.SQLite-*.msi) /q TARGETDIR=$PWD\target\" -Wait
if ("${{ matrix.arch }}" -eq "x86") {
move target\System\* "target\DB Browser for SQLite\"
} else {
move target\System64\* "target\DB Browser for SQLite\"
}
Compress-Archive -Path "target\DB Browser for SQLite\*" -DestinationPath $FILENAME_FORMAT
- if: github.event_name != 'pull_request' && github.workflow != 'Build (Windows)'
name: Prepare artifacts
run: |
mkdir build-artifacts
move installer\windows\DB.Browser.for.SQLite-*.msi build-artifacts\
move DB.Browser.for.SQLite-*.zip build-artifacts\
Compress-Archive -Path build-artifacts\* -DestinationPath build-artifacts-${{ matrix.arch }}.zip
- if: github.event_name != 'pull_request' && github.workflow != 'Build (Windows)'
name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: build-artifacts-${{ matrix.os }}-${{ matrix.arch }}
path: build-artifacts-${{ matrix.arch }}.zip
- if: github.event_name == 'workflow_dispatch' && github.workflow == 'Build (Windows)'
name: Release
uses: softprops/action-gh-release@v2
with:
files: installer/windows/DB.Browser.for.SQLite-*.msi, DB.Browser.for.SQLite-*.zip
prerelease: true
tag_name: ${{ github.sha }}-windows
- name: Summary
run: |
$OPENSSL_VERSION=(C:\dev\OpenSSL\bin\openssl version) -replace "OpenSSL ([\d\.]+[a-z]+) .*", '$1'
$QT_VERSION = & "$env:QT_ROOT_DIR\bin\qmake.exe" --version | Select-String "Using Qt version" | ForEach-Object { $_.ToString().Split()[3] }
$SQLCIPHER_VERSION=(Get-Item "C:\dev\SQLCipher\sqlcipher.dll").VersionInfo.FileVersion
Select-String -Path "C:\dev\SQLite\sqlite3.h" -Pattern '#define SQLITE_VERSION\s+"([\d\.]+)"' | ForEach-Object {
($_ -match '"([\d\.]+)"') | Out-Null
$SQLITE_VERSION=$matches[1]
}
echo "## Libaries used" >> $env:GITHUB_STEP_SUMMARY
echo "OpenSSL: $OPENSSL_VERSION, Qt: $QT_VERSION, SQLCipher: $SQLCIPHER_VERSION, SQLite: $SQLITE_VERSION" >> $env:GITHUB_STEP_SUMMARY