Refactor Windows Installer setup
Resolves #703 along with several other issues: * Build an x64 MSI for an x64 executable. This means the binary is installed to C:\Program Files, by default, rather than C:\Program Files (x86) without the ability to redirect it to 64-bit locations. * Environment change to PATH is not system-wide, which for a per-machine install it should be so all users who can access the executable have it in their PATH. * Environment change to PATH is not cleaned up when uninstalled. * RTF conversion of LICENSE was difficult to read. A simple conversion script is checked in to facilitate regenerating RTF from root LICENSE.
This commit is contained in:
parent
8f3b6749d7
commit
5fad092b9e
6 changed files with 144 additions and 42 deletions
14
.github/workflows/releases.yml
vendored
14
.github/workflows/releases.yml
vendored
|
|
@ -123,23 +123,17 @@ jobs:
|
|||
unzip -o *.zip && rm -v *.zip
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
- name: Install go-msi
|
||||
run: choco install -y "go-msi"
|
||||
- name: Prepare PATH
|
||||
shell: bash
|
||||
run: |
|
||||
echo "$WIX\\bin" >> $GITHUB_PATH
|
||||
echo "C:\\Program Files\\go-msi" >> $GITHUB_PATH
|
||||
uses: microsoft/setup-msbuild@v1.0.3
|
||||
- name: Build MSI
|
||||
id: buildmsi
|
||||
shell: bash
|
||||
env:
|
||||
ZIP_FILE: ${{ steps.download_exe.outputs.zip }}
|
||||
run: |
|
||||
mkdir -p build
|
||||
msi="$(basename "$ZIP_FILE" ".zip").msi"
|
||||
printf "::set-output name=msi::%s\n" "$msi"
|
||||
go-msi make --msi "$PWD/$msi" --out "$PWD/build" --version "${GITHUB_REF#refs/tags/}"
|
||||
name="$(basename "$ZIP_FILE" ".zip")"
|
||||
printf "::set-output name=msi::%s\n" "$name.msi"
|
||||
msbuild .\build\windows\gh.wixproj /p:SourceDir="$PWD" /p:OutputName="$name" /p:ProductVersion="${GITHUB_REF#refs/tags/}"
|
||||
- name: Obtain signing cert
|
||||
id: obtain_cert
|
||||
env:
|
||||
|
|
|
|||
24
build/windows/ConvertTo-Rtf.ps1
Normal file
24
build/windows/ConvertTo-Rtf.ps1
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Mandatory=$true, Position=0)]
|
||||
[string] $Path,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=1)]
|
||||
[string] $OutFile,
|
||||
|
||||
[Parameter()]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string] $FontFamily = 'Arial'
|
||||
)
|
||||
|
||||
$rtf = "{\rtf1\ansi\deff0{\fonttbl{\f0\fcharset0 $FontFamily;}}\pard\sa200\sl200\slmult1\fs20`n"
|
||||
foreach ($line in (Get-Content $Path)) {
|
||||
if (!$line) {
|
||||
$rtf += "\par`n"
|
||||
} else {
|
||||
$rtf += "$line`n"
|
||||
}
|
||||
}
|
||||
$rtf += '}'
|
||||
|
||||
$rtf | Set-Content $OutFile
|
||||
23
build/windows/LICENSE.rtf
Normal file
23
build/windows/LICENSE.rtf
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{\rtf1\ansi\deff0{\fonttbl{\f0\fcharset0 Arial;}}\pard\sa200\sl200\slmult1\fs20
|
||||
MIT License
|
||||
\par
|
||||
Copyright (c) 2019 GitHub Inc.
|
||||
\par
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
\par
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
\par
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
}
|
||||
35
build/windows/gh.wixproj
Normal file
35
build/windows/gh.wixproj
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
|
||||
<Platform Condition="'$(Platform)' == ''">x64</Platform>
|
||||
<ProductVersion Condition="'$(ProductVersion)' == ''">0.1.0</ProductVersion>
|
||||
<OutputName Condition="'$(OutputName)' == ''">$(MSBuildProjectName)</OutputName>
|
||||
<OutputType>package</OutputType>
|
||||
<RepoPath>$(MSBuildProjectDirectory)\..\..</RepoPath>
|
||||
<OutputPath>$(RepoPath)\bin\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<IntermediateOutputPath>$(RepoPath)\bin\obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
|
||||
<DefineConstants>
|
||||
$(DefineConstants);
|
||||
ProductVersion=$(ProductVersion);
|
||||
</DefineConstants>
|
||||
<DefineSolutionProperties>false</DefineSolutionProperties>
|
||||
<WixTargetsPath Condition="'$(WixTargetsPath)' == ''">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="gh.wxs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- Include directory containing LICENSE.rtf (run ConvertTo-Rtf to regenerate from root LICENSE) -->
|
||||
<BindInputPaths Include="$(MSBuildProjectDirectory)"/>
|
||||
|
||||
<!-- Include directories containing both user-specified output and unzipped release for ease -->
|
||||
<BindInputPaths Include="$(SourceDir)"/>
|
||||
<BindInputPaths Include="$(SourceDir)\bin"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WixExtension Include="WixUIExtension"/>
|
||||
<WixExtension Include="WixUtilExtension"/>
|
||||
</ItemGroup>
|
||||
<Import Project="$(WixTargetsPath)"/>
|
||||
</Project>
|
||||
58
build/windows/gh.wxs
Normal file
58
build/windows/gh.wxs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<?ifndef ProductVersion?>
|
||||
<?error ProductVersion property not defined?>
|
||||
<?endif?>
|
||||
|
||||
<!-- Define a unique UpgradeCode per platform -->
|
||||
<?define UpgradeCode=8CFB9531-B959-4E1B-AA2E-4AF0FFCC4AF4?>
|
||||
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Product Id="*" Name="GitHub CLI" Version="$(var.ProductVersion)" Language="1033" Manufacturer="GitHub, Inc." UpgradeCode="$(var.UpgradeCode)">
|
||||
<Package Compressed="yes" InstallerVersion="200" InstallScope="perMachine"/>
|
||||
<MediaTemplate EmbedCab="yes"/>
|
||||
|
||||
<!-- Remove older product(s) early but within the transaction -->
|
||||
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A newer version of !(bind.property.ProductName) is already installed."/>
|
||||
|
||||
<!-- Upgrade older x86 products -->
|
||||
<Upgrade Id="7C0A5736-5B8E-4176-B350-613FA2D8A1B3">
|
||||
<UpgradeVersion Maximum="$(var.ProductVersion)" Property="OLDERX86VERSIONDETECTED"/>
|
||||
</Upgrade>
|
||||
|
||||
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||
<Directory Id="ProgramFiles64Folder" Name="Program Files">
|
||||
<Directory Id="INSTALLDIR" Name="GitHub CLI"/>
|
||||
</Directory>
|
||||
</Directory>
|
||||
|
||||
<!-- Restore the INSTALLDIR if previously persisted to the registry -->
|
||||
<Property Id="INSTALLDIR">
|
||||
<RegistrySearch Id="InstallDir" Root="HKLM" Key="SOFTWARE\GitHub\CLI" Name="InstallDir" Type="directory"/>
|
||||
</Property>
|
||||
|
||||
<Feature Id="DefaultFeature" ConfigurableDirectory="INSTALLDIR">
|
||||
<!-- @Guid will be automatically and durably assigned based on key path -->
|
||||
<Component Directory="INSTALLDIR">
|
||||
<File Name="gh.exe"/>
|
||||
</Component>
|
||||
|
||||
<!-- Persist the INSTALLDIR and restore it in subsequent installs -->
|
||||
<Component Directory="INSTALLDIR">
|
||||
<RegistryValue Root="HKLM" Key="SOFTWARE\GitHub\CLI" Name="InstallDir" Type="string" Value="[INSTALLDIR]"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="Env" Guid="94FAAC3D-4478-431C-8497-FBA55DCFB249" Directory="TARGETDIR">
|
||||
<Environment Id="Path" Action="set" Name="PATH" Part="last" System="yes" Value="[INSTALLDIR]"/>
|
||||
</Component>
|
||||
</Feature>
|
||||
|
||||
<!-- Broadcast environment variable changes -->
|
||||
<CustomActionRef Id="WixBroadcastEnvironmentChange" />
|
||||
|
||||
<!-- Use WixUI showing license and allowing user-specified INSTALLDIR -->
|
||||
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"/>
|
||||
<UIRef Id="WixUI_InstallDir"/>
|
||||
<WixVariable Id="WixUILicenseRtf" Value="LICENSE.rtf"/>
|
||||
</Product>
|
||||
</Wix>
|
||||
32
wix.json
32
wix.json
|
|
@ -1,32 +0,0 @@
|
|||
{
|
||||
"product": "GitHub CLI",
|
||||
"company": "GitHub, Inc.",
|
||||
"license": "LICENSE",
|
||||
"upgrade-code": "7c0a5736-5b8e-4176-b350-613fa2d8a1b3",
|
||||
"files": {
|
||||
"guid": "6e6dcb19-3cf6-46d1-ac56-c6fb39485c9d",
|
||||
"items": [
|
||||
"bin/gh.exe"
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"guid": "94faac3d-4478-431c-8497-fba55dcfb249",
|
||||
"vars": [
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "[INSTALLDIR]",
|
||||
"permanent": "yes",
|
||||
"system": "no",
|
||||
"action": "set",
|
||||
"part": "last"
|
||||
}
|
||||
]
|
||||
},
|
||||
"shortcuts": {},
|
||||
"choco": {
|
||||
"description": "Use GitHub from the CLI",
|
||||
"project-url": "https://github.com/cli/cli",
|
||||
"tags": "github cli git",
|
||||
"license-url": "https://github.com/cli/cli/blob/trunk/LICENSE"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue