Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows MSI to the release #560

Merged
merged 28 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6f010ac
Add Windows MSI to the release
pjanotti May 21, 2024
c32d476
Add MSI support to generate-goreleaser
pjanotti May 21, 2024
a58435d
Setup wixl
pjanotti May 21, 2024
68f396f
Remove InstallPrivileges and InstallScope from wxs
pjanotti May 22, 2024
29673f5
Remove RemoveFile element
pjanotti May 22, 2024
59da855
Directory is not supported on CustomAction
pjanotti May 22, 2024
ce52f3d
Remove path prefix from opentelemetry.ico
pjanotti May 22, 2024
a16feef
Path to opentelemetry.ico
pjanotti May 22, 2024
459cb9b
Use sys.SOURCEFILEDIR to locate .ico file
pjanotti May 22, 2024
cef70da
Use sys.CURRENTDIR to locate ico file
pjanotti May 22, 2024
fb8ed65
Remove path not present on GH execution
pjanotti May 22, 2024
599b2cb
Try to locate opentelmetry.ico
pjanotti May 23, 2024
2791692
Fix location of ico file when building MSI
pjanotti May 23, 2024
b02cba8
CURRENTDIR since SOURCEFILEDIR gives the wxs file
pjanotti May 23, 2024
2d78d20
Remove GH action step to locate ico file
pjanotti May 23, 2024
d9afe65
Temporarily duplicate windows folder for otelcol-contrib distribution
pjanotti May 23, 2024
787dc72
Temporary action to upload artifacts
pjanotti May 23, 2024
5a000ac
Register event source for the collector
pjanotti May 28, 2024
30ad144
Use distribution name as service name
pjanotti May 28, 2024
5bfe10f
Better provider name to show up on the event viewer
pjanotti May 29, 2024
b8ece30
Match both installer.wxs
pjanotti May 29, 2024
c60f97c
Add COLLECTOR_SVC_ARGS property
pjanotti May 29, 2024
51f3eb6
Use ubuntu 22.04 in order to get latest wixl
pjanotti May 30, 2024
68dd254
CURRENTDIR didn't work with wixl 101
pjanotti May 30, 2024
dc7339f
Change the location of opentelemetry.ico
pjanotti May 30, 2024
3ecb3b8
Move wxs source
pjanotti May 30, 2024
9c49554
Use the binary name as event provider name
pjanotti May 30, 2024
d4395d7
Remove temporary action to upload artifacts
pjanotti May 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/base-ci-goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
GOARCH: arm
- GOOS: windows
GOARCH: s390x
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout
Expand All @@ -45,6 +45,11 @@ jobs:
with:
platforms: arm64,ppc64le,linux/arm/v7,s390x

- name: Setup wixl
run: |
sudo apt-get update
sudo apt-get install -y wixl

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/base-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
GOARCH: arm
- GOOS: windows
GOARCH: s390x
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:

release:
name: ${{ inputs.distribution }} Release
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: prepare

permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build:
name: Build
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ This repository contains a set of resources that ultimately results in OpenTelem

### Distribution directory

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:
Each distribution has its own directory under the [`distributions`](./distributions/) folder, such as [`otelcol`](./distributions/otelcol/).
Within each one of those, you'll find at least two files:

- `Dockerfile`, determining how to build the container image for this distribution
- `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.
Expand Down
26 changes: 23 additions & 3 deletions cmd/goreleaser/internal/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import (
"path"
"strings"

"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/nfpm/v2/files"
"github.com/goreleaser/goreleaser-pro/pkg/config"
)

const ArmArch = "arm"
Expand All @@ -45,6 +44,7 @@ func Generate(dist string) config.Project {
Env: []string{"COSIGN_YES=true"},
Builds: Builds(dist),
Archives: Archives(dist),
MSI: WinPackages(dist),
NFPMs: Packages(dist),
Dockers: DockerImages(dist),
DockerManifests: DockerManifests(dist),
Expand Down Expand Up @@ -102,6 +102,26 @@ func Archive(dist string) config.Archive {
}
}

func WinPackages(dist string) []config.MSI {
return []config.MSI{
WinPackage(dist),
}
}

// Package configures goreleaser to build a Windows MSI package.
// https://goreleaser.com/customization/msi/
func WinPackage(dist string) config.MSI {
return config.MSI{
ID: dist,
Name: fmt.Sprintf("%s_{{ .Version }}_{{ .Os }}_{{ .MsiArch }}", dist),
WXS: "windows-installer.wxs",
Files: []string{
"config.yaml",
"opentelemetry.ico",
},
}
}

func Packages(dist string) (r []config.NFPM) {
return []config.NFPM{
Package(dist),
Expand All @@ -127,7 +147,7 @@ func Package(dist string) config.NFPM {
PostInstall: "postinstall.sh",
PreRemove: "preremove.sh",
},
Contents: files.Contents{
Contents: config.NFPMContents{
{
Source: fmt.Sprintf("%s.service", dist),
Destination: path.Join("/lib", "systemd", "system", fmt.Sprintf("%s.service", dist)),
Expand Down
7 changes: 7 additions & 0 deletions distributions/otelcol-contrib/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ partial:
project_name: opentelemetry-collector-releases
env:
- COSIGN_YES=true
msi:
- id: otelcol-contrib
name: otelcol-contrib_{{ .Version }}_{{ .Os }}_{{ .MsiArch }}
wxs: windows-installer.wxs
extra_files:
- config.yaml
- opentelemetry.ico
builds:
- id: otelcol-contrib
goos:
Expand Down
Binary file not shown.
88 changes: 88 additions & 0 deletions distributions/otelcol-contrib/windows-installer.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product
Name="OpenTelemetry Collector ({{ .Version }}) - {{ .Binary }} distribution"
Id="B250A214-D463-4E9B-8902-1DE5C19EA951"
UpgradeCode="B7C263DD-95A5-436A-A025-DCA5200C2BE3"
Version="{{ .Version }}"
Manufacturer="OpenTelemetry"
Language="1033">

<Package
InstallerVersion="200"
Compressed="yes"
Comments="Windows Installer Package"
InstallScope="perMachine"/>
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
<Icon Id="ProductIcon" SourceFile="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"/>

<MajorUpgrade
DowngradeErrorMessage="A later version of OpenTelemetry Collector already installed. Setup will now exit."/>

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

<Property Id="COLLECTOR_SVC_ARGS"/>
<CustomAction
Id="SetCollectorSvcArgs"
Property="COLLECTOR_SVC_ARGS"
Value="--config &quot;[INSTALLDIR]config.yaml&quot;"/>

<InstallExecuteSequence>
<Custom Action="SetCollectorSvcArgs" Before="InstallFiles">NOT COLLECTOR_SVC_ARGS</Custom>
</InstallExecuteSequence>

<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="{{ .Binary }}.exe"
Name="{{ .Binary }}.exe"
Source="{{ .Binary }}.exe"
KeyPath="yes"/>
<File
Id="config.yaml"
Name="config.yaml"
Source="config.yaml"/>

<ServiceInstall
Id="Sevice"
Name="{{ .Binary }}"
DisplayName="OpenTelemetry Collector"
Description="Collects, processes, and exports telemetry from various configurable sources."
Type="ownProcess"
Vital="yes"
Start="auto"
Account="LocalSystem"
ErrorControl="normal"
Arguments="[COLLECTOR_SVC_ARGS]"
Interactive="no"/>
<ServiceControl
Id="StartStopRemoveService"
Name="{{ .Binary }}"
Start="install"
Stop="both"
Remove="uninstall"
Wait="yes"/>

<RegistryKey
Root="HKLM"
Key="SYSTEM\CurrentControlSet\Services\EventLog\Application\{{ .Binary }}">
<RegistryValue
Type="expandable"
Name="EventMessageFile"
Value="%SystemRoot%\System32\EventCreate.exe"/>
</RegistryKey>
</Component>
</Directory>
</Directory>
</Directory>
</Product>
</Wix>
7 changes: 7 additions & 0 deletions distributions/otelcol/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ partial:
project_name: opentelemetry-collector-releases
env:
- COSIGN_YES=true
msi:
- id: otelcol
name: otelcol_{{ .Version }}_{{ .Os }}_{{ .MsiArch }}
wxs: windows-installer.wxs
extra_files:
- config.yaml
- opentelemetry.ico
builds:
- id: otelcol
goos:
Expand Down
Binary file added distributions/otelcol/opentelemetry.ico
Binary file not shown.
88 changes: 88 additions & 0 deletions distributions/otelcol/windows-installer.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product
Name="OpenTelemetry Collector ({{ .Version }}) - {{ .Binary }} distribution"
Id="B250A214-D463-4E9B-8902-1DE5C19EA951"
UpgradeCode="B7C263DD-95A5-436A-A025-DCA5200C2BE3"
Version="{{ .Version }}"
Manufacturer="OpenTelemetry"
Language="1033">

<Package
InstallerVersion="200"
Compressed="yes"
Comments="Windows Installer Package"
InstallScope="perMachine"/>
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
<Icon Id="ProductIcon" SourceFile="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"/>

<MajorUpgrade
DowngradeErrorMessage="A later version of OpenTelemetry Collector already installed. Setup will now exit."/>

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

<Property Id="COLLECTOR_SVC_ARGS"/>
<CustomAction
Id="SetCollectorSvcArgs"
Property="COLLECTOR_SVC_ARGS"
Value="--config &quot;[INSTALLDIR]config.yaml&quot;"/>

<InstallExecuteSequence>
<Custom Action="SetCollectorSvcArgs" Before="InstallFiles">NOT COLLECTOR_SVC_ARGS</Custom>
</InstallExecuteSequence>

<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="{{ .Binary }}.exe"
Name="{{ .Binary }}.exe"
Source="{{ .Binary }}.exe"
KeyPath="yes"/>
<File
Id="config.yaml"
Name="config.yaml"
Source="config.yaml"/>

<ServiceInstall
Id="Sevice"
Name="{{ .Binary }}"
DisplayName="OpenTelemetry Collector"
Description="Collects, processes, and exports telemetry from various configurable sources."
Type="ownProcess"
Vital="yes"
Start="auto"
Account="LocalSystem"
ErrorControl="normal"
Arguments="[COLLECTOR_SVC_ARGS]"
Interactive="no"/>
<ServiceControl
Id="StartStopRemoveService"
Name="{{ .Binary }}"
Start="install"
Stop="both"
Remove="uninstall"
Wait="yes"/>

<RegistryKey
Root="HKLM"
Key="SYSTEM\CurrentControlSet\Services\EventLog\Application\{{ .Binary }}">
<RegistryValue
Type="expandable"
Name="EventMessageFile"
Value="%SystemRoot%\System32\EventCreate.exe"/>
</RegistryKey>
</Component>
</Directory>
</Directory>
</Directory>
</Product>
</Wix>
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.7

require (
github.com/goreleaser/goreleaser v1.25.1
github.com/goreleaser/goreleaser-pro v1.25.1-pro
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realise you could directly use the pro version, interesting.

github.com/goreleaser/nfpm/v2 v2.37.1
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ github.com/goreleaser/fileglob v1.3.0 h1:/X6J7U8lbDpQtBvGcwwPS6OpzkNVlVEsFUVRx9+
github.com/goreleaser/fileglob v1.3.0/go.mod h1:Jx6BoXv3mbYkEzwm9THo7xbr5egkAraxkGorbJb4RxU=
github.com/goreleaser/goreleaser v1.25.1 h1:a9skjeROotTN5GPPJDHDfhmOK4n13cBgJ34sTdXRDN0=
github.com/goreleaser/goreleaser v1.25.1/go.mod h1:nsbhCYp9eImbE2fyd9/3Tgv5hjuGuDIQRoBozEUEYbc=
github.com/goreleaser/goreleaser-pro v1.25.1-pro h1:NOoSx96oAK0zNA1+hiL0p6pY1DWL101kwPmpmkiExXk=
github.com/goreleaser/goreleaser-pro v1.25.1-pro/go.mod h1:7q9HURJC4ZYBT9VyX3XlqjK0kwe5QbG/VIUAJSP3CKc=
github.com/goreleaser/nfpm/v2 v2.37.1 h1:RUmeEt8OlEVeSzKRrO5Vl5qVWCtUwx4j9uivGuRo5fw=
github.com/goreleaser/nfpm/v2 v2.37.1/go.mod h1:q8+sZXFqn106/eGw+9V+I8+izFxZ/sJjrhwmEUxXhUg=
github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI=
Expand Down
Loading