Skip to content

Commit

Permalink
add windows zip
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiranAvidov committed Jul 24, 2023
1 parent 8da6181 commit 7ed35aa
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 8 deletions.
60 changes: 56 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
partial:
by: target
project_name: opentelemetry-collector-releases
builds:
- id: otelcol
goos:
- darwin
- linux
- windows
goarch:
- "386"
- amd64
Expand All @@ -20,6 +17,27 @@ builds:
goarch: "386"
- goos: darwin
goarch: arm
dir: distributions/otelcol/_build
binary: otelcol
ldflags:
- -s
- -w
flags:
- -trimpath
env:
- CGO_ENABLED=0
- id: otelcol-windows
goos:
- windows
goarch:
- "386"
- amd64
- arm
- arm64
- ppc64le
goarm:
- "7"
ignore:
- goos: windows
goarch: arm
- goos: windows
Expand All @@ -37,7 +55,6 @@ builds:
goos:
- darwin
- linux
- windows
goarch:
- "386"
- amd64
Expand All @@ -51,6 +68,27 @@ builds:
goarch: "386"
- goos: darwin
goarch: arm
dir: distributions/otelcol-contrib/_build
binary: otelcol-contrib
ldflags:
- -s
- -w
flags:
- -trimpath
env:
- CGO_ENABLED=0
- id: otelcol-contrib-windows
goos:
- windows
goarch:
- "386"
- amd64
- arm
- arm64
- ppc64le
goarm:
- "7"
ignore:
- goos: windows
goarch: arm
- goos: windows
Expand All @@ -68,11 +106,25 @@ archives:
- id: otelcol
builds:
- otelcol
- otelcol-windows
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
format: tar.gz
- id: otelcol-windows
builds:
- otelcol-windows
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
format: zip
- id: otelcol-contrib
builds:
- otelcol-contrib
- otelcol-contrib-windows
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
format: tar.gz
- id: otelcol-contrib-windows
builds:
- otelcol-contrib-windows
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
format: zip
nfpms:
- package_name: otelcol
contents:
Expand Down
40 changes: 36 additions & 4 deletions cmd/goreleaser/internal/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func Generate(imagePrefixes []string, dists []string) config.Project {

func Builds(dists []string) (r []config.Build) {
for _, dist := range dists {
r = append(r, Build(dist))
r = append(r, Build(dist), WindowsBuild(dist))
}
return
}
Expand All @@ -70,12 +70,32 @@ func Build(dist string) config.Build {
Flags: []string{"-trimpath"},
Ldflags: []string{"-s", "-w"},
},
Goos: []string{"darwin", "linux", "windows"},
Goos: []string{"darwin", "linux"},
Goarch: Architectures,
Goarm: ArmVersions,
Ignore: []config.IgnoredBuild{
{Goos: "darwin", Goarch: "386"},
{Goos: "darwin", Goarch: "arm"},
},
}
}

// WindowsBuild configures a goreleaser build.
// https://goreleaser.com/customization/build/
func WindowsBuild(dist string) config.Build {
return config.Build{
ID: fmt.Sprintf("%s-windows", dist),
Dir: path.Join("distributions", dist, "_build"),
Binary: dist,
BuildDetails: config.BuildDetails{
Env: []string{"CGO_ENABLED=0"},
Flags: []string{"-trimpath"},
Ldflags: []string{"-s", "-w"},
},
Goos: []string{"windows"},
Goarch: Architectures,
Goarm: ArmVersions,
Ignore: []config.IgnoredBuild{
{Goos: "windows", Goarch: "arm"},
{Goos: "windows", Goarch: "arm64"},
},
Expand All @@ -84,7 +104,7 @@ func Build(dist string) config.Build {

func Archives(dists []string) (r []config.Archive) {
for _, dist := range dists {
r = append(r, Archive(dist))
r = append(r, Archive(dist), WindowsZipArchive(dist))
}
return
}
Expand All @@ -95,7 +115,19 @@ func Archive(dist string) config.Archive {
return config.Archive{
ID: dist,
NameTemplate: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}",
Builds: []string{dist},
Builds: []string{dist, fmt.Sprintf("%s-windows", dist)},
Format: "tar.gz",
}
}

// WindowsZipArchive configures a goreleaser archive (tarball).
// https://goreleaser.com/customization/archive/
func WindowsZipArchive(dist string) config.Archive {
return config.Archive{
ID: fmt.Sprintf("%s-windows", dist),
NameTemplate: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}",
Builds: []string{fmt.Sprintf("%s-windows", dist)},
Format: "zip",
}
}

Expand Down

0 comments on commit 7ed35aa

Please sign in to comment.