Skip to content

Commit

Permalink
revert distribution changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgopack4 committed Nov 6, 2024
1 parent 9416237 commit 294cd9a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 197 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ OTELCOL_BUILDER_DIR ?= ${HOME}/bin
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb

DISTRIBUTIONS ?= "otelcol,otelcol-contrib,otelcol-k8s,otelcol-otlp"
GEN_CONFIG_DISTRIBUTIONS ?= "otelcol,otelcol-contrib"

ci: check build
check: ensure-goreleaser-up-to-date
Expand All @@ -16,7 +17,7 @@ build: go ocb
generate: generate-sources generate-goreleaser

generate-goreleaser: go
@./scripts/generate-goreleaser.sh -d "${DISTRIBUTIONS}" -g ${GO}
@./scripts/generate-goreleaser.sh -d "${GEN_CONFIG_DISTRIBUTIONS}" -g ${GO}

generate-sources: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO}
Expand Down
104 changes: 33 additions & 71 deletions cmd/goreleaser/internal/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,10 @@ import (
const ArmArch = "arm"

var (
ImagePrefixes = []string{"otel", "ghcr.io/open-telemetry/opentelemetry-collector-releases"}
Architectures = []string{"386", "amd64", "arm", "arm64", "ppc64le", "s390x"}
ArmVersions = []string{"7"}
DefaultConfigDists = map[string]bool{"otelcol": true, "otelcol-contrib": true}
MSIWindowsDists = map[string]bool{"otelcol": true, "otelcol-contrib": true, "otelcol-otlp": true}
K8sDockerSkipArchs = map[string]bool{"arm": true, "386": true}
K8sGoos = []string{"linux"}
K8sArchs = []string{"amd64", "arm64", "ppc64le", "s390x"}
AlwaysIgnored = map[config.IgnoredBuild]bool{
ImagePrefixes = []string{"otel", "ghcr.io/open-telemetry/opentelemetry-collector-releases"}
Architectures = []string{"386", "amd64", "arm", "arm64", "ppc64le", "s390x"}
ArmVersions = []string{"7"}
AlwaysIgnored = map[config.IgnoredBuild]bool{
{Goos: "darwin", Goarch: "386"}: true,
{Goos: "darwin", Goarch: "arm"}: true,
{Goos: "darwin", Goarch: "s390x"}: true,
Expand Down Expand Up @@ -121,26 +116,17 @@ func Build(dist string, pie bool) config.Build {
ldflags = append(ldflags, "-buildmode=pie")
id = id + "-pie"
}
flags := []string{"-trimpath"}
if dist == "otelcol-k8s" {
goos = K8sGoos
archs = K8sArchs
ignore = generateIgnored(K8sGoos, K8sArchs, pie)
armVersions = make([]string, 0)

} else {
goos = []string{"darwin", "linux", "windows"}
archs = Architectures
ignore = generateIgnored(goos, archs, pie)
armVersions = ArmVersions
}
goos = []string{"darwin", "linux", "windows"}
archs = Architectures
ignore = generateIgnored(goos, archs, pie)
armVersions = ArmVersions
return config.Build{
ID: id,
Dir: "_build",
Binary: dist,
BuildDetails: config.BuildDetails{
Env: []string{"CGO_ENABLED=0"},
Flags: flags,
Flags: []string{"-trimpath"},
Ldflags: ldflags,
},
Goos: goos,
Expand Down Expand Up @@ -174,9 +160,6 @@ func Archive(dist string, pie bool) config.Archive {
}

func WinPackages(dist string) []config.MSI {
if _, ok := MSIWindowsDists[dist]; !ok {
return []config.MSI{}
}
return []config.MSI{
WinPackage(dist),
}
Expand All @@ -185,22 +168,18 @@ func WinPackages(dist string) []config.MSI {
// Package configures goreleaser to build a Windows MSI package.
// https://goreleaser.com/customization/msi/
func WinPackage(dist string) config.MSI {
files := []string{"opentelemetry.ico"}
if _, ok := DefaultConfigDists[dist]; ok {
files = append(files, "config.yaml")
}
return config.MSI{
ID: dist,
Name: fmt.Sprintf("%s_{{ .Version }}_{{ .Os }}_{{ .MsiArch }}", dist),
WXS: "windows-installer.wxs",
Files: files,
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) {
if dist == "otelcol-k8s" {
return []config.NFPM{}
}
return []config.NFPM{
Package(dist, true),
Package(dist, false),
Expand All @@ -216,24 +195,6 @@ func Package(dist string, pie bool) config.NFPM {
id = id + "-pie"
build = build + "-pie"
}
nfpmContents := config.NFPMContents{
{
Source: fmt.Sprintf("%s.service", dist),
Destination: path.Join("/lib", "systemd", "system", fmt.Sprintf("%s.service", dist)),
},
{
Source: fmt.Sprintf("%s.conf", dist),
Destination: path.Join("/etc", dist, fmt.Sprintf("%s.conf", dist)),
Type: "config|noreplace",
},
}
if _, ok := DefaultConfigDists[dist]; ok {
nfpmContents = append(nfpmContents, &config.NFPMContent{
Source: "config.yaml",
Destination: path.Join("/etc", dist, "config.yaml"),
Type: "config|noreplace",
})
}
return config.NFPM{
ID: id,
Builds: []string{build},
Expand All @@ -257,19 +218,29 @@ func Package(dist string, pie bool) config.NFPM {
PostInstall: "postinstall.sh",
PreRemove: "preremove.sh",
},
Contents: nfpmContents,
Contents: config.NFPMContents{
{
Source: fmt.Sprintf("%s.service", dist),
Destination: path.Join("/lib", "systemd", "system", fmt.Sprintf("%s.service", dist)),
},
{
Source: fmt.Sprintf("%s.conf", dist),
Destination: path.Join("/etc", dist, fmt.Sprintf("%s.conf", dist)),
Type: "config|noreplace",
},
{
Source: "config.yaml",
Destination: path.Join("/etc", dist, "config.yaml"),
Type: "config|noreplace",
},
},
},
}
}

func DockerImages(dist string) []config.Docker {
r := make([]config.Docker, 0)
for _, arch := range Architectures {
if dist == "otelcol-k8s" {
if _, ok := K8sDockerSkipArchs[arch]; ok {
continue
}
}
switch arch {
case ArmArch:
for _, vers := range ArmVersions {
Expand Down Expand Up @@ -299,10 +270,6 @@ func DockerImage(dist, arch, armVersion string) config.Docker {
label := func(name, template string) string {
return fmt.Sprintf("--label=org.opencontainers.image.%s={{%s}}", name, template)
}
files := make([]string, 0)
if _, ok := DefaultConfigDists[dist]; ok {
files = append(files, "config.yaml")
}
return config.Docker{
ImageTemplates: imageTemplates,
Dockerfile: "Dockerfile",
Expand All @@ -318,7 +285,7 @@ func DockerImage(dist, arch, armVersion string) config.Docker {
label("source", ".GitURL"),
"--label=org.opencontainers.image.licenses=Apache-2.0",
},
Files: files,
Files: []string{"config.yaml"},
Goos: "linux",
Goarch: arch,
Goarm: armVersion,
Expand All @@ -339,11 +306,6 @@ func DockerManifests(dist string) []config.DockerManifest {
func DockerManifest(prefix, version, dist string) config.DockerManifest {
var imageTemplates []string
for _, arch := range Architectures {
if dist == "otelcol-k8s" {
if _, ok := K8sDockerSkipArchs[arch]; ok {
continue
}
}
switch arch {
case ArmArch:
for _, armVers := range ArmVersions {
Expand Down
2 changes: 1 addition & 1 deletion distributions/otelcol-contrib/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ msi:
name: otelcol-contrib_{{ .Version }}_{{ .Os }}_{{ .MsiArch }}
wxs: windows-installer.wxs
extra_files:
- opentelemetry.ico
- config.yaml
- opentelemetry.ico
builds:
- id: otelcol-contrib-pie
goos:
Expand Down
36 changes: 2 additions & 34 deletions distributions/otelcol-k8s/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
partial:
by: target
version: 2
monorepo:
tag_prefix: v
project_name: opentelemetry-collector-releases
env:
- COSIGN_YES=true
builds:
- id: otelcol-k8s-pie
goos:
- linux
goarch:
- amd64
- arm64
- ppc64le
- s390x
ignore:
- goos: linux
goarch: s390x
dir: _build
binary: otelcol-k8s
ldflags:
- -s
- -w
- -buildmode=pie
flags:
- -trimpath
env:
- CGO_ENABLED=0
- id: otelcol-k8s
goos:
- linux
Expand All @@ -34,13 +15,6 @@ builds:
- arm64
- ppc64le
- s390x
ignore:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: linux
goarch: ppc64le
dir: _build
binary: otelcol-k8s
ldflags:
Expand All @@ -51,10 +25,6 @@ builds:
env:
- CGO_ENABLED=0
archives:
- id: otelcol-k8s-pie
builds:
- otelcol-k8s-pie
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
- id: otelcol-k8s
builds:
- otelcol-k8s
Expand Down Expand Up @@ -181,5 +151,3 @@ sboms:
artifacts: archive
- id: package
artifacts: package
monorepo:
tag_prefix: v
89 changes: 0 additions & 89 deletions distributions/otelcol-otlp/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,6 @@ msi:
extra_files:
- opentelemetry.ico
builds:
- id: otelcol-otlp-pie
goos:
- darwin
- linux
- windows
goarch:
- "386"
- amd64
- arm
- arm64
- ppc64le
- s390x
goarm:
- "7"
ignore:
- goos: darwin
goarch: "386"
- goos: darwin
goarch: arm
- goos: darwin
goarch: ppc64le
- goos: darwin
goarch: s390x
- goos: linux
goarch: "386"
- goos: linux
goarch: arm
- goos: linux
goarch: s390x
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
- goos: windows
goarch: ppc64le
- goos: windows
goarch: s390x
dir: _build
binary: otelcol-otlp
ldflags:
- -s
- -w
- -buildmode=pie
flags:
- -trimpath
env:
- CGO_ENABLED=0
- id: otelcol-otlp
goos:
- darwin
Expand All @@ -75,24 +28,10 @@ builds:
ignore:
- goos: darwin
goarch: "386"
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm
- goos: darwin
goarch: arm64
- goos: darwin
goarch: s390x
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: linux
goarch: ppc64le
- goos: windows
goarch: "386"
- goos: windows
goarch: amd64
- goos: windows
goarch: arm
- goos: windows
Expand All @@ -109,39 +48,11 @@ builds:
env:
- CGO_ENABLED=0
archives:
- id: otelcol-otlp-pie
builds:
- otelcol-otlp-pie
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
- id: otelcol-otlp
builds:
- otelcol-otlp
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
nfpms:
- package_name: otelcol-otlp
contents:
- src: otelcol-otlp.service
dst: /lib/systemd/system/otelcol-otlp.service
- src: otelcol-otlp.conf
dst: /etc/otelcol-otlp/otelcol-otlp.conf
type: config|noreplace
scripts:
preinstall: preinstall.sh
postinstall: postinstall.sh
preremove: preremove.sh
overrides:
rpm:
dependencies:
- /bin/sh
id: otelcol-otlp-pie
builds:
- otelcol-otlp-pie
formats:
- deb
- rpm
maintainer: The OpenTelemetry Collector maintainers <[email protected]>
description: OpenTelemetry Collector - otelcol-otlp
license: Apache 2.0
- package_name: otelcol-otlp
contents:
- src: otelcol-otlp.service
Expand Down
Loading

0 comments on commit 294cd9a

Please sign in to comment.