Skip to content

Commit

Permalink
Merge pull request #138 from janhohenheim/msi
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim authored Feb 15, 2023
2 parents c883857 + 853e4fa commit eb9e07b
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 3 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
build-macOS:
runs-on: macos-latest

env:
# macOS 11.0 Big Sur is the first version of macOS to support universal binaries
MACOSX_DEPLOYMENT_TARGET: 11.0
steps:
- name: Get tag
id: tag
Expand All @@ -43,7 +46,7 @@ jobs:
brew install michaeleisel/zld/zld
- name: Build release for Apple Silicon
run: |
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version) cargo build --release --no-default-features --features core,native --target=aarch64-apple-darwin
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) cargo build --release --no-default-features --features core,native --target=aarch64-apple-darwin
- name: Install rust toolchain for Apple x86
uses: actions-rs/toolchain@v1
with:
Expand All @@ -52,7 +55,7 @@ jobs:
override: true
- name: Build release for x86 Apple
run: |
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version) cargo build --release --no-default-features --features core,native --target=x86_64-apple-darwin
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) cargo build --release --no-default-features --features core,native --target=x86_64-apple-darwin
- name: Create Universal Binary
run: |
lipo -create -output target/release/${{ env.GAME_EXECUTABLE_NAME }} target/aarch64-apple-darwin/release/${{ env.GAME_EXECUTABLE_NAME }} target/x86_64-apple-darwin/release/${{ env.GAME_EXECUTABLE_NAME }}
Expand Down Expand Up @@ -135,6 +138,10 @@ jobs:
with:
toolchain: nightly
override: true
- name: Install dotnet
uses: actions/setup-dotnet@v3
with:
global-json-file: build/windows/installer/global.json
- name: Build release
run: |
cargo build --release --no-default-features --features core,native
Expand All @@ -147,6 +154,8 @@ jobs:
with:
files: target/release/assets/ target/release/credits/ target/release/${{ env.GAME_EXECUTABLE_NAME }}.exe
dest: ${{ env.GAME_EXECUTABLE_NAME }}_windows.zip
- name: Create Installer
run: dotnet build -c Release build/windows/installer/Installer.wixproj --output installer
- name: Upload release
uses: svenstaro/upload-release-action@v2
with:
Expand All @@ -155,6 +164,14 @@ jobs:
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ steps.tag.outputs.tag }}_windows.zip
tag: ${{ github.ref }}
overwrite: true
- name: Upload installer
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: installer/en-US/installer.msi
asset_name: ${{ env.EXECUTABLE_NAME }}_${{ steps.tag.outputs.tag }}_windows.msi
tag: ${{ github.ref }}
overwrite: true
build-web:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -183,7 +200,7 @@ jobs:
- name: Build Release
run: |
trunk build --release --public-url "${GITHUB_REPOSITORY#*/}" --no-default-features --features core,wasm
- name: optimize Wasm
- name: Optimize Wasm
uses: NiklasEi/wasm-opt-action@v2
with:
file: dist/*.wasm
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ assets/scenes/*-[1-9].scn.ron
blender_assets.cats.txt*
*.blend1

installer/
Trunk.toml
2 changes: 2 additions & 0 deletions build/windows/installer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin/
/obj/
60 changes: 60 additions & 0 deletions build/windows/installer/InstallDirUi.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<!-- Copied from https://github.com/wixtoolset/wix4/blob/6f2511f58f60e63a15357a2fe37f83343dea3090/src/ext/UI/wixlib/WixUI_InstallDir.wxs#L9
but with the license dialog disabled.
See: https://wixtoolset.org/docs/v3/wixui/wixui_customizations/#changing-the-ui-sequence-of-a-built-in-dialog-set. -->
<Fragment>
<UI Id="WixUI_CustomInstallDir">
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />

<DialogRef Id="BrowseDlg" />
<DialogRef Id="DiskCostDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FatalError" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="MsiRMFilesInUse" />
<DialogRef Id="PrepareDlg" />
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ResumeDlg" />
<DialogRef Id="UserExit" />
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4" Condition="NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID&lt;&gt;&quot;1&quot;" />

<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999" />

<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Condition="NOT Installed" />
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Condition="Installed AND PATCH" />

<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" />
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1" />
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3" Condition="NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID&lt;&gt;&quot;1&quot;" />
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4" Condition="WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID=&quot;1&quot;" />
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1" />
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2" />
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1" Condition="NOT Installed" />
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2" Condition="Installed AND NOT PATCH" />
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2" Condition="Installed AND PATCH" />

<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg" />

<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg" />
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg" />
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg" />

<Property Id="ARPNOMODIFY" Value="1" />
</UI>

<UIRef Id="WixUI_Common" />
</Fragment>
<?foreach WIXUIARCH in X86;X64;A64 ?>
<Fragment>
<UI Id="WixUI_CustomInstallDir_$(WIXUIARCH)">
<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath_$(WIXUIARCH)" Order="3" Condition="NOT WIXUI_DONTVALIDATEPATH" />
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath_$(WIXUIARCH)" Order="2" Condition="NOT WIXUI_DONTVALIDATEPATH" />
</UI>
</Fragment>
<?endforeach?>
</Wix>
40 changes: 40 additions & 0 deletions build/windows/installer/Installer.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "Installer", "Installer.wixproj", "{340293B0-F46C-46A0-88D8-4BB2F3465C53}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Debug|Any CPU.ActiveCfg = Debug|x64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Debug|Any CPU.Build.0 = Debug|x64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Debug|ARM64.ActiveCfg = Debug|ARM64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Debug|ARM64.Build.0 = Debug|ARM64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Debug|x64.ActiveCfg = Debug|x64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Debug|x64.Build.0 = Debug|x64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Debug|x86.ActiveCfg = Debug|x86
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Debug|x86.Build.0 = Debug|x86
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Release|Any CPU.ActiveCfg = Release|x64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Release|Any CPU.Build.0 = Release|x64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Release|ARM64.ActiveCfg = Release|ARM64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Release|ARM64.Build.0 = Release|ARM64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Release|x64.ActiveCfg = Release|x64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Release|x64.Build.0 = Release|x64
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Release|x86.ActiveCfg = Release|x86
{340293B0-F46C-46A0-88D8-4BB2F3465C53}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
29 changes: 29 additions & 0 deletions build/windows/installer/Installer.wixproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Sdk="WixToolset.Sdk/4.0.0-rc.2">
<PropertyGroup>
<DebugType>none</DebugType>
<OutputName>installer</OutputName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="WixToolset.UI.wixext" Version="4.0.0-rc.2" />
<PackageReference Include="WixToolset.Heat" Version="4.0.0-rc.2" />
</ItemGroup>

<ItemGroup>
<HarvestDirectory Include="..\..\..\assets">
<ComponentGroupName>AssetsDirectory</ComponentGroupName>
<DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
<SuppressRootDirectory>false</SuppressRootDirectory>
</HarvestDirectory>
<BindPath Include="..\..\..\assets" />
</ItemGroup>

<ItemGroup>
<HarvestDirectory Include="..\..\..\credits">
<ComponentGroupName>CreditsDirectory</ComponentGroupName>
<DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
<SuppressRootDirectory>false</SuppressRootDirectory>
</HarvestDirectory>
<BindPath Include="..\..\..\credits" />
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions build/windows/installer/Package.en-us.wxl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!--
This file contains the declaration of all the localizable strings.
-->
<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
<String Id="DowngradeError" Value="A newer version of [ProductName] is already installed." />
</WixLocalization>
50 changes: 50 additions & 0 deletions build/windows/installer/Package.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<Package
Name="Foxtrot"
Manufacturer="Jan Hohenheim"
Version="0.1.6.0"

UpgradeCode="5b55f5ef-3eba-4782-8bd5-7711d414728d"
Scope="perUserOrMachine">
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />

<Media Id="1" Cabinet="myapplication.cab" EmbedCab="yes" />

<Property Id="ApplicationFolderName" Value="!(bind.Property.ProductName)" />

<!-- Installer Icon -->
<Icon Id="icon.ico" SourceFile="..\icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />

<!-- Sets the default installation folder -->
<StandardDirectory Id="ProgramFiles6432Folder">
<Directory Id="INSTALLFOLDER" Name="!(bind.Property.ProductName)" />
</StandardDirectory>

<!-- Shows a UI that allows customizing the install location -->
<ui:WixUI Id="WixUI_CustomInstallDir" InstallDirectory="INSTALLFOLDER" />

<Feature Id="Main">
<ComponentGroupRef Id="MainComponent" />
<ComponentRef Id="StartMenuShortcut" />
<ComponentGroupRef Id="AssetsDirectory" />
<ComponentGroupRef Id="CreditsDirectory" />
</Feature>

<!-- Installs the actual files -->
<ComponentGroup Id="MainComponent" Directory="INSTALLFOLDER">
<Component>
<File Id="Executable" Source="..\..\..\target\debug\foxtrot.exe" Vital="true" />
</Component>
</ComponentGroup>

<!-- Start menu shortcut -->
<!-- Source: https://wixtoolset.org/docs/v3/howtos/files_and_registry/create_start_menu_shortcut/ -->
<StandardDirectory Id="ProgramMenuFolder">
<Component Id="StartMenuShortcut" Guid="*">
<Shortcut Id="ApplicationStartMenuShortcut" Name="!(bind.Property.ProductName)" Target="[!Executable]" WorkingDirectory="INSTALLFOLDER" />
<RegistryValue Root="HKCU" Key="Software\!(bind.Property.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</StandardDirectory>
</Package>
</Wix>
6 changes: 6 additions & 0 deletions build/windows/installer/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "7.0.102",
"rollForward": "latestFeature"
}
}

0 comments on commit eb9e07b

Please sign in to comment.