From 294cd9a773905987e8dd2ea89cb9f0b40accfa2e Mon Sep 17 00:00:00 2001 From: jackgopack4 Date: Wed, 6 Nov 2024 11:01:03 -0500 Subject: [PATCH] revert distribution changes --- Makefile | 3 +- cmd/goreleaser/internal/configure.go | 104 ++++++------------ .../otelcol-contrib/.goreleaser.yaml | 2 +- distributions/otelcol-k8s/.goreleaser.yaml | 36 +----- distributions/otelcol-otlp/.goreleaser.yaml | 89 --------------- distributions/otelcol/.goreleaser.yaml | 2 +- 6 files changed, 39 insertions(+), 197 deletions(-) diff --git a/Makefile b/Makefile index 7efc0f160..d0e80c4f3 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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} diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index 867290149..18ab1aeeb 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -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, @@ -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, @@ -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), } @@ -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), @@ -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}, @@ -257,7 +218,22 @@ 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", + }, + }, }, } } @@ -265,11 +241,6 @@ func Package(dist string, pie bool) config.NFPM { 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 { @@ -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", @@ -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, @@ -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 { diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index 625e2afc4..14edb9bc4 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -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: diff --git a/distributions/otelcol-k8s/.goreleaser.yaml b/distributions/otelcol-k8s/.goreleaser.yaml index 127255793..47d5d05b5 100644 --- a/distributions/otelcol-k8s/.goreleaser.yaml +++ b/distributions/otelcol-k8s/.goreleaser.yaml @@ -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 @@ -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: @@ -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 @@ -181,5 +151,3 @@ sboms: artifacts: archive - id: package artifacts: package -monorepo: - tag_prefix: v diff --git a/distributions/otelcol-otlp/.goreleaser.yaml b/distributions/otelcol-otlp/.goreleaser.yaml index 0770d1e09..a1e9681cf 100644 --- a/distributions/otelcol-otlp/.goreleaser.yaml +++ b/distributions/otelcol-otlp/.goreleaser.yaml @@ -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 @@ -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 @@ -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 - description: OpenTelemetry Collector - otelcol-otlp - license: Apache 2.0 - package_name: otelcol-otlp contents: - src: otelcol-otlp.service diff --git a/distributions/otelcol/.goreleaser.yaml b/distributions/otelcol/.goreleaser.yaml index 4c9dba73d..8c65a1326 100644 --- a/distributions/otelcol/.goreleaser.yaml +++ b/distributions/otelcol/.goreleaser.yaml @@ -9,8 +9,8 @@ msi: name: otelcol_{{ .Version }}_{{ .Os }}_{{ .MsiArch }} wxs: windows-installer.wxs extra_files: - - opentelemetry.ico - config.yaml + - opentelemetry.ico builds: - id: otelcol-pie goos: