Skip to content

Commit

Permalink
Build and sign Windows installer (#1702)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pjob authored Oct 11, 2024
1 parent edddf04 commit 2a79d80
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 36 deletions.
101 changes: 66 additions & 35 deletions scripts/packaging/win/build_installer.bat
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
@echo on

REM replace with one from environment
set RELEASE_TYPE=dev

aws s3 ls %STAGE_URL% --recursive

heat.exe /?
candle.exe /?
light.exe /?


REM heat.exe dir dist\\snow\\_internal ^
REM -gg ^
REM -cg SnowflakeCLIInternalFiles ^
REM -dr TESTFILEPRODUCTDIR ^
REM -var var.SnowflakeCLIInternalFiles ^
REM -sfrag ^
REM -o _internal.wxs
REM
REM candle.exe ^
REM -arch x64 ^
REM -dSnowflakeCLIVersion=%CLI_VERSION% ^
REM -dSnowflakeCLIInternalFiles=dist\\snow\\_internal ^
REM scripts\packaging\win\snowflake_cli.wxs ^
REM scripts\packaging\win\snowflake_cli_exitdlg.wxs ^
REM _internal.wxs
REM
REM light.exe ^
REM -ext WixUIExtension ^
REM -ext WixUtilExtension ^
REM -cultures:en-us ^
REM -loc scripts\packaging\win\snowflake_cli_en-us.wxl ^
REM -out snowflake-cli-%CLI_VERSION%-x86_64.msi ^
REM snowflake_cli.wixobj ^
REM snowflake_cli_exitdlg.wixobj ^
REM _internal.wixobj
set PATH=C:\Program Files\7-Zip;C:\Users\jenkins\AppData\Local\Programs\Python\Python38;C:\Users\jenkins\AppData\Local\Programs\Python\Python38\Scripts;C:\Program Files (x86)\WiX Toolset v3.11\bin;%PATH%

python.exe --version
python.exe -c "import platform as p; print(f'{p.system()=}, {p.architecture()=}')"

python.exe -m pip install hatch
FOR /F "delims=" %%I IN ('hatch run packaging:win-build-version') DO SET CLI_VERSION=%%I
FOR /F "delims=" %%I IN ('git rev-parse %svnRevision%') DO SET REVISION=%%I
FOR /F "delims=" %%I IN ('echo %releaseType%') DO SET RELEASE_TYPE=%%I

echo CLI_VERSION = %CLI_VERSION%
echo REVISION = %REVISION%`
echo RELEASE_TYPE = %RELEASE_TYPE%`

set CLI_ZIP=snowflake-cli-%CLI_VERSION%.zip
set CLI_MSI=snowflake-cli-%CLI_VERSION%-x86_64.msi
set STAGE_URL=s3://sfc-eng-jenkins/repository/snowflake-cli/staging/%RELEASE_TYPE%/windows_x86_64/%REVISION%
set RELEASE_URL=s3://sfc-eng-jenkins/repository/snowflake-cli/%RELEASE_TYPE%/windows_x86_64/%REVISION%

echo "[INFO] downloading artifacts"
cmd /c aws s3 cp %STAGE_URL%/%CLI_ZIP% . || goto :error

echo "[INFO] building installer"
7z x %CLI_ZIP% || goto :error

signtool sign /debug /sm /d "Snowflake CLI" /t http://timestamp.digicert.com /a dist\snow\snow.exe || goto :error
signtool verify /v /pa dist\snow\snow.exe || goto :error

heat.exe dir dist\snow\_internal ^
-gg ^
-cg SnowflakeCLIInternalFiles ^
-dr TESTFILEPRODUCTDIR ^
-var var.SnowflakeCLIInternalFiles ^
-sfrag ^
-o _internal.wxs || goto :error

candle.exe ^
-arch x64 ^
-dSnowflakeCLIVersion=%CLI_VERSION% ^
-dSnowflakeCLIInternalFiles=dist\\snow\\_internal ^
scripts\packaging\win\snowflake_cli.wxs ^
scripts\packaging\win\snowflake_cli_exitdlg.wxs ^
_internal.wxs || goto :error

light.exe ^
-ext WixUIExtension ^
-ext WixUtilExtension ^
-cultures:en-us ^
-loc scripts\packaging\win\snowflake_cli_en-us.wxl ^
-out %CLI_MSI% ^
snowflake_cli.wixobj ^
snowflake_cli_exitdlg.wixobj ^
_internal.wixobj || goto :error

signtool sign /debug /sm /d "Snowflake CLI" /t http://timestamp.digicert.com /a %CLI_MSI% || goto :error
signtool verify /v /pa %CLI_MSI% || goto :error

echo "[INFO] uploading artifacts"
cmd /c aws s3 cp %CLI_MSI% %RELEASE_URL%/%CLI_MSI% || goto :error

REM FINISH SCRIPT EXECUTION HERE
GOTO :EOF

:error
echo Failed with error code #%errorlevel%.
exit /b %errorlevel%
2 changes: 1 addition & 1 deletion scripts/packaging/win/build_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def parse_version_for_windows_build() -> list[str]:
case last if "dev" in last:
version = msv + last.split("dev")

return version
return [segment for segment in version if segment]


if __name__ == "__main__":
Expand Down

0 comments on commit 2a79d80

Please sign in to comment.