Skip to content

Commit

Permalink
chore: build installer on visual studio 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
karenc-bq committed Jun 24, 2024
1 parent 909cbf1 commit 0241716
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 20 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build-installer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build installer
# This workflow is triggered on creating tags
on:
push:
branches:
- windows-installer

env:
BUILD_TYPE: Release

jobs:
build-windows:
name: Windows
runs-on: windows-latest
env:
CMAKE_GENERATOR: Visual Studio 17 2022
WIX_DIR: "C:/Program Files (x86)/WiX Toolset v3.14/bin"
steps:
- name: Checkout source code
uses: actions/checkout@v4

# Configure build environment/dependencies
- name: Install MySQL client libs
run: |
curl -L https://dev.mysql.com/get/Downloads/MySQL-8.3/mysql-${{ vars.MYSQL_VERSION }}-winx64.zip -o mysql.zip
unzip -d C:/ mysql.zip
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2

- name: Cache AWS SDK libraries
id: cache-dynamic-aws-sdk
uses: actions/cache@v4
with:
path: |
aws_sdk
key: ${{ runner.os }}-aws-sdk-dynamic-lib

- name: Build and install AWS SDK C++
working-directory: ./scripts
if: steps.cache-dynamic-aws-sdk.outputs.cache-hit != 'true'
run: |
.\build_aws_sdk_win.ps1 x64 ${{ env.BUILD_TYPE}} ON "${{env.CMAKE_GENERATOR}}"
- name: Setup nmake
uses: ilammy/msvc-dev-cmd@v1

- name: Run build installer script
shell: pwsh
run: |
.\build_installer.ps1 x64 ${{ env.BUILD_TYPE}} "${{env.CMAKE_GENERATOR}}" C:/mysql-${{ vars.MYSQL_VERSION }}-winx64 "${{env.WIX_DIR}}"
- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-skip-session-tagging: true
aws-access-key-id: ${{ secrets.AWS_BUILD_KEY }}
aws-secret-access-key: ${{ secrets.AWS_BUILD_SECRET_KEY }}
aws-region: us-west-2
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-external-id: ${{ secrets.AWS_ROLE_EXTERNAL_ID }}
role-duration-seconds: 3600

- name: Run signer script
shell: pwsh
working-directory: ./scripts
run: |
choco upgrade jq -y
. ".\sign_installer.ps1"
Invoke-SignInstaller ${{ github.workspace }}\wix winx64a ${{github.ref_name}} ${{ secrets.AWS_UNSIGNED_BUCKET }} ${{ secrets.AWS_SIGNED_BUCKET }} ${{ secrets.AWS_S3_KEY }}aws-mysql-odbc-${{github.ref_name}}-winx64a.msi
- name: Upload Windows installer as artifact
if: success()
uses: actions/upload-artifact@v3
with:
name: installers
path: ${{ github.workspace }}/wix/*.msi
if-no-files-found: error
5 changes: 0 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2

- name: Update CMAKE Version
shell: pwsh
run: |
choco upgrade cmake --pre
- name: Cache AWS SDK libraries
id: cache-dynamic-aws-sdk
uses: actions/cache@v4
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ jobs:

build-windows:
name: Windows
runs-on: windows-2019
runs-on: windows-latest
env:
CMAKE_GENERATOR: Visual Studio 16 2019
CMAKE_GENERATOR: Visual Studio 17 2022
WIX_DIR: "C:/Program Files (x86)/WiX Toolset v3.14/bin"
steps:
- name: Checkout source code
uses: actions/checkout@v4
Expand All @@ -177,7 +178,7 @@ jobs:

- name: Run build installer script
run: |
.\build_installer.ps1 x64 ${{ env.BUILD_TYPE}} "${{env.CMAKE_GENERATOR}}" C:/mysql-${{ vars.MYSQL_VERSION }}-winx64
.\build_installer.ps1 x64 ${{ env.BUILD_TYPE}} "${{env.CMAKE_GENERATOR}}" C:/mysql-${{ vars.MYSQL_VERSION }}-winx64 "${{env.WIX_DIR}}"
- name: Configure AWS credentials
uses: aws-actions/[email protected]
Expand Down
14 changes: 10 additions & 4 deletions build_installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ $ARCHITECTURE = $args[0]
$CONFIGURATION = $args[1]
$GENERATOR = $args[2]
$MYSQL_DIR = $args[3]
$WIX_DIR = $args[4]

# Set default values
if ($null -eq $CONFIGURATION) {
$CONFIGURATION = "Release"
}
if ($null -eq $MYSQL_DIR) {
$MYSQL_DIR = "C:\Program Files\MySQL\MySQL Server 8.0"
$MYSQL_DIR = "C:\Program Files\MySQL\MySQL Server 8.3"
}

# BUILD DRIVER
Expand Down Expand Up @@ -81,10 +82,15 @@ Copy-Item .\LICENSE.txt .\Wix\doc

Set-Location .\Wix
if ($ARCHITECTURE -eq "x64") {
cmake -DMSI_64=1 -G "NMake Makefiles"
}
else {
if ($null -eq $WIX_DIR) {
cmake -DMSI_64=1 -G "NMake Makefiles"
} else {
cmake -DMSI_64=1 -G "NMake Makefiles" -DWIX_DIR="$WIX_DIR"
}
} elseif ($null -eq $WIX_DIR) {
cmake -DMSI_64=0 -G "NMake Makefiles"
} else {
cmake -DMSI_64=0 -G "NMake Makefiles" -DWIX_DIR="$WIX_DIR"
}
nmake

Expand Down
10 changes: 8 additions & 2 deletions wix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,20 @@ FILE(APPEND "${XML_DEPENDENCIES}" "</Component></Include>")


CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_odbc.wxs.in
${CMAKE_CURRENT_SOURCE_DIR}/mysql-odbc-${ODBC_VERSION}-${MSI_VERSION}.wxs @ONLY)
${CMAKE_CURRENT_SOURCE_DIR}/aws-mysql-odbc-${ODBC_VERSION}-${MSI_VERSION}.wxs @ONLY)

ADD_CUSTOM_TARGET(
MSI_INSTALLER ALL
DEPENDS ${MSI_PACKAGE})

ADD_CUSTOM_COMMAND(
OUTPUT ${MSI_PACKAGE}
DEPENDS mysql_odbc.wxs
mysql_odbc_fragment.wxs
COMMAND ${WIX_DIR}/candle.exe mysql_odbc.wxs.in mysql_odbc_fragment.wxs -o ${MSI_PACKAGE})

ADD_CUSTOM_COMMAND(
OUTPUT mysql_odbc.wxs
DEPENDS mysql_odbc.wxs.in
mysql_common_ui.wxs
COMMAND ${WIX_EXECUTABLE} build -arch ${XML_FILE_SOURCE_ARCH} -out ${MSI_PACKAGE} mysql-odbc-${ODBC_VERSION}-${MSI_VERSION}.wxs mysql_odbc_fragment.wxs)
COMMAND ${WIX_EXECUTABLE} -arch ${XML_FILE_SOURCE_ARCH} aws-mysql-odbc-${ODBC_VERSION}-${MSI_VERSION}.wxs -o mysql_odbc.wxs.in)
2 changes: 1 addition & 1 deletion wix/cmake/FindWix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ IF(NOT DEFINED WIX_DIR)
ENDIF(DEFINED $ENV{WIX_DIR})
ENDIF(NOT DEFINED WIX_DIR)

FIND_PROGRAM(WIX_EXECUTABLE wix ${WIX_DIR})
FIND_PROGRAM(WIX_EXECUTABLE candle ${WIX_DIR})

#----------------- FIND WIX EXECUTABLE -------------------
IF (EXISTS "${WIX_EXECUTABLE}")
Expand Down
4 changes: 2 additions & 2 deletions wix/mysql_odbc.wxs.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<?include myodbc_version.xml ?>
<?include myodbc_version.wxs ?>
<!-- *****************************************************************************************
Product MySQL Server
-->
Expand Down Expand Up @@ -64,7 +64,7 @@
Description="AWS ODBC Driver for MySQL" Manufacturer="Amazon.com Inc. or affiliates"
InstallerVersion="200" Platform="$(var.odbc_platform)"
Languages="1033" SummaryCodepage="1252" Compressed='yes' />
<?include mysql-connector-odbc-msi-arpprops.xml ?>
<?include mysql-connector-odbc-msi-arpprops.wxs ?>

<!-- *****************************************************************************************
Custom Actions
Expand Down
6 changes: 3 additions & 3 deletions wix/mysql_odbc_fragment.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<!-- *****************************************************************************************
Icons
-->
<?include myodbc_version.xml ?>
<?include myodbc_version.wxs ?>

<!-- *****************************************************************************************
Directories / Files
Expand Down Expand Up @@ -106,8 +106,8 @@
<?endif ?>
</Component>
<?endif ?>
<?include mysql_odbc_dependencies.xml ?>
<Directory Id="Plugindir" Name="plugin"><?include mysql_odbc_plugins.xml ?></Directory>
<?include mysql_odbc_dependencies.wxs ?>
<Directory Id="Plugindir" Name="plugin"><?include mysql_odbc_plugins.wxs ?></Directory>
</Directory> <!--INSTALLDIR-->
</Directory>
<!-- needed to make candle happy -->
Expand Down

0 comments on commit 0241716

Please sign in to comment.