Skip to content

Commit 7ef3abe

Browse files
author
Nate Smith
authored
Merge pull request cli#4276 from heaths/issue703
Refactor Windows Installer setup
2 parents 2e07d0f + bad38fd commit 7ef3abe

File tree

5 files changed

+175
-42
lines changed

5 files changed

+175
-42
lines changed

.github/workflows/releases.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,19 @@ jobs:
132132
unzip -o *.zip && rm -v *.zip
133133
env:
134134
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
135-
- name: Install go-msi
136-
run: choco install -y "go-msi"
137135
- name: Prepare PATH
138-
shell: bash
139-
run: |
140-
echo "$WIX\\bin" >> $GITHUB_PATH
141-
echo "C:\\Program Files\\go-msi" >> $GITHUB_PATH
136+
id: setupmsbuild
137+
uses: microsoft/setup-msbuild@v1.0.3
142138
- name: Build MSI
143139
id: buildmsi
144140
shell: bash
145141
env:
146142
ZIP_FILE: ${{ steps.download_exe.outputs.zip }}
143+
MSBUILD_PATH: ${{ steps.setupmsbuild.outputs.msbuildPath }}
147144
run: |
148-
mkdir -p build
149-
msi="$(basename "$ZIP_FILE" ".zip").msi"
150-
printf "::set-output name=msi::%s\n" "$msi"
151-
go-msi make --msi "$PWD/$msi" --out "$PWD/build" --version "${GITHUB_REF#refs/tags/}"
145+
name="$(basename "$ZIP_FILE" ".zip")"
146+
version="$(echo -e ${GITHUB_REF#refs/tags/v} | sed s/-.*$//)"
147+
"${MSBUILD_PATH}\MSBuild.exe" ./build/windows/gh.wixproj -p:SourceDir="$PWD" -p:OutputPath="$PWD" -p:OutputName="$name" -p:ProductVersion="$version"
152148
- name: Obtain signing cert
153149
id: obtain_cert
154150
env:

build/windows/gh.wixproj

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration>Release</Configuration>
5+
<Platform Condition="'$(Platform)' == ''">x64</Platform>
6+
<ProductVersion Condition="'$(ProductVersion)' == ''">0.1.0</ProductVersion>
7+
<OutputName Condition="'$(OutputName)' == ''">$(MSBuildProjectName)</OutputName>
8+
<OutputType>package</OutputType>
9+
<RepoPath>$([MSBuild]::NormalizeDirectory($(MSBuildProjectDirectory)\..\..))</RepoPath>
10+
<OutputPath Condition="'$(OutputPath)' == ''">$(RepoPath)bin\$(Platform)\</OutputPath>
11+
<IntermediateOutputPath>$(RepoPath)bin\obj\$(Platform)\</IntermediateOutputPath>
12+
<DefineConstants>
13+
$(DefineConstants);
14+
ProductVersion=$(ProductVersion);
15+
</DefineConstants>
16+
<SuppressIces Condition="'$(Platform)' == 'arm' Or '$(Platform)' == 'arm64'">ICE39</SuppressIces>
17+
<DefineSolutionProperties>false</DefineSolutionProperties>
18+
<WixTargetsPath Condition="'$(WixTargetsPath)' == ''">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
19+
</PropertyGroup>
20+
<ItemGroup>
21+
<Compile Include="gh.wxs"/>
22+
<Compile Include="ui.wxs"/>
23+
</ItemGroup>
24+
<ItemGroup>
25+
<!-- Include directories containing both user-specified output and unzipped release for ease -->
26+
<BindInputPaths Include="$(SourceDir)"/>
27+
<BindInputPaths Include="$(SourceDir)\bin"/>
28+
</ItemGroup>
29+
<ItemGroup>
30+
<WixExtension Include="WixUIExtension"/>
31+
<WixExtension Include="WixUtilExtension"/>
32+
</ItemGroup>
33+
<Target Name="SetStepOutput" AfterTargets="Build" Condition="'$(GITHUB_ACTIONS)' != ''">
34+
<!-- Make sure the correct target path is always set as the step output -->
35+
<Message Importance="high" Text="::set-output name=msi::$(TargetPath)"/>
36+
</Target>
37+
<Import Project="$(WixTargetsPath)"/>
38+
</Project>

build/windows/gh.wxs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<?ifndef ProductVersion?>
4+
<?error ProductVersion property not defined?>
5+
<?endif?>
6+
7+
<!-- Define a unique UpgradeCode per platform -->
8+
<?if $(var.Platform) = "x64"?>
9+
<?define InstallerVersion = "200"?>
10+
<?define UpgradeCode = "8CFB9531-B959-4E1B-AA2E-4AF0FFCC4AF4"?>
11+
<?define ProgramFilesFolder = "ProgramFiles64Folder"?>
12+
<?elseif $(var.Platform) = "x86"?>
13+
<?define InstallerVersion = "200"?>
14+
<?define UpgradeCode = "767EC5D2-C8F0-4912-9901-45E21F59A284"?>
15+
<?define ProgramFilesFolder = "ProgramFilesFolder"?>
16+
<?elseif $(var.Platform) = "arm64"?>
17+
<?define InstallerVersion = "500"?>
18+
<?define UpgradeCode = "5D15E95C-F979-41B0-826C-C33C8CB5A7EB"?>
19+
<?define ProgramFilesFolder = "ProgramFiles64Folder"?>
20+
<?elseif $(var.Platform) = "arm"?>
21+
<?define InstallerVersion = "500"?>
22+
<?define UpgradeCode = "DDDE52AA-42DA-404B-9238-77DC86117CFF"?>
23+
<?define ProgramFilesFolder = "ProgramFilesFolder"?>
24+
<?endif?>
25+
26+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
27+
<Product Id="*" Name="GitHub CLI" Version="$(var.ProductVersion)" Language="1033" Manufacturer="GitHub, Inc." UpgradeCode="$(var.UpgradeCode)">
28+
<Package Compressed="yes" InstallerVersion="$(var.InstallerVersion)" InstallScope="perMachine"/>
29+
<MediaTemplate EmbedCab="yes"/>
30+
31+
<!-- Remove older product(s) early but within the transaction -->
32+
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A newer version of !(bind.property.ProductName) is already installed."/>
33+
34+
<!-- Upgrade older x86 products -->
35+
<Upgrade Id="7C0A5736-5B8E-4176-B350-613FA2D8A1B3">
36+
<UpgradeVersion Maximum="$(var.ProductVersion)" Property="OLDERX86VERSIONDETECTED"/>
37+
</Upgrade>
38+
39+
<Directory Id="TARGETDIR" Name="SourceDir">
40+
<Directory Id="$(var.ProgramFilesFolder)" Name="Program Files">
41+
<Directory Id="INSTALLDIR" Name="GitHub CLI"/>
42+
</Directory>
43+
</Directory>
44+
45+
<!-- Restore the INSTALLDIR if previously persisted to the registry -->
46+
<Property Id="INSTALLDIR">
47+
<RegistrySearch Id="InstallDir" Root="HKLM" Key="SOFTWARE\GitHub\CLI" Name="InstallDir" Type="directory"/>
48+
</Property>
49+
50+
<Feature Id="DefaultFeature" ConfigurableDirectory="INSTALLDIR">
51+
<!-- @Guid will be automatically and durably assigned based on key path -->
52+
<Component Directory="INSTALLDIR">
53+
<File Name="gh.exe"/>
54+
<Environment Id="Path" Action="set" Name="PATH" Part="last" System="yes" Value="[INSTALLDIR]"/>
55+
</Component>
56+
57+
<!-- Persist the INSTALLDIR and restore it in subsequent installs -->
58+
<Component Directory="INSTALLDIR">
59+
<RegistryValue Root="HKLM" Key="SOFTWARE\GitHub\CLI" Name="InstallDir" Type="string" Value="[INSTALLDIR]"/>
60+
</Component>
61+
62+
<Component Id="OlderX86Env" Guid="50C15744-A674-404B-873C-6B58957E2A32" Directory="TARGETDIR" Win64="no">
63+
<Condition><![CDATA[OLDERX86VERSIONDETECTED]]></Condition>
64+
65+
<!-- Clean up the old x86 package default directory from the user environment -->
66+
<Environment Id="OlderX86Path" Action="remove" Name="PATH" Part="last" System="no" Value="[ProgramFilesFolder]GitHub CLI\"/>
67+
</Component>
68+
</Feature>
69+
70+
<!-- Broadcast environment variable changes -->
71+
<CustomActionRef Id="WixBroadcastEnvironmentChange" />
72+
73+
<!-- Use customized WixUI_InstallDir that removes WixUI_LicenseAgreementDlg -->
74+
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"/>
75+
<UIRef Id="GitHubCLI_InstallDir"/>
76+
</Product>
77+
</Wix>

build/windows/ui.wxs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3+
<Fragment>
4+
<UI Id="GitHubCLI_InstallDir">
5+
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
6+
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
7+
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
8+
9+
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
10+
<Property Id="WixUI_Mode" Value="InstallDir" />
11+
12+
<DialogRef Id="BrowseDlg" />
13+
<DialogRef Id="DiskCostDlg" />
14+
<DialogRef Id="ErrorDlg" />
15+
<DialogRef Id="FatalError" />
16+
<DialogRef Id="FilesInUse" />
17+
<DialogRef Id="MsiRMFilesInUse" />
18+
<DialogRef Id="PrepareDlg" />
19+
<DialogRef Id="ProgressDlg" />
20+
<DialogRef Id="ResumeDlg" />
21+
<DialogRef Id="UserExit" />
22+
23+
<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
24+
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
25+
26+
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
27+
28+
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">NOT Installed</Publish>
29+
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
30+
31+
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
32+
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
33+
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
34+
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
35+
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
36+
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
37+
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
38+
39+
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1">NOT Installed</Publish>
40+
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
41+
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>
42+
43+
<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
44+
45+
<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
46+
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
47+
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
48+
49+
<Property Id="ARPNOMODIFY" Value="1" />
50+
</UI>
51+
52+
<UIRef Id="WixUI_Common" />
53+
</Fragment>
54+
</Wix>

wix.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)