Skip to content

Commit

Permalink
Added wix file and build step to create msi
Browse files Browse the repository at this point in the history
  • Loading branch information
james-bebbington committed Jun 22, 2020
1 parent a8b8ba4 commit c856f6f
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ workflows:
filters:
tags:
only: /^v([0-9])+.([0-9])+.([0-9])+.*/
- windows-msi:
requires:
- cross-compile
filters:
tags:
only: /^v([0-9])+.([0-9])+.([0-9])+.*/
- publish-stable:
requires:
- cross-compile
Expand Down Expand Up @@ -262,3 +268,18 @@ jobs:
name: Unit tests
command: go test ./...
- save_module_cache

windows-msi:
executor:
name: win/default
shell: powershell.exe
environment:
GOPATH=~/go
steps:
- attach_to_workspace
- run:
name: Build MSI
command: |
candle -arch x64 -dConfig=$(CONFIG) scripts/msi/opentelemetry-collector.wxs
light opentelemetry-collector.wixobj
# TODO publish msi?
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ coverage.txt
coverage_all.txt
coverage_old.txt
coverage.html

# Wix
*.wixobj
*.wixpdb
*.msi
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,17 @@ genproto_sub:
# to proto and after running `make genproto`
genpdata:
go run cmd/pdatagen/main.go

# The following commands can only be run on Windows (use WSL2 or Cygwin,
# or run equivalent commands directly in Cmd/Powershell)

.PHONY: windows-install-tools-msi
choco install wixtoolset

.PHONY: windows-build-msi
all: binaries-windows_amd64 windows-msi

.PHONY: windows-msi
msi-windows:
candle -arch x64 -dConfig=$(CONFIG) scripts/msi/opentelemetry-collector.wxs
light opentelemetry-collector.wixobj
54 changes: 54 additions & 0 deletions scripts/msi/opentelemetry-collector.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!-- Fall back to default local config file if none is supplied -->
<?if $(var.Config) = ""?><?undef Config ?><?endif?>
<?ifndef Config?><?define Config = "./examples/otel-local-config.yaml" ?><?endif?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="B7C263DD-95A5-436A-A025-DCA5200C2BE3" Name="OpenTelemetry Collector" Version="$(env.VERSION)" Manufacturer="OpenTelemetry" Language="1033">
<Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package"/>
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
<Icon Id="ProductIcon" SourceFile="scripts/msi/opentelemetry.ico"/>
<Property Id="ARPPRODUCTICON" Value="ProductIcon"/>
<Property Id="ARPHELPLINK" Value="https://opentelemetry.io/"/>
<Property Id="ARPURLINFOABOUT" Value="https://opentelemetry.io/"/>
<Property Id="ARPNOREPAIR" Value="1"/>
<Property Id="ARPNOMODIFY" Value="1"/>

<Feature Id="Feature" Level="1">
<ComponentRef Id="ApplicationComponent"/>
</Feature>

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLDIR" Name="OpenTelemetry Collector">
<Component Id="ApplicationComponent" Guid="1207C3C4-1830-4DC8-8A7B-2BD7DBE45BC3">
<!-- Files to include -->
<File Id="ExecutableFile" Name="otelcol.exe" KeyPath="yes" Source="bin/otelcol_windows_amd64.exe"/>
<File Id="DefaultConfigFile" Name="config.yaml" Source="$(var.Config)" />
<!-- Since we may have overridden the config file (see below), we need to explicitly remove it on uninstall -->
<RemoveFile Id="RemoveConfigFile" Name="config.yaml" On="uninstall" />

<ServiceInstall
Id="Sevice"
Name="OpenTelemetry Collector"
DisplayName="OpenTelemetry Collector"
Description="Collects, processes, and exports telemetry from various configurable sources."
Type="ownProcess"
Vital="yes"
Start="auto"
Account="LocalSystem"
ErrorControl="normal"
Arguments=" --config=&quot;[INSTALLDIR]config.yaml&quot;"
Interactive="no" />
<ServiceControl Id="StartStopRemove" Name="OpenTelemetry Collector" Start="install" Stop="both" Remove="uninstall" Wait="yes" />
</Component>
</Directory>
</Directory>
</Directory>

<!-- If CONFIG is supplied as a custom argument when installing, replace config.yaml with the specified file -->
<CustomAction Id="CopyConfig" ExeCommand="xcopy /y &quot;[CONFIG]&quot; &quot;[INSTALLDIR]config.yaml*&quot;" Directory="INSTALLDIR" Impersonate="no" Execute="deferred" Return="check" />
<InstallExecuteSequence>
<Custom Action="CopyConfig" After="InstallFiles">CONFIG AND NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
</Wix>
Binary file added scripts/msi/opentelemetry.ico
Binary file not shown.

0 comments on commit c856f6f

Please sign in to comment.