Skip to content

Commit

Permalink
Merge pull request #175 from chewing/msi-installer
Browse files Browse the repository at this point in the history
feat: build MSI installer with WiX
  • Loading branch information
kanru authored Jun 29, 2024
2 parents 8ba5c8a + 309540b commit 323b8d7
Show file tree
Hide file tree
Showing 11 changed files with 761 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ jobs:
- name: Setup rustup
run: rustup target add i686-pc-windows-msvc

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2

- name: Build
run: scripts/build_installer.bat

- id: upload-unsigned
uses: actions/upload-artifact@v4
with:
name: Unsigned Installer
path: dist\windows-chewing-tsf-unsigned.exe
path: |
dist\windows-chewing-tsf-unsigned.exe
dist\windows-chewing-tsf-unsigned.msi
4 changes: 4 additions & 0 deletions .github/workflows/code-signing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ jobs:
run: |
mv dist/windows-chewing-tsf-unsigned.exe dist/windows-chewing-tsf.exe
sha256sum dist/windows-chewing-tsf.exe > dist/windows-chewing-tsf.exe.sha256
mv dist/windows-chewing-tsf-unsigned.msi dist/windows-chewing-tsf.msi
sha256sum dist/windows-chewing-tsf.msi > dist/windows-chewing-tsf.msi.sha256
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Signed Installer
path: |
dist/windows-chewing-tsf.exe
dist/windows-chewing-tsf.exe.sha256
dist/windows-chewing-tsf.msi
dist/windows-chewing-tsf.msi.sha256
2 changes: 2 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ jobs:
files: |
dist/windows-chewing-tsf.exe
dist/windows-chewing-tsf.exe.sha256
dist/windows-chewing-tsf.msi
dist/windows-chewing-tsf.msi.sha256
251 changes: 251 additions & 0 deletions installer/lgpl-2.1.rtf

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions installer/windows-chewing-tsf.wixproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="WixToolset.Sdk/5.0.0">
<PropertyGroup>
<Cultures>zh-TW</Cultures>
<InstallerPlatform>x64</InstallerPlatform>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="WixToolset.UI.wixext" Version="5.0.0" />
</ItemGroup>
</Project>
109 changes: 109 additions & 0 deletions installer/windows-chewing-tsf.wxl
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>

<WixLocalization Culture="zh-tw" Codepage="950" xmlns="http://wixtoolset.org/schemas/v4/wxl">
<String Id="WelcomeEulaDlgTitle" Overridable="yes" Value="{\WixUI_Font_Title}[ProductName]使用 GNU Lesser General Public License (LGPL) 2.1 授權。" />
<String Id="WelcomeEulaDlgLicenseAcceptedCheckBox" Overridable="yes" Value="我已閱讀並了解我的權利(&amp;R)" />

<!-- Remove spaces before and after [ProductName] -->

<String Id="AdvancedWelcomeEulaDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="AdvancedWelcomeEulaDlgTitle" Overridable="yes" Value="{\WixUI_Font_Title}請閱讀[ProductName]授權合約" />

<String Id="BrowseDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="CancelDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="CancelDlgText" Overridable="yes" Value="您確定要取消[ProductName]安裝嗎?" />

<String Id="CustomizeDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="DiskCostDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="ErrorDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="ExitDialog_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="ExitDialogTitle" Overridable="yes" Value="{\WixUI_Font_Bigger}已完成[ProductName]安裝精靈" />

<String Id="FatalError_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="FatalErrorTitle" Overridable="yes" Value="{\WixUI_Font_Bigger}[ProductName]安裝精靈提前結束" />
<String Id="FatalErrorDescription1" Overridable="yes" Value="[ProductName]安裝精靈因發生錯誤而提前結束,您的系統尚未被修改。若要稍後再安裝此程式,請再執行一次安裝精靈。" />

<String Id="FeaturesDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="FilesInUse_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="InstallDirDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="InstallDirDlgFolderLabel" Overridable="yes" Value="安裝[ProductName]到:" />

<String Id="InstallScopeDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="InstallScopeDlgPerUserDescription" Overridable="yes" Value="[ProductName]將安裝在個別使用者資料夾中,並且僅供您的使用者帳戶使用。您不需要本機系統管理員權限。" />
<String Id="InstallScopeDlgNoPerUserDescription" Overridable="yes" Value="[ProductName]不支援個別使用者安裝。" />
<String Id="InstallScopeDlgPerMachineDescription" Overridable="yes" Value="[ProductName]將依預設安裝在個別電腦資料夾中,並且可供所有使用者使用。您可以變更預設安裝資料夾。您必須擁有本機系統管理員權限。" />

<String Id="InvalidDirDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="LicenseAgreementDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="MaintenanceTypeDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="MaintenanceTypeDlgChangeDisabledText" Overridable="yes" Value="[ProductName]沒有可以單獨選取的功能。" />
<String Id="MaintenanceTypeDlgRemoveText" Overridable="yes" Value="從您的電腦移除[ProductName]。" />
<String Id="MaintenanceTypeDlgRemoveDisabledText" Overridable="yes" Value="[ProductName]無法移除。" />
<String Id="MaintenanceTypeDlgRepairDisabledText" Overridable="yes" Value="[ProductName]無法修復。" />

<String Id="MaintenanceWelcomeDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="MaintenanceWelcomeDlgDescription" Overridable="yes" Value="安裝精靈可以讓您變更[ProductName]功能安裝在電腦上的方式,或從電腦移除它們。請按 [\[]下一步[\]] 繼續進行,或按 [\[]取消[\]] 結束安裝精靈。" />
<String Id="MaintenanceWelcomeDlgTitle" Overridable="yes" Value="{\WixUI_Font_Bigger}歡迎使用[ProductName]安裝精靈" />

<String Id="MsiRMFilesInUse_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="OutOfDiskDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="OutOfRbDiskDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="PrepareDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="PrepareDlgTitle" Overridable="yes" Value="{\WixUI_Font_Bigger}歡迎使用[ProductName]安裝精靈" />

<String Id="ProgressDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="ProgressDlgTextInstalling" Overridable="yes" Value="安裝程式精靈正在安裝[ProductName],請稍候。" />
<String Id="ProgressDlgTitleInstalling" Overridable="yes" Value="{\WixUI_Font_Title}正在安裝[ProductName]" />
<String Id="ProgressDlgTextChanging" Overridable="yes" Value="安裝精靈正在變更[ProductName],請稍候。" />
<String Id="ProgressDlgTitleChanging" Overridable="yes" Value="{\WixUI_Font_Title}正在變更[ProductName]" />
<String Id="ProgressDlgTextRepairing" Overridable="yes" Value="安裝精靈正在修復[ProductName],請稍候。" />
<String Id="ProgressDlgTitleRepairing" Overridable="yes" Value="{\WixUI_Font_Title}正在修復[ProductName]" />
<String Id="ProgressDlgTextRemoving" Overridable="yes" Value="安裝精靈正在移除[ProductName],請稍候。" />
<String Id="ProgressDlgTitleRemoving" Overridable="yes" Value="{\WixUI_Font_Title}正在移除[ProductName]" />
<String Id="ProgressDlgTextUpdating" Overridable="yes" Value="安裝精靈正在更新[ProductName],請稍候。" />
<String Id="ProgressDlgTitleUpdating" Overridable="yes" Value="{\WixUI_Font_Title}正在更新[ProductName]" />

<String Id="ResumeDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="ResumeDlgDescription" Overridable="yes" Value="安裝精靈即將完成在您的電腦上安裝[ProductName]。請按 [\[]安裝[\]] 繼續進行,或按 [\[]取消[\]] 結束安裝精靈。" />
<String Id="ResumeDlgTitle" Overridable="yes" Value="{\WixUI_Font_Bigger}繼續執行[ProductName]安裝精靈" />

<String Id="SetupTypeDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="UserExit_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="UserExitTitle" Overridable="yes" Value="{\WixUI_Font_Bigger}[ProductName]安裝精靈已中斷" />
<String Id="UserExitDescription1" Overridable="yes" Value="[ProductName]安裝程式已中斷。您的系統尚未被修改。若要稍後再安裝此程式,請再執行一次安裝精靈。" />

<String Id="VerifyReadyDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="VerifyReadyDlgInstallTitle" Overridable="yes" Value="{\WixUI_Font_Title}準備安裝[ProductName]" />
<String Id="VerifyReadyDlgChangeTitle" Overridable="yes" Value="{\WixUI_Font_Title}準備變更[ProductName]" />
<String Id="VerifyReadyDlgRepairTitle" Overridable="yes" Value="{\WixUI_Font_Title}準備修復[ProductName]" />
<String Id="VerifyReadyDlgRemoveText" Overridable="yes" Value="按一下 [\[]移除[\]] 即可從電腦移除[ProductName]。按一下 [\[]上一步[\]] 可檢閱或變更您的任何安裝設定。按一下 [\[]取消[\]] 可結束此精靈。" />
<String Id="VerifyReadyDlgRemoveTitle" Overridable="yes" Value="{\WixUI_Font_Title}準備移除[ProductName]" />
<String Id="VerifyReadyDlgUpdateText" Overridable="yes" Value="按一下 [\[]更新[\]] 即可更新您電腦中的[ProductName]。按一下 [\[]上一步[\]] 可檢閱或變更您的任何安裝設定。按一下 [\[]取消[\]] 可結束此精靈。" />
<String Id="VerifyReadyDlgUpdateTitle" Overridable="yes" Value="{\WixUI_Font_Title}準備更新[ProductName]" />

<String Id="WaitForCostingDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />

<String Id="WelcomeDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="WelcomeDlgDescription" Overridable="yes" Value="安裝精靈將在您的電腦上安裝[ProductName]。請按 [\[]下一步[\]] 繼續進行,或按 [\[]取消[\]] 結束安裝精靈。" />
<String Id="WelcomeUpdateDlgDescriptionUpdate" Overridable="yes" Value="安裝精靈將更新您電腦上的[ProductName]。請按 [\[]下一步[\]] 繼續進行,或按 [\[]取消[\]] 結束安裝精靈。" />
<String Id="WelcomeDlgTitle" Overridable="yes" Value="{\WixUI_Font_Bigger}歡迎使用[ProductName]安裝精靈" />

<String Id="WelcomeEulaDlg_Title" Overridable="yes" Value="[ProductName]安裝程式" />
<String Id="WelcomeEulaDlgTitle" Overridable="yes" Value="{\WixUI_Font_Title}請閱讀[ProductName]授權合約" />

<String Id="Error20" Overridable="yes" Value="請稍候,Windows 在設定[ProductName]" />
<String Id="Error32" Overridable="yes" Value="{[ProductName]}安裝成功。" />
<String Id="Error33" Overridable="yes" Value="{[ProductName]}安裝失敗。" />
</WixLocalization>
101 changes: 101 additions & 0 deletions installer/windows-chewing-tsf.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<Package Name="新酷音輸入法 (TSF)"
Codepage="65001"
Language="1028"
Manufacturer="新酷音輸入法開發團隊"
Version="1.0.0.1"
UpgradeCode="8085e4ce-205d-4c44-9450-59ba34163b2a">
<MediaTemplate EmbedCab="yes" />
<StandardDirectory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER32" Name="ChewingTextService">
<Directory Id="Dictionary" Name="Dictionary">
<File Source="Dictionary\swkb.dat" Bitness="always32" />
<File Source="Dictionary\symbols.dat" Bitness="always32" />
<File Source="Dictionary\tsi.dat" Bitness="always32" />
<File Source="Dictionary\word.dat" Bitness="always32" />
</Directory>
<File Source="x86\chewing-msvc.dll" Bitness="always32" />
<Component Bitness="always32">
<File Source="x86\ChewingTextService.dll">
<Class Advertise="no" Context="InprocServer32" Description="新酷音輸入法 (TSF)"
Id="13F2EF08-575C-4D8C-88E0-F67BB8052B84" IconIndex="0"
ThreadingModel="apartment" />
</File>
<!-- Remove NSIS Uninstaller -->
<RemoveFile Name="Uninstall.exe" On="install" />
</Component>
<File Source="ChewingPreferences.exe" Bitness="always32" />
<File Source="chewing-cli.exe" Bitness="always32" />

</Directory>
</StandardDirectory>
<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER64" Name="ChewingTextService">
<File Source="x64\chewing-msvc.dll" />
<Component Bitness="always64">
<File Source="x64\ChewingTextService.dll">
<Class Advertise="no" Context="InprocServer32" Description="新酷音輸入法 (TSF)"
Id="13F2EF08-575C-4D8C-88E0-F67BB8052B84" IconIndex="0"
ThreadingModel="apartment" />
</File>
<!-- Remove NSIS Uninstaller -->
<RemoveFile Name="Uninstall.exe" On="install" />
</Component>
</Directory>
</StandardDirectory>
<Binary Id="tsfreg" SourceFile="tsfreg.exe" />
<CustomAction Id="RegisterTSF" BinaryRef="tsfreg" ExeCommand="-r '[INSTALLFOLDER32]ChewingTextService.dll'"
Impersonate="no" Execute="deferred" Return="check" />
<CustomAction Id="UnregisterTSF" BinaryRef="tsfreg" ExeCommand="-u" Impersonate="no"
Execute="deferred" Return="check" />
<InstallExecuteSequence>
<Custom Action="RegisterTSF" Before="InstallFinalize"
Condition='Installed="" AND PREVIOUSVERSIONSINSTALLED=""' />
<Custom Action="UnregisterTSF" Before="RemoveRegistryValues"
Condition='PREVIOUSVERSIONSINSTALLED="" AND REMOVE="ALL"' />
</InstallExecuteSequence>
<ui:WixUI Id="WixUI_Minimal" />
<WixVariable Id="WixUILicenseRtf" Value="lgpl-2.1.rtf" />

<Property Id="NSISUNINSTALLFOLDER32">
<RegistrySearch Id="NSISUNINSTALLFOLDER32" Type="file" Root="HKLM"
Bitness="always32" Name="UninstallString"
Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ChewingTextService" />
</Property>
<Property Id="NSISUNINSTALLCMD32">
<RegistrySearch Id="NSISUNINSTALLCMD32" Type="file" Root="HKLM"
Bitness="always32" Name="UninstallString"
Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ChewingTextService">
<FileSearch Name="Uninstall.exe" />
</RegistrySearch>
</Property>
<Property Id="NSISUNINSTALLFOLDER64">
<RegistrySearch Id="NSISUNINSTALLFOLDER64" Type="file" Root="HKLM"
Bitness="always64" Name="UninstallString"
Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ChewingTextService" />
</Property>
<Property Id="NSISUNINSTALLCMD64">
<RegistrySearch Id="NSISUNINSTALLCMD64" Type="file" Root="HKLM"
Bitness="always64" Name="UninstallString"
Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ChewingTextService">
<FileSearch Name="Uninstall.exe" />
</RegistrySearch>
</Property>

<CustomAction Id="RemoveNsisInst32" Property="NSISUNINSTALLCMD32"
ExeCommand="/S _?=[NSISUNINSTALLFOLDER32]"
Execute="deferred" Impersonate="no" Return="check" />
<CustomAction Id="RemoveNsisInst64" Property="NSISUNINSTALLCMD64"
ExeCommand="/S _?=[NSISUNINSTALLFOLDER64]"
Execute="deferred" Impersonate="no" Return="check" />
<InstallExecuteSequence>
<Custom Action="RemoveNsisInst32" After="InstallInitialize"
Condition='NSISUNINSTALLCMD32&lt;&gt;""' />
<Custom Action="RemoveNsisInst64" After="InstallInitialize"
Condition='NSISUNINSTALLCMD64&lt;&gt;""' />
</InstallExecuteSequence>
</Package>
</Wix>
6 changes: 6 additions & 0 deletions scripts/build_installer.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ cmake -B x86 -A Win32 -DBUILD_TESTING=OFF
cmake --build x86 --config Release
cmake -B x64 -A x64 -DBUILD_TESTING=OFF
cmake --build x64 --config Release
pushd tsfreg
cargo build --release
popd
mkdir dist
mkdir nsis
copy installer\* nsis\
Expand All @@ -17,7 +20,10 @@ copy x86\libchewing\chewing-cli.exe nsis\
mkdir nsis\x64
copy x64\ChewingTextService\Release\*.dll nsis\x64\
copy x64\libchewing\Release\*.dll nsis\x64\
copy tsfreg\target\release\tsfreg.exe nsis\
pushd nsis
makensis installer.nsi
msbuild -p:Configuration=Release -restore windows-chewing-tsf.wixproj
popd
copy nsis\windows-chewing-tsf.exe dist\windows-chewing-tsf-unsigned.exe
copy nsis\bin\Release\zh-TW\windows-chewing-tsf.msi dist\windows-chewing-tsf-unsigned.msi
Loading

0 comments on commit 323b8d7

Please sign in to comment.