Skip to content

Commit 4e8f050

Browse files
authoredMay 31, 2024··
Add Windows MSI to the release (#560)
* Add Windows MSI to the release * Add MSI support to generate-goreleaser * Setup wixl * Remove InstallPrivileges and InstallScope from wxs * Remove RemoveFile element * Directory is not supported on CustomAction * Remove path prefix from opentelemetry.ico * Path to opentelemetry.ico * Use sys.SOURCEFILEDIR to locate .ico file * Use sys.CURRENTDIR to locate ico file * Remove path not present on GH execution * Try to locate opentelmetry.ico * Fix location of ico file when building MSI * CURRENTDIR since SOURCEFILEDIR gives the wxs file * Remove GH action step to locate ico file * Temporarily duplicate windows folder for otelcol-contrib distribution * Temporary action to upload artifacts * Register event source for the collector * Use distribution name as service name * Better provider name to show up on the event viewer * Match both installer.wxs * Add COLLECTOR_SVC_ARGS property * Use ubuntu 22.04 in order to get latest wixl It has proper support for CustomAction. * CURRENTDIR didn't work with wixl 101 SOURCEFILEDIR didn'1 work with wixl 100 ... * Change the location of opentelemetry.ico * Move wxs source * Use the binary name as event provider name * Remove temporary action to upload artifacts
1 parent cc3161a commit 4e8f050

13 files changed

+227
-9
lines changed
 

‎.github/workflows/base-ci-goreleaser.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
GOARCH: arm
3333
- GOOS: windows
3434
GOARCH: s390x
35-
runs-on: ubuntu-20.04
35+
runs-on: ubuntu-22.04
3636

3737
steps:
3838
- name: Checkout
@@ -45,6 +45,11 @@ jobs:
4545
with:
4646
platforms: arm64,ppc64le,linux/arm/v7,s390x
4747

48+
- name: Setup wixl
49+
run: |
50+
sudo apt-get update
51+
sudo apt-get install -y wixl
52+
4853
- name: Setup Docker Buildx
4954
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
5055

‎.github/workflows/base-release.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
GOARCH: arm
3333
- GOOS: windows
3434
GOARCH: s390x
35-
runs-on: ubuntu-20.04
35+
runs-on: ubuntu-22.04
3636

3737
steps:
3838
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
@@ -95,7 +95,7 @@ jobs:
9595

9696
release:
9797
name: ${{ inputs.distribution }} Release
98-
runs-on: ubuntu-20.04
98+
runs-on: ubuntu-22.04
9999
needs: prepare
100100

101101
permissions:

‎.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
build:
1111
name: Build
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

‎CONTRIBUTING.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ This repository contains a set of resources that ultimately results in OpenTelem
66

77
### Distribution directory
88

9-
Each distribution has its own directory at the root of this repository, such as `opentelemetry-collector`. Within each one of those, you'll find at least two files:
9+
Each distribution has its own directory under the [`distributions`](./distributions/) folder, such as [`otelcol`](./distributions/otelcol/).
10+
Within each one of those, you'll find at least two files:
1011

1112
- `Dockerfile`, determining how to build the container image for this distribution
1213
- `manifest.yaml`, which is used with [ocb](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder) to generate the sources for the distribution.

‎cmd/goreleaser/internal/configure.go

+23-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import (
2424
"path"
2525
"strings"
2626

27-
"github.com/goreleaser/goreleaser/pkg/config"
28-
"github.com/goreleaser/nfpm/v2/files"
27+
"github.com/goreleaser/goreleaser-pro/pkg/config"
2928
)
3029

3130
const ArmArch = "arm"
@@ -45,6 +44,7 @@ func Generate(dist string) config.Project {
4544
Env: []string{"COSIGN_YES=true"},
4645
Builds: Builds(dist),
4746
Archives: Archives(dist),
47+
MSI: WinPackages(dist),
4848
NFPMs: Packages(dist),
4949
Dockers: DockerImages(dist),
5050
DockerManifests: DockerManifests(dist),
@@ -102,6 +102,26 @@ func Archive(dist string) config.Archive {
102102
}
103103
}
104104

105+
func WinPackages(dist string) []config.MSI {
106+
return []config.MSI{
107+
WinPackage(dist),
108+
}
109+
}
110+
111+
// Package configures goreleaser to build a Windows MSI package.
112+
// https://goreleaser.com/customization/msi/
113+
func WinPackage(dist string) config.MSI {
114+
return config.MSI{
115+
ID: dist,
116+
Name: fmt.Sprintf("%s_{{ .Version }}_{{ .Os }}_{{ .MsiArch }}", dist),
117+
WXS: "windows-installer.wxs",
118+
Files: []string{
119+
"config.yaml",
120+
"opentelemetry.ico",
121+
},
122+
}
123+
}
124+
105125
func Packages(dist string) (r []config.NFPM) {
106126
return []config.NFPM{
107127
Package(dist),
@@ -127,7 +147,7 @@ func Package(dist string) config.NFPM {
127147
PostInstall: "postinstall.sh",
128148
PreRemove: "preremove.sh",
129149
},
130-
Contents: files.Contents{
150+
Contents: config.NFPMContents{
131151
{
132152
Source: fmt.Sprintf("%s.service", dist),
133153
Destination: path.Join("/lib", "systemd", "system", fmt.Sprintf("%s.service", dist)),

‎distributions/otelcol-contrib/.goreleaser.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ partial:
33
project_name: opentelemetry-collector-releases
44
env:
55
- COSIGN_YES=true
6+
msi:
7+
- id: otelcol-contrib
8+
name: otelcol-contrib_{{ .Version }}_{{ .Os }}_{{ .MsiArch }}
9+
wxs: windows-installer.wxs
10+
extra_files:
11+
- config.yaml
12+
- opentelemetry.ico
613
builds:
714
- id: otelcol-contrib
815
goos:
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
2+
<Product
3+
Name="OpenTelemetry Collector ({{ .Version }}) - {{ .Binary }} distribution"
4+
Id="B250A214-D463-4E9B-8902-1DE5C19EA951"
5+
UpgradeCode="B7C263DD-95A5-436A-A025-DCA5200C2BE3"
6+
Version="{{ .Version }}"
7+
Manufacturer="OpenTelemetry"
8+
Language="1033">
9+
10+
<Package
11+
InstallerVersion="200"
12+
Compressed="yes"
13+
Comments="Windows Installer Package"
14+
InstallScope="perMachine"/>
15+
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
16+
<Icon Id="ProductIcon" SourceFile="opentelemetry.ico"/>
17+
<Property Id="ARPPRODUCTICON" Value="ProductIcon"/>
18+
<Property Id="ARPHELPLINK" Value="https://opentelemetry.io/"/>
19+
<Property Id="ARPURLINFOABOUT" Value="https://opentelemetry.io/"/>
20+
<Property Id="ARPNOREPAIR" Value="1"/>
21+
<Property Id="ARPNOMODIFY" Value="1"/>
22+
23+
<MajorUpgrade
24+
DowngradeErrorMessage="A later version of OpenTelemetry Collector already installed. Setup will now exit."/>
25+
26+
<Feature Id="Feature" Level="1">
27+
<ComponentRef Id="ApplicationComponent"/>
28+
</Feature>
29+
30+
<Property Id="COLLECTOR_SVC_ARGS"/>
31+
<CustomAction
32+
Id="SetCollectorSvcArgs"
33+
Property="COLLECTOR_SVC_ARGS"
34+
Value="--config &quot;[INSTALLDIR]config.yaml&quot;"/>
35+
36+
<InstallExecuteSequence>
37+
<Custom Action="SetCollectorSvcArgs" Before="InstallFiles">NOT COLLECTOR_SVC_ARGS</Custom>
38+
</InstallExecuteSequence>
39+
40+
<Directory Id="TARGETDIR" Name="SourceDir">
41+
<Directory Id="ProgramFiles64Folder">
42+
<Directory Id="INSTALLDIR" Name="OpenTelemetry Collector">
43+
<Component Id="ApplicationComponent" Guid="1207C3C4-1830-4DC8-8A7B-2BD7DBE45BC3">
44+
<!-- Files to include -->
45+
<File
46+
Id="{{ .Binary }}.exe"
47+
Name="{{ .Binary }}.exe"
48+
Source="{{ .Binary }}.exe"
49+
KeyPath="yes"/>
50+
<File
51+
Id="config.yaml"
52+
Name="config.yaml"
53+
Source="config.yaml"/>
54+
55+
<ServiceInstall
56+
Id="Sevice"
57+
Name="{{ .Binary }}"
58+
DisplayName="OpenTelemetry Collector"
59+
Description="Collects, processes, and exports telemetry from various configurable sources."
60+
Type="ownProcess"
61+
Vital="yes"
62+
Start="auto"
63+
Account="LocalSystem"
64+
ErrorControl="normal"
65+
Arguments="[COLLECTOR_SVC_ARGS]"
66+
Interactive="no"/>
67+
<ServiceControl
68+
Id="StartStopRemoveService"
69+
Name="{{ .Binary }}"
70+
Start="install"
71+
Stop="both"
72+
Remove="uninstall"
73+
Wait="yes"/>
74+
75+
<RegistryKey
76+
Root="HKLM"
77+
Key="SYSTEM\CurrentControlSet\Services\EventLog\Application\{{ .Binary }}">
78+
<RegistryValue
79+
Type="expandable"
80+
Name="EventMessageFile"
81+
Value="%SystemRoot%\System32\EventCreate.exe"/>
82+
</RegistryKey>
83+
</Component>
84+
</Directory>
85+
</Directory>
86+
</Directory>
87+
</Product>
88+
</Wix>

‎distributions/otelcol/.goreleaser.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ partial:
33
project_name: opentelemetry-collector-releases
44
env:
55
- COSIGN_YES=true
6+
msi:
7+
- id: otelcol
8+
name: otelcol_{{ .Version }}_{{ .Os }}_{{ .MsiArch }}
9+
wxs: windows-installer.wxs
10+
extra_files:
11+
- config.yaml
12+
- opentelemetry.ico
613
builds:
714
- id: otelcol
815
goos:
269 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
2+
<Product
3+
Name="OpenTelemetry Collector ({{ .Version }}) - {{ .Binary }} distribution"
4+
Id="B250A214-D463-4E9B-8902-1DE5C19EA951"
5+
UpgradeCode="B7C263DD-95A5-436A-A025-DCA5200C2BE3"
6+
Version="{{ .Version }}"
7+
Manufacturer="OpenTelemetry"
8+
Language="1033">
9+
10+
<Package
11+
InstallerVersion="200"
12+
Compressed="yes"
13+
Comments="Windows Installer Package"
14+
InstallScope="perMachine"/>
15+
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
16+
<Icon Id="ProductIcon" SourceFile="opentelemetry.ico"/>
17+
<Property Id="ARPPRODUCTICON" Value="ProductIcon"/>
18+
<Property Id="ARPHELPLINK" Value="https://opentelemetry.io/"/>
19+
<Property Id="ARPURLINFOABOUT" Value="https://opentelemetry.io/"/>
20+
<Property Id="ARPNOREPAIR" Value="1"/>
21+
<Property Id="ARPNOMODIFY" Value="1"/>
22+
23+
<MajorUpgrade
24+
DowngradeErrorMessage="A later version of OpenTelemetry Collector already installed. Setup will now exit."/>
25+
26+
<Feature Id="Feature" Level="1">
27+
<ComponentRef Id="ApplicationComponent"/>
28+
</Feature>
29+
30+
<Property Id="COLLECTOR_SVC_ARGS"/>
31+
<CustomAction
32+
Id="SetCollectorSvcArgs"
33+
Property="COLLECTOR_SVC_ARGS"
34+
Value="--config &quot;[INSTALLDIR]config.yaml&quot;"/>
35+
36+
<InstallExecuteSequence>
37+
<Custom Action="SetCollectorSvcArgs" Before="InstallFiles">NOT COLLECTOR_SVC_ARGS</Custom>
38+
</InstallExecuteSequence>
39+
40+
<Directory Id="TARGETDIR" Name="SourceDir">
41+
<Directory Id="ProgramFiles64Folder">
42+
<Directory Id="INSTALLDIR" Name="OpenTelemetry Collector">
43+
<Component Id="ApplicationComponent" Guid="1207C3C4-1830-4DC8-8A7B-2BD7DBE45BC3">
44+
<!-- Files to include -->
45+
<File
46+
Id="{{ .Binary }}.exe"
47+
Name="{{ .Binary }}.exe"
48+
Source="{{ .Binary }}.exe"
49+
KeyPath="yes"/>
50+
<File
51+
Id="config.yaml"
52+
Name="config.yaml"
53+
Source="config.yaml"/>
54+
55+
<ServiceInstall
56+
Id="Sevice"
57+
Name="{{ .Binary }}"
58+
DisplayName="OpenTelemetry Collector"
59+
Description="Collects, processes, and exports telemetry from various configurable sources."
60+
Type="ownProcess"
61+
Vital="yes"
62+
Start="auto"
63+
Account="LocalSystem"
64+
ErrorControl="normal"
65+
Arguments="[COLLECTOR_SVC_ARGS]"
66+
Interactive="no"/>
67+
<ServiceControl
68+
Id="StartStopRemoveService"
69+
Name="{{ .Binary }}"
70+
Start="install"
71+
Stop="both"
72+
Remove="uninstall"
73+
Wait="yes"/>
74+
75+
<RegistryKey
76+
Root="HKLM"
77+
Key="SYSTEM\CurrentControlSet\Services\EventLog\Application\{{ .Binary }}">
78+
<RegistryValue
79+
Type="expandable"
80+
Name="EventMessageFile"
81+
Value="%SystemRoot%\System32\EventCreate.exe"/>
82+
</RegistryKey>
83+
</Component>
84+
</Directory>
85+
</Directory>
86+
</Directory>
87+
</Product>
88+
</Wix>

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.21
55
toolchain go1.21.7
66

77
require (
8-
github.com/goreleaser/goreleaser v1.25.1
8+
github.com/goreleaser/goreleaser-pro v1.25.1-pro
99
github.com/goreleaser/nfpm/v2 v2.37.1
1010
gopkg.in/yaml.v3 v3.0.1
1111
)

‎go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ github.com/goreleaser/fileglob v1.3.0 h1:/X6J7U8lbDpQtBvGcwwPS6OpzkNVlVEsFUVRx9+
2121
github.com/goreleaser/fileglob v1.3.0/go.mod h1:Jx6BoXv3mbYkEzwm9THo7xbr5egkAraxkGorbJb4RxU=
2222
github.com/goreleaser/goreleaser v1.25.1 h1:a9skjeROotTN5GPPJDHDfhmOK4n13cBgJ34sTdXRDN0=
2323
github.com/goreleaser/goreleaser v1.25.1/go.mod h1:nsbhCYp9eImbE2fyd9/3Tgv5hjuGuDIQRoBozEUEYbc=
24+
github.com/goreleaser/goreleaser-pro v1.25.1-pro h1:NOoSx96oAK0zNA1+hiL0p6pY1DWL101kwPmpmkiExXk=
25+
github.com/goreleaser/goreleaser-pro v1.25.1-pro/go.mod h1:7q9HURJC4ZYBT9VyX3XlqjK0kwe5QbG/VIUAJSP3CKc=
2426
github.com/goreleaser/nfpm/v2 v2.37.1 h1:RUmeEt8OlEVeSzKRrO5Vl5qVWCtUwx4j9uivGuRo5fw=
2527
github.com/goreleaser/nfpm/v2 v2.37.1/go.mod h1:q8+sZXFqn106/eGw+9V+I8+izFxZ/sJjrhwmEUxXhUg=
2628
github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI=

0 commit comments

Comments
 (0)
Please sign in to comment.