Skip to content

Commit

Permalink
Add MSI support to generate-goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanotti committed May 21, 2024
1 parent 6f010ac commit c32d476
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
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",
"./windows/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
- ./windows/opentelemetry.ico
builds:
- id: otelcol-contrib
goos:
Expand Down
13 changes: 7 additions & 6 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
- ./windows/opentelemetry.ico
builds:
- id: otelcol
goos:
Expand Down Expand Up @@ -70,12 +77,6 @@ nfpms:
maintainer: The OpenTelemetry Collector maintainers <cncf-opentelemetry-maintainers@lists.cncf.io>
description: OpenTelemetry Collector - otelcol
license: Apache 2.0
msi:
name: "otelcol_{{ .Version }}_{{ .Os }}_{{ .MsiArch }}"
wxs: ./windows/installer.wxs
extra_files:
- config.yaml
- ./windows/opentelemetry.ico
checksum:
name_template: '{{ .ProjectName }}_otelcol_checksums.txt'
dockers:
Expand Down
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
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

0 comments on commit c32d476

Please sign in to comment.