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 5e78a80
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 3 deletions.
28 changes: 27 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ workflows:
only: /^v([0-9])+.([0-9])+.([0-9])+.*/
- cross-compile:
requires:
- build
- setup-and-lint
filters:
tags:
only: /^v([0-9])+.([0-9])+.([0-9])+.*/
Expand Down 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,23 @@ jobs:
name: Unit tests
command: go test ./...
- save_module_cache

windows-msi:
executor:
name: win/default
shell: powershell.exe
steps:
- attach_to_workspace
- run:
name: Install Wix Toolset
command: |
choco install wixtoolset
setx /m PATH "%PATH%;C:\Program Files (x86)\WiX Toolset v3.11\bin"
refreshenv
- run:
name: Build MSI
command: |
candle -arch x64 scripts/msi/opentelemetry-collector.wxs
light opentelemetry-collector.wixobj
# TODO publish msi - where should we put this?
# CircleCI artifact? On S3 somewhere?
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
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ install-tools:

.PHONY: otelcol
otelcol:
GO111MODULE=on CGO_ENABLED=0 go build -o ./bin/otelcol_$(GOOS)_$(GOARCH) $(BUILD_INFO) ./cmd/otelcol
GO111MODULE=on CGO_ENABLED=0 go build -o ./bin/otelcol_$(GOOS)_$(GOARCH)$(EXTENSION) $(BUILD_INFO) ./cmd/otelcol

.PHONY: run
run:
Expand Down Expand Up @@ -201,7 +201,7 @@ binaries-linux_arm64:

.PHONY: binaries-windows_amd64
binaries-windows_amd64:
GOOS=windows GOARCH=amd64 $(MAKE) binaries
GOOS=windows GOARCH=amd64 EXTENSION=.exe $(MAKE) binaries

# Definitions for ProtoBuf generation.

Expand Down 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 -dVersion=$(VERSION) -dConfig=$(CONFIG) scripts/msi/opentelemetry-collector.wxs
light opentelemetry-collector.wixobj
57 changes: 57 additions & 0 deletions scripts/msi/opentelemetry-collector.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!-- Use v0.0.1 if version is not supplied -->
<?ifdef Version?><?if $(var.Version) = ""?><?undef Version ?><?endif?><?endif?>
<?ifndef Version?><?define Version = "0.0.1" ?><?endif?>
<!-- Use default local config file if config path is not supplied -->
<?ifdef Config?><?if $(var.Config) = ""?><?undef Config ?><?endif?><?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="$(var.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 5e78a80

Please sign in to comment.