From f2944addf5962068f237399659a66cb7c4a154cf Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 19 Sep 2024 09:10:15 +0200 Subject: [PATCH 01/40] run package tests nightly against latest main Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 55 ++++++++++++++++++- .github/workflows/nightly-package-tests.yml | 44 +++++++++++++++ Makefile | 4 +- .../otelcol-contrib/.goreleaser-build.yaml | 43 +++++++++++++++ .../otelcol-contrib/.goreleaser.yaml | 10 +--- scripts/build.sh | 2 +- 6 files changed, 147 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/nightly-package-tests.yml create mode 100644 distributions/otelcol-contrib/.goreleaser-build.yaml diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index 7a036bef..54395f9b 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -12,6 +12,10 @@ on: goarch: required: true type: string + latest: + required: false + type: boolean + default: false env: # renovate: datasource=github-tags depName=goreleaser-pro packageName=goreleaser/goreleaser-pro @@ -64,9 +68,58 @@ jobs: go-version: '1.23' check-latest: true - - name: Generate the sources + - name: Get latest finished run ID from contrib repo build-and-test + id: get-run-id + if: inputs.latest == true + env: + GH_TOKEN: ${{ github.token }} + run: | + run_id=$(gh run list --branch main --workflow build-and-test --repo open-telemetry/opentelemetry-collector-contrib --limit 1 --status success --json databaseId --jq '.[0].databaseId') + echo "run_id=$run_id" >> "$GITHUB_OUTPUT" + + - run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1 + if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest == true }} + + - name: Download built otelcontribcol artifact from contrib repo + if: inputs.latest == true + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: collector-binaries-linux-amd64 + repository: open-telemetry/opentelemetry-collector-contrib + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ steps.get-run-id.outputs.run_id }} + + - name: Rename downloaded artifact + if: inputs.latest == true + run: mv otelcontribcol_linux_amd64 distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1/otelcol-contrib + + - name: Generate the sources for ${{ inputs.distribution }} + if: inputs.latest != true + env: + DISTRIBUTIONS: ${{ inputs.distribution }} run: make generate-sources + - name: Run split GoReleaser build for otelcol-contrib + if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest != true }} + uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0 + with: + distribution: goreleaser-pro + version: v2.3.2 + workdir: distributions/otelcol-contrib + args: --snapshot --clean --timeout 2h --split --config .goreleaser-build.yaml + env: + GOOS: ${{ matrix.GOOS }} + GOARCH: ${{ matrix.GOARCH }} + GOARM: 7 # Default is 6 + GOAMD64: v1 + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + + - if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest != true }} + run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/ + + - run: ls -laR distributions/otelcol-contrib/artifacts + if: ${{ inputs.distribution == 'otelcol-contrib' }} + - name: Run GoReleaser for ${{ inputs.distribution }} uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 with: diff --git a/.github/workflows/nightly-package-tests.yml b/.github/workflows/nightly-package-tests.yml new file mode 100644 index 00000000..511204fe --- /dev/null +++ b/.github/workflows/nightly-package-tests.yml @@ -0,0 +1,44 @@ +name: Nightly Package Tests - Contrib - GoReleaser + +on: + push: + branches: [main] + paths: + - "distributions/otelcol-contrib/**" + - "cmd/**" + - ".github/**" + - "scripts/**" + - "Makefile" + - "go.mod" + - "go.sum" + pull_request: + branches: [main] + paths: + - "distributions/otelcol-contrib/**" + - "cmd/**" + - ".github/**" + - "scripts/**" + - "Makefile" + - "go.mod" + - "go.sum" +# schedule: +# - + +jobs: + check-goreleaser: + name: Continuous Integration - Contrib - GoReleaser + uses: ./.github/workflows/base-ci-goreleaser.yaml + with: + distribution: otelcol-contrib + goos: '[ "linux" ]' + goarch: '[ "amd64" ]' + latest: true + secrets: inherit + + package-tests: + name: Package tests + needs: check-goreleaser + uses: ./.github/workflows/package-tests.yaml + with: + distribution: otelcol-contrib + type: '[ "deb", "rpm" ]' diff --git a/Makefile b/Makefile index 656e7cb2..23e1673a 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ OTELCOL_BUILDER_VERSION ?= 0.114.0 OTELCOL_BUILDER_DIR ?= ${HOME}/bin OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb -DISTRIBUTIONS ?= "otelcol,otelcol-contrib,otelcol-k8s,otelcol-otlp" +DISTRIBUTIONS ?= "otelcol-contrib" ci: check build check: ensure-goreleaser-up-to-date @@ -92,4 +92,4 @@ delete-tags: # Used for debug only REMOTE?=git@github.com:open-telemetry/opentelemetry-collector-releases.git .PHONY: repeat-tags -repeat-tags: delete-tags push-tags \ No newline at end of file +repeat-tags: delete-tags push-tags diff --git a/distributions/otelcol-contrib/.goreleaser-build.yaml b/distributions/otelcol-contrib/.goreleaser-build.yaml new file mode 100644 index 00000000..b5f60c0d --- /dev/null +++ b/distributions/otelcol-contrib/.goreleaser-build.yaml @@ -0,0 +1,43 @@ +partial: + by: target +version: 2 +project_name: opentelemetry-collector-releases +builds: + - id: otelcol-contrib + 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: s390x + - goos: windows + goarch: arm + - goos: windows + goarch: arm64 + - goos: windows + goarch: s390x + dir: _build + binary: otelcol-contrib + ldflags: + - -s + - -w + flags: + - -trimpath + env: + - CGO_ENABLED=0 +monorepo: + tag_prefix: v diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index 593efbbc..fb450769 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -13,6 +13,9 @@ msi: - config.yaml builds: - id: otelcol-contrib + builder: prebuilt + prebuilt: + path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} goos: - darwin - linux @@ -41,13 +44,6 @@ builds: goarch: s390x dir: _build binary: otelcol-contrib - ldflags: - - -s - - -w - flags: - - -trimpath - env: - - CGO_ENABLED=0 archives: - id: otelcol-contrib builds: diff --git a/scripts/build.sh b/scripts/build.sh index bcf810b3..e6b325f4 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -6,7 +6,7 @@ BUILDER='' # default values skipcompilation=false -while getopts d:s:b:g: flag +while getopts d:s:b: flag do case "${flag}" in d) distributions=${OPTARG};; From 4fb20f782f57272ad538b70cc57288f1f1f14270 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 14 Nov 2024 11:11:40 +0100 Subject: [PATCH 02/40] try again Signed-off-by: Moritz Wiesinger --- distributions/otelcol-contrib/.goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index fb450769..a1dc180c 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -15,7 +15,7 @@ builds: - id: otelcol-contrib builder: prebuilt prebuilt: - path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} + path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} goos: - darwin - linux From f4cc7fd89a6bee3dcbd2280591a856620c3e6711 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 14 Nov 2024 11:12:49 +0100 Subject: [PATCH 03/40] add mkdir for all distros Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index 54395f9b..5e39ae79 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -77,6 +77,8 @@ jobs: run_id=$(gh run list --branch main --workflow build-and-test --repo open-telemetry/opentelemetry-collector-contrib --limit 1 --status success --json databaseId --jq '.[0].databaseId') echo "run_id=$run_id" >> "$GITHUB_OUTPUT" + - run: mkdir -p distributions/otelcol-contrib/artifacts + - run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1 if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest == true }} From 4ba2fa3e5da6cdf860f1b4cec09341642e8aaebf Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 14 Nov 2024 12:57:05 +0100 Subject: [PATCH 04/40] start with adding goreleaser generation code Signed-off-by: Moritz Wiesinger --- cmd/goreleaser/internal/configure.go | 54 ++++++++++++++++++---------- cmd/goreleaser/main.go | 10 +++++- scripts/generate-goreleaser.sh | 4 +++ 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index 32741f16..15030a1a 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -42,7 +42,6 @@ const ( var ( ImagePrefixes = []string{DockerHub, GHCR} Architectures = []string{"386", "amd64", "arm", "arm64", "ppc64le", "s390x"} - ArmVersions = []string{"7"} DefaultConfigDists = map[string]bool{CoreDistro: true, ContribDistro: true} MSIWindowsDists = map[string]bool{CoreDistro: true, ContribDistro: true, OTLPDistro: true} K8sDockerSkipArchs = map[string]bool{"arm": true, "386": true} @@ -50,6 +49,17 @@ var ( K8sArchs = []string{"amd64", "arm64", "ppc64le", "s390x"} ) +func GenerateContribBuildOnly(dist string) config.Project { + return config.Project{ + ProjectName: "opentelemetry-collector-releases", + Builds: Builds(dist), + Version: 2, + Monorepo: config.Monorepo{ + TagPrefix: "v", + }, + } +} + func Generate(dist string) config.Project { return config.Project{ ProjectName: "opentelemetry-collector-releases", @@ -84,25 +94,12 @@ func Builds(dist string) []config.Build { func Build(dist string) config.Build { var goos []string var archs []string - var ignore []config.IgnoredBuild - var armVersions []string if dist == K8sDistro { goos = K8sGoos archs = K8sArchs - ignore = make([]config.IgnoredBuild, 0) - armVersions = make([]string, 0) } else { goos = []string{"darwin", "linux", "windows"} archs = Architectures - ignore = []config.IgnoredBuild{ - {Goos: "darwin", Goarch: "386"}, - {Goos: "darwin", Goarch: "arm"}, - {Goos: "darwin", Goarch: "s390x"}, - {Goos: "windows", Goarch: "arm"}, - {Goos: "windows", Goarch: "arm64"}, - {Goos: "windows", Goarch: "s390x"}, - } - armVersions = ArmVersions } return config.Build{ ID: dist, @@ -115,9 +112,30 @@ func Build(dist string) config.Build { }, Goos: goos, Goarch: archs, - Goarm: armVersions, - Ignore: ignore, + Goarm: ArmVersions(dist), + Ignore: IgnoreBuildCombinations(dist), + } +} + +func IgnoreBuildCombinations(dist string) []config.IgnoredBuild { + if dist == K8sDistro { + return make([]config.IgnoredBuild, 0) + } + return []config.IgnoredBuild{ + {Goos: "darwin", Goarch: "386"}, + {Goos: "darwin", Goarch: "arm"}, + {Goos: "darwin", Goarch: "s390x"}, + {Goos: "windows", Goarch: "arm"}, + {Goos: "windows", Goarch: "arm64"}, + {Goos: "windows", Goarch: "s390x"}, + } +} + +func ArmVersions(dist string) []string { + if dist == K8sDistro { + return make([]string, 0) } + return []string{"7"} } func Archives(dist string) (r []config.Archive) { @@ -228,7 +246,7 @@ func DockerImages(dist string) []config.Docker { } switch arch { case ArmArch: - for _, vers := range ArmVersions { + for _, vers := range ArmVersions(dist) { r = append(r, DockerImage(dist, arch, vers)) } default: @@ -302,7 +320,7 @@ func DockerManifest(prefix, version, dist string) config.DockerManifest { } switch arch { case ArmArch: - for _, armVers := range ArmVersions { + for _, armVers := range ArmVersions(dist) { dockerArchTag := strings.ReplaceAll(archName(arch, armVers), "/", "") imageTemplates = append( imageTemplates, diff --git a/cmd/goreleaser/main.go b/cmd/goreleaser/main.go index b466e06d..e9735b00 100644 --- a/cmd/goreleaser/main.go +++ b/cmd/goreleaser/main.go @@ -19,12 +19,14 @@ import ( "log" "os" + "github.com/goreleaser/goreleaser-pro/v2/pkg/config" "gopkg.in/yaml.v3" "github.com/open-telemetry/opentelemetry-collector-releases/cmd/goreleaser/internal" ) var distFlag = flag.String("d", "", "Collector distributions to build") +var contribBuildOrRestFlag = flag.Bool("b", false, "Collector Contrib distribution only - switch between build and package config file - set to true to generate build step, false to generate pacakge step") func main() { flag.Parse() @@ -32,8 +34,14 @@ func main() { if len(*distFlag) == 0 { log.Fatal("no distribution to build") } + var project config.Project - project := internal.Generate(*distFlag) + if *distFlag == internal.ContribDistro && *contribBuildOrRestFlag { + // Special care needs to be taken for otelcol-contrib since it has a split setup + project = internal.GenerateContribBuildOnly(*distFlag) + } else { + project = internal.Generate(*distFlag) + } partial := map[string]any{ "partial": map[string]any{ diff --git a/scripts/generate-goreleaser.sh b/scripts/generate-goreleaser.sh index 7b6c7ae7..91144359 100755 --- a/scripts/generate-goreleaser.sh +++ b/scripts/generate-goreleaser.sh @@ -23,5 +23,9 @@ echo "Distributions to generate: $distributions"; for distribution in $(echo "$distributions" | tr "," "\n") do + if [[ "$distribution" == "otelcol-contrib" ]]; then + ${GO} run cmd/goreleaser/main.go -d "${distribution}" -b > "./distributions/${distribution}/.goreleaser-build.yaml" + fi + ${GO} run cmd/goreleaser/main.go -d "${distribution}" > "./distributions/${distribution}/.goreleaser.yaml" done From 1795db1a9394899badf6fd1c18dda27623a33a95 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 14 Nov 2024 14:20:43 +0100 Subject: [PATCH 05/40] generate rest of goreleaser config Signed-off-by: Moritz Wiesinger --- cmd/goreleaser/internal/configure.go | 31 +++++++++++++++++++++------- cmd/goreleaser/main.go | 4 ++-- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index 15030a1a..b5d0e64a 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -49,10 +49,10 @@ var ( K8sArchs = []string{"amd64", "arm64", "ppc64le", "s390x"} ) -func GenerateContribBuildOnly(dist string) config.Project { +func GenerateContribBuildOnly(dist string, buildOrRest bool) config.Project { return config.Project{ ProjectName: "opentelemetry-collector-releases", - Builds: Builds(dist), + Builds: Builds(dist, buildOrRest), Version: 2, Monorepo: config.Monorepo{ TagPrefix: "v", @@ -60,14 +60,14 @@ func GenerateContribBuildOnly(dist string) config.Project { } } -func Generate(dist string) config.Project { +func Generate(dist string, split bool) config.Project { return config.Project{ ProjectName: "opentelemetry-collector-releases", Checksum: config.Checksum{ NameTemplate: fmt.Sprintf("{{ .ProjectName }}_%v_checksums.txt", dist), }, Env: []string{"COSIGN_YES=true"}, - Builds: Builds(dist), + Builds: Builds(dist, split), Archives: Archives(dist), MSI: WinPackages(dist), NFPMs: Packages(dist), @@ -83,15 +83,32 @@ func Generate(dist string) config.Project { } } -func Builds(dist string) []config.Build { +func Builds(dist string, buildOrRest bool) []config.Build { return []config.Build{ - Build(dist), + Build(dist, buildOrRest), } } // Build configures a goreleaser build. // https://goreleaser.com/customization/build/ -func Build(dist string) config.Build { +func Build(dist string, buildOrRest bool) config.Build { + if !buildOrRest && dist == ContribDistro { + // only return build config for contrib build file + return config.Build{ + ID: dist, + Builder: "prebuilt", + PreBuilt: config.PreBuiltOptions{ + Path: "artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os \"windows\" }}.exe{{ end }}", + }, + Goos: []string{"darwin", "linux", "windows"}, + Goarch: Architectures, + Goarm: ArmVersions(dist), + Dir: "_build", + Binary: dist, + Ignore: IgnoreBuildCombinations(dist), + } + } + var goos []string var archs []string if dist == K8sDistro { diff --git a/cmd/goreleaser/main.go b/cmd/goreleaser/main.go index e9735b00..a02e14d3 100644 --- a/cmd/goreleaser/main.go +++ b/cmd/goreleaser/main.go @@ -38,9 +38,9 @@ func main() { if *distFlag == internal.ContribDistro && *contribBuildOrRestFlag { // Special care needs to be taken for otelcol-contrib since it has a split setup - project = internal.GenerateContribBuildOnly(*distFlag) + project = internal.GenerateContribBuildOnly(*distFlag, *contribBuildOrRestFlag) } else { - project = internal.Generate(*distFlag) + project = internal.Generate(*distFlag, *contribBuildOrRestFlag) } partial := map[string]any{ From ba8b447b451f837cb3140ca59b18c87ff4462d2c Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 14 Nov 2024 14:21:43 +0100 Subject: [PATCH 06/40] make generate-goreleaser - only reorders things Signed-off-by: Moritz Wiesinger --- distributions/otelcol-contrib/.goreleaser.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index a1dc180c..653e0dd6 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -13,9 +13,6 @@ msi: - config.yaml builds: - id: otelcol-contrib - builder: prebuilt - prebuilt: - path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} goos: - darwin - linux @@ -44,6 +41,9 @@ builds: goarch: s390x dir: _build binary: otelcol-contrib + builder: prebuilt + prebuilt: + path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} archives: - id: otelcol-contrib builds: From 111e357a852f28214f427dd69bb89710ff7712c1 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 14 Nov 2024 14:38:22 +0100 Subject: [PATCH 07/40] polishing Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 14 ++++++++------ Makefile | 2 +- cmd/goreleaser/internal/configure.go | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index 5e39ae79..4953f069 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -77,12 +77,14 @@ jobs: run_id=$(gh run list --branch main --workflow build-and-test --repo open-telemetry/opentelemetry-collector-contrib --limit 1 --status success --json databaseId --jq '.[0].databaseId') echo "run_id=$run_id" >> "$GITHUB_OUTPUT" - - run: mkdir -p distributions/otelcol-contrib/artifacts + - name: Create artifacts directory to store prebuilt artifacts + run: mkdir -p distributions/otelcol-contrib/artifacts - - run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1 + - name: Create sub-directory for otelcol-contrib nightly build if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest == true }} + run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1 - - name: Download built otelcontribcol artifact from contrib repo + - name: Download built otelcol-contrib artifact from contrib repo if: inputs.latest == true uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: @@ -91,7 +93,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ steps.get-run-id.outputs.run_id }} - - name: Rename downloaded artifact + - name: Move downloaded artifact if: inputs.latest == true run: mv otelcontribcol_linux_amd64 distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1/otelcol-contrib @@ -119,8 +121,8 @@ jobs: - if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest != true }} run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/ - - run: ls -laR distributions/otelcol-contrib/artifacts - if: ${{ inputs.distribution == 'otelcol-contrib' }} + - if: ${{ inputs.distribution == 'otelcol-contrib' }} + run: ls -laR distributions/otelcol-contrib/artifacts - name: Run GoReleaser for ${{ inputs.distribution }} uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 diff --git a/Makefile b/Makefile index 23e1673a..1f7708a9 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ OTELCOL_BUILDER_VERSION ?= 0.114.0 OTELCOL_BUILDER_DIR ?= ${HOME}/bin OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb -DISTRIBUTIONS ?= "otelcol-contrib" +DISTRIBUTIONS ?= "otelcol,otelcol-contrib,otelcol-k8s,otelcol-otlp" ci: check build check: ensure-goreleaser-up-to-date diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index b5d0e64a..43a30ad5 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -60,14 +60,14 @@ func GenerateContribBuildOnly(dist string, buildOrRest bool) config.Project { } } -func Generate(dist string, split bool) config.Project { +func Generate(dist string, buildOrRest bool) config.Project { return config.Project{ ProjectName: "opentelemetry-collector-releases", Checksum: config.Checksum{ NameTemplate: fmt.Sprintf("{{ .ProjectName }}_%v_checksums.txt", dist), }, Env: []string{"COSIGN_YES=true"}, - Builds: Builds(dist, split), + Builds: Builds(dist, buildOrRest), Archives: Archives(dist), MSI: WinPackages(dist), NFPMs: Packages(dist), From 3d09e7af45a51e8c34f7dafcb2b573ec514f5122 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 14 Nov 2024 15:17:23 +0100 Subject: [PATCH 08/40] trigger build From b8cefe5540571806ecd90ad7b06788ed16bdb47f Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 21 Nov 2024 13:55:30 +0100 Subject: [PATCH 09/40] rename files Signed-off-by: Moritz Wiesinger --- .github/workflows/base-package-tests.yaml | 30 ++++++++++ .github/workflows/nightly-package-tests.yml | 44 -------------- .github/workflows/package-tests.yaml | 64 +++++++++++++-------- 3 files changed, 69 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/base-package-tests.yaml delete mode 100644 .github/workflows/nightly-package-tests.yml diff --git a/.github/workflows/base-package-tests.yaml b/.github/workflows/base-package-tests.yaml new file mode 100644 index 00000000..57d10102 --- /dev/null +++ b/.github/workflows/base-package-tests.yaml @@ -0,0 +1,30 @@ +name: Package Tests + +on: + workflow_call: + inputs: + type: + required: true + type: string + distribution: + required: true + type: string + +jobs: + package-tests: + name: Package Tests + runs-on: ubuntu-latest + strategy: + matrix: + type: ${{ fromJSON(inputs.type) }} + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Download built artifacts + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: linux-packages + + - name: Test ${{ matrix.type }} package + run: ./scripts/package-tests/package-tests.sh ./otelcol*-SNAPSHOT-*_linux_amd64.${{ matrix.type }} ${{ inputs.distribution }} diff --git a/.github/workflows/nightly-package-tests.yml b/.github/workflows/nightly-package-tests.yml deleted file mode 100644 index 511204fe..00000000 --- a/.github/workflows/nightly-package-tests.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Nightly Package Tests - Contrib - GoReleaser - -on: - push: - branches: [main] - paths: - - "distributions/otelcol-contrib/**" - - "cmd/**" - - ".github/**" - - "scripts/**" - - "Makefile" - - "go.mod" - - "go.sum" - pull_request: - branches: [main] - paths: - - "distributions/otelcol-contrib/**" - - "cmd/**" - - ".github/**" - - "scripts/**" - - "Makefile" - - "go.mod" - - "go.sum" -# schedule: -# - - -jobs: - check-goreleaser: - name: Continuous Integration - Contrib - GoReleaser - uses: ./.github/workflows/base-ci-goreleaser.yaml - with: - distribution: otelcol-contrib - goos: '[ "linux" ]' - goarch: '[ "amd64" ]' - latest: true - secrets: inherit - - package-tests: - name: Package tests - needs: check-goreleaser - uses: ./.github/workflows/package-tests.yaml - with: - distribution: otelcol-contrib - type: '[ "deb", "rpm" ]' diff --git a/.github/workflows/package-tests.yaml b/.github/workflows/package-tests.yaml index 57d10102..c9c9c40e 100644 --- a/.github/workflows/package-tests.yaml +++ b/.github/workflows/package-tests.yaml @@ -1,30 +1,44 @@ -name: Package Tests +name: Nightly Package Tests - Contrib - GoReleaser on: - workflow_call: - inputs: - type: - required: true - type: string - distribution: - required: true - type: string + push: + branches: [main] + paths: + - "distributions/otelcol-contrib/**" + - "cmd/**" + - ".github/**" + - "scripts/**" + - "Makefile" + - "go.mod" + - "go.sum" + pull_request: + branches: [main] + paths: + - "distributions/otelcol-contrib/**" + - "cmd/**" + - ".github/**" + - "scripts/**" + - "Makefile" + - "go.mod" + - "go.sum" + schedule: + - cron: "0 2 * * *" # every day at 2am UTC jobs: - package-tests: - name: Package Tests - runs-on: ubuntu-latest - strategy: - matrix: - type: ${{ fromJSON(inputs.type) }} - steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Download built artifacts - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 - with: - name: linux-packages + check-goreleaser: + name: Continuous Integration - Contrib - GoReleaser + uses: ./.github/workflows/base-ci-goreleaser.yaml + with: + distribution: otelcol-contrib + goos: '[ "linux" ]' + goarch: '[ "amd64" ]' + latest: true + secrets: inherit - - name: Test ${{ matrix.type }} package - run: ./scripts/package-tests/package-tests.sh ./otelcol*-SNAPSHOT-*_linux_amd64.${{ matrix.type }} ${{ inputs.distribution }} + package-tests: + name: Package tests + needs: check-goreleaser + uses: ./.github/workflows/package-tests.yaml + with: + distribution: otelcol-contrib + type: '[ "deb", "rpm" ]' From f9e465481a184cc32dffa3aa0c3dce13303bb809 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 21 Nov 2024 13:56:27 +0100 Subject: [PATCH 10/40] rename agai Signed-off-by: Moritz Wiesinger --- .github/workflows/{package-tests.yaml => package-test.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{package-tests.yaml => package-test.yaml} (100%) diff --git a/.github/workflows/package-tests.yaml b/.github/workflows/package-test.yaml similarity index 100% rename from .github/workflows/package-tests.yaml rename to .github/workflows/package-test.yaml From 26e604f5879e195cef6e0d0929782def26e43663 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 21 Nov 2024 13:59:20 +0100 Subject: [PATCH 11/40] remove push trigger Signed-off-by: Moritz Wiesinger --- .github/workflows/package-test.yaml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/package-test.yaml b/.github/workflows/package-test.yaml index c9c9c40e..4a371094 100644 --- a/.github/workflows/package-test.yaml +++ b/.github/workflows/package-test.yaml @@ -1,16 +1,6 @@ name: Nightly Package Tests - Contrib - GoReleaser on: - push: - branches: [main] - paths: - - "distributions/otelcol-contrib/**" - - "cmd/**" - - ".github/**" - - "scripts/**" - - "Makefile" - - "go.mod" - - "go.sum" pull_request: branches: [main] paths: From 38f5c812569f1f2a8dbe63b59f5b045539e6b4d4 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 21 Nov 2024 14:12:01 +0100 Subject: [PATCH 12/40] rename jobs, use pinned ubuntu version Signed-off-by: Moritz Wiesinger --- .github/workflows/base-package-tests.yaml | 2 +- .github/workflows/package-test.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/base-package-tests.yaml b/.github/workflows/base-package-tests.yaml index 57d10102..d5809c11 100644 --- a/.github/workflows/base-package-tests.yaml +++ b/.github/workflows/base-package-tests.yaml @@ -13,7 +13,7 @@ on: jobs: package-tests: name: Package Tests - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 strategy: matrix: type: ${{ fromJSON(inputs.type) }} diff --git a/.github/workflows/package-test.yaml b/.github/workflows/package-test.yaml index 4a371094..2d3882a9 100644 --- a/.github/workflows/package-test.yaml +++ b/.github/workflows/package-test.yaml @@ -16,7 +16,7 @@ on: jobs: check-goreleaser: - name: Continuous Integration - Contrib - GoReleaser + name: Build - Contrib - GoReleaser uses: ./.github/workflows/base-ci-goreleaser.yaml with: distribution: otelcol-contrib @@ -26,7 +26,7 @@ jobs: secrets: inherit package-tests: - name: Package tests + name: Linux Package tests needs: check-goreleaser uses: ./.github/workflows/package-tests.yaml with: From a79e4339a92e0af17954ebde5f85b58f630256cd Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 21 Nov 2024 14:16:44 +0100 Subject: [PATCH 13/40] remove curly braces, refactoring Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 27 +++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index 4953f069..a5284e4e 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -54,7 +54,7 @@ jobs: platforms: arm64,ppc64le,linux/arm/v7,s390x - name: Setup wixl # Required to build MSI packages for Windows - if: ${{ matrix.GOOS == 'windows' && ( matrix.GOARCH == '386' || matrix.GOARCH == 'amd64') }} + if: matrix.GOOS == 'windows' && ( matrix.GOARCH == '386' || matrix.GOARCH == 'amd64') run: | sudo apt-get update sudo apt-get install -y wixl @@ -74,18 +74,27 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - run_id=$(gh run list --branch main --workflow build-and-test --repo open-telemetry/opentelemetry-collector-contrib --limit 1 --status success --json databaseId --jq '.[0].databaseId') + run_id=$(gh run list \ + --branch main \ + --workflow build-and-test \ + --repo open-telemetry/opentelemetry-collector-contrib \ + --limit 1 \ + --status success \ + --json databaseId \ + --jq '.[0].databaseId' \ + ) + echo "Found run ID: $run_id" echo "run_id=$run_id" >> "$GITHUB_OUTPUT" - - name: Create artifacts directory to store prebuilt artifacts + - name: Create artifacts directory to store build artifacts run: mkdir -p distributions/otelcol-contrib/artifacts - name: Create sub-directory for otelcol-contrib nightly build - if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest == true }} + if: inputs.distribution == 'otelcol-contrib' && inputs.latest == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1 - name: Download built otelcol-contrib artifact from contrib repo - if: inputs.latest == true + if: inputs.latest == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: collector-binaries-linux-amd64 @@ -104,7 +113,7 @@ jobs: run: make generate-sources - name: Run split GoReleaser build for otelcol-contrib - if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest != true }} + if: inputs.distribution == 'otelcol-contrib' && inputs.latest != true uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0 with: distribution: goreleaser-pro @@ -118,10 +127,10 @@ jobs: GOAMD64: v1 GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} - - if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest != true }} + - if: inputs.distribution == 'otelcol-contrib' && inputs.latest != true run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/ - - if: ${{ inputs.distribution == 'otelcol-contrib' }} + - if: inputs.distribution == 'otelcol-contrib' run: ls -laR distributions/otelcol-contrib/artifacts - name: Run GoReleaser for ${{ inputs.distribution }} @@ -138,7 +147,7 @@ jobs: GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} - name: Upload linux service packages - if: ${{ matrix.GOOS == 'linux' && matrix.GOARCH == 'amd64' }} + if: matrix.GOOS == 'linux' && matrix.GOARCH == 'amd64' uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: linux-packages From 6f9b5d9a346d6abd9998c6483c84c47572f647e0 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 21 Nov 2024 14:44:19 +0100 Subject: [PATCH 14/40] minor polishing and refactoring Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index a5284e4e..adb85217 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -103,7 +103,7 @@ jobs: run-id: ${{ steps.get-run-id.outputs.run_id }} - name: Move downloaded artifact - if: inputs.latest == true + if: inputs.latest == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' run: mv otelcontribcol_linux_amd64 distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1/otelcol-contrib - name: Generate the sources for ${{ inputs.distribution }} @@ -112,12 +112,13 @@ jobs: DISTRIBUTIONS: ${{ inputs.distribution }} run: make generate-sources - - name: Run split GoReleaser build for otelcol-contrib + # otelcol-contrib is built in a separate stage + - name: Build ${{ inputs.distribution }} if: inputs.distribution == 'otelcol-contrib' && inputs.latest != true - uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0 + uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 with: distribution: goreleaser-pro - version: v2.3.2 + version: ${{ env.GORELEASER_PRO_VERSION }} workdir: distributions/otelcol-contrib args: --snapshot --clean --timeout 2h --split --config .goreleaser-build.yaml env: @@ -130,7 +131,8 @@ jobs: - if: inputs.distribution == 'otelcol-contrib' && inputs.latest != true run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/ - - if: inputs.distribution == 'otelcol-contrib' + - name: Show built content + if: inputs.distribution == 'otelcol-contrib' run: ls -laR distributions/otelcol-contrib/artifacts - name: Run GoReleaser for ${{ inputs.distribution }} @@ -147,7 +149,7 @@ jobs: GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} - name: Upload linux service packages - if: matrix.GOOS == 'linux' && matrix.GOARCH == 'amd64' + if: matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: linux-packages From b9586c5d8d9bd489eb95103c46d6d6f5d1623b1c Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 21 Nov 2024 14:46:42 +0100 Subject: [PATCH 15/40] remove trigger on PR Signed-off-by: Moritz Wiesinger --- .github/workflows/package-test.yaml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/package-test.yaml b/.github/workflows/package-test.yaml index 2d3882a9..c3cd085a 100644 --- a/.github/workflows/package-test.yaml +++ b/.github/workflows/package-test.yaml @@ -1,16 +1,6 @@ name: Nightly Package Tests - Contrib - GoReleaser on: - pull_request: - branches: [main] - paths: - - "distributions/otelcol-contrib/**" - - "cmd/**" - - ".github/**" - - "scripts/**" - - "Makefile" - - "go.mod" - - "go.sum" schedule: - cron: "0 2 * * *" # every day at 2am UTC From 9bcb1021fca109adf961d23cedcc62a95b2235ea Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 21 Nov 2024 15:30:12 +0100 Subject: [PATCH 16/40] minor refactoring Signed-off-by: Moritz Wiesinger --- cmd/goreleaser/internal/configure.go | 39 +++++++++++----------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index 43a30ad5..8c4e221a 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -109,14 +109,11 @@ func Build(dist string, buildOrRest bool) config.Build { } } - var goos []string - var archs []string + goos := []string{"darwin", "linux", "windows"} + archs := Architectures if dist == K8sDistro { goos = K8sGoos archs = K8sArchs - } else { - goos = []string{"darwin", "linux", "windows"} - archs = Architectures } return config.Build{ ID: dist, @@ -136,7 +133,7 @@ func Build(dist string, buildOrRest bool) config.Build { func IgnoreBuildCombinations(dist string) []config.IgnoredBuild { if dist == K8sDistro { - return make([]config.IgnoredBuild, 0) + return nil } return []config.IgnoredBuild{ {Goos: "darwin", Goarch: "386"}, @@ -150,12 +147,12 @@ func IgnoreBuildCombinations(dist string) []config.IgnoredBuild { func ArmVersions(dist string) []string { if dist == K8sDistro { - return make([]string, 0) + return nil } return []string{"7"} } -func Archives(dist string) (r []config.Archive) { +func Archives(dist string) []config.Archive { return []config.Archive{ Archive(dist), } @@ -173,7 +170,7 @@ func Archive(dist string) config.Archive { func WinPackages(dist string) []config.MSI { if _, ok := MSIWindowsDists[dist]; !ok { - return []config.MSI{} + return nil } return []config.MSI{ WinPackage(dist), @@ -195,9 +192,9 @@ func WinPackage(dist string) config.MSI { } } -func Packages(dist string) (r []config.NFPM) { +func Packages(dist string) []config.NFPM { if dist == K8sDistro { - return []config.NFPM{} + return nil } return []config.NFPM{ Package(dist), @@ -226,21 +223,17 @@ func Package(dist string) config.NFPM { }) } return config.NFPM{ - ID: dist, - Builds: []string{dist}, - Formats: []string{"deb", "rpm"}, - + ID: dist, + Builds: []string{dist}, + Formats: []string{"deb", "rpm"}, License: "Apache 2.0", Description: fmt.Sprintf("OpenTelemetry Collector - %s", dist), Maintainer: "The OpenTelemetry Collector maintainers ", Overrides: map[string]config.NFPMOverridables{ "rpm": { - Dependencies: []string{ - "/bin/sh", - }, + Dependencies: []string{"/bin/sh"}, }, }, - NFPMOverridables: config.NFPMOverridables{ PackageName: dist, Scripts: config.NFPMScripts{ @@ -254,12 +247,10 @@ func Package(dist string) config.NFPM { } func DockerImages(dist string) []config.Docker { - r := make([]config.Docker, 0) + var r []config.Docker for _, arch := range Architectures { - if dist == K8sDistro { - if _, ok := K8sDockerSkipArchs[arch]; ok { - continue - } + if dist == K8sDistro && K8sDockerSkipArchs[arch] { + continue } switch arch { case ArmArch: From 5178475467eddb59d8462c9ed5f56aa39d2d0758 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 21 Nov 2024 15:40:43 +0100 Subject: [PATCH 17/40] renaming Signed-off-by: Moritz Wiesinger --- .github/workflows/package-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package-test.yaml b/.github/workflows/package-test.yaml index c3cd085a..217f3044 100644 --- a/.github/workflows/package-test.yaml +++ b/.github/workflows/package-test.yaml @@ -1,4 +1,4 @@ -name: Nightly Package Tests - Contrib - GoReleaser +name: Package Tests - Contrib on: schedule: From f779d204d9fa0c79867eb5e87b42c4a75d066e89 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Mon, 25 Nov 2024 09:07:48 +0100 Subject: [PATCH 18/40] minor refactoring Signed-off-by: Moritz Wiesinger --- cmd/goreleaser/internal/configure.go | 12 +++++++----- cmd/goreleaser/main.go | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index 8c4e221a..a83fd71a 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -92,7 +92,10 @@ func Builds(dist string, buildOrRest bool) []config.Build { // Build configures a goreleaser build. // https://goreleaser.com/customization/build/ func Build(dist string, buildOrRest bool) config.Build { - if !buildOrRest && dist == ContribDistro { + goos := []string{"darwin", "linux", "windows"} + archs := Architectures + + if dist == ContribDistro && !buildOrRest { // only return build config for contrib build file return config.Build{ ID: dist, @@ -100,8 +103,8 @@ func Build(dist string, buildOrRest bool) config.Build { PreBuilt: config.PreBuiltOptions{ Path: "artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os \"windows\" }}.exe{{ end }}", }, - Goos: []string{"darwin", "linux", "windows"}, - Goarch: Architectures, + Goos: goos, + Goarch: archs, Goarm: ArmVersions(dist), Dir: "_build", Binary: dist, @@ -109,12 +112,11 @@ func Build(dist string, buildOrRest bool) config.Build { } } - goos := []string{"darwin", "linux", "windows"} - archs := Architectures if dist == K8sDistro { goos = K8sGoos archs = K8sArchs } + return config.Build{ ID: dist, Dir: "_build", diff --git a/cmd/goreleaser/main.go b/cmd/goreleaser/main.go index a02e14d3..9695192b 100644 --- a/cmd/goreleaser/main.go +++ b/cmd/goreleaser/main.go @@ -26,7 +26,7 @@ import ( ) var distFlag = flag.String("d", "", "Collector distributions to build") -var contribBuildOrRestFlag = flag.Bool("b", false, "Collector Contrib distribution only - switch between build and package config file - set to true to generate build step, false to generate pacakge step") +var contribBuildOrRestFlag = flag.Bool("b", false, "Collector Contrib distribution only - switch between build and package config file - set to true to generate build step, false to generate package step") func main() { flag.Parse() From 9acfee36bb4541532be4c06a16d9f36c46ef59ea Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Tue, 26 Nov 2024 08:24:53 +0100 Subject: [PATCH 19/40] revert beauty changes for separate PR Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 4 ++-- .github/workflows/base-package-tests.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index adb85217..c2599cd3 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -54,7 +54,7 @@ jobs: platforms: arm64,ppc64le,linux/arm/v7,s390x - name: Setup wixl # Required to build MSI packages for Windows - if: matrix.GOOS == 'windows' && ( matrix.GOARCH == '386' || matrix.GOARCH == 'amd64') + if: ${{ matrix.GOOS == 'windows' && ( matrix.GOARCH == '386' || matrix.GOARCH == 'amd64') }} run: | sudo apt-get update sudo apt-get install -y wixl @@ -149,7 +149,7 @@ jobs: GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} - name: Upload linux service packages - if: matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' + if: ${{ matrix.GOOS == 'linux' && matrix.GOARCH == 'amd64' }} uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: linux-packages diff --git a/.github/workflows/base-package-tests.yaml b/.github/workflows/base-package-tests.yaml index d5809c11..57d10102 100644 --- a/.github/workflows/base-package-tests.yaml +++ b/.github/workflows/base-package-tests.yaml @@ -13,7 +13,7 @@ on: jobs: package-tests: name: Package Tests - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest strategy: matrix: type: ${{ fromJSON(inputs.type) }} From 74152b61306f669b7989ba5385014a450b5f2973 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 08:39:45 +0100 Subject: [PATCH 20/40] rename input variable and add description Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 17 +++++++++-------- .github/workflows/package-test.yaml | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index c2599cd3..f7db0120 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -12,10 +12,11 @@ on: goarch: required: true type: string - latest: + nightly: required: false type: boolean default: false + description: "Set to true to fetch latest otelcol-contrib main branch version instead of building the version in this repo" env: # renovate: datasource=github-tags depName=goreleaser-pro packageName=goreleaser/goreleaser-pro @@ -70,7 +71,7 @@ jobs: - name: Get latest finished run ID from contrib repo build-and-test id: get-run-id - if: inputs.latest == true + if: inputs.nightly == true env: GH_TOKEN: ${{ github.token }} run: | @@ -90,11 +91,11 @@ jobs: run: mkdir -p distributions/otelcol-contrib/artifacts - name: Create sub-directory for otelcol-contrib nightly build - if: inputs.distribution == 'otelcol-contrib' && inputs.latest == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' + if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1 - name: Download built otelcol-contrib artifact from contrib repo - if: inputs.latest == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' + if: inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: collector-binaries-linux-amd64 @@ -103,18 +104,18 @@ jobs: run-id: ${{ steps.get-run-id.outputs.run_id }} - name: Move downloaded artifact - if: inputs.latest == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' + if: inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' run: mv otelcontribcol_linux_amd64 distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1/otelcol-contrib - name: Generate the sources for ${{ inputs.distribution }} - if: inputs.latest != true + if: inputs.nightly != true env: DISTRIBUTIONS: ${{ inputs.distribution }} run: make generate-sources # otelcol-contrib is built in a separate stage - name: Build ${{ inputs.distribution }} - if: inputs.distribution == 'otelcol-contrib' && inputs.latest != true + if: inputs.distribution == 'otelcol-contrib' && inputs.nightly != true uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 with: distribution: goreleaser-pro @@ -128,7 +129,7 @@ jobs: GOAMD64: v1 GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} - - if: inputs.distribution == 'otelcol-contrib' && inputs.latest != true + - if: inputs.distribution == 'otelcol-contrib' && inputs.nightly != true run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/ - name: Show built content diff --git a/.github/workflows/package-test.yaml b/.github/workflows/package-test.yaml index 217f3044..fc1671fe 100644 --- a/.github/workflows/package-test.yaml +++ b/.github/workflows/package-test.yaml @@ -12,7 +12,7 @@ jobs: distribution: otelcol-contrib goos: '[ "linux" ]' goarch: '[ "amd64" ]' - latest: true + nightly: true secrets: inherit package-tests: From 45101566492473a92d6e5949aee55d4dc10dfdf2 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 08:57:26 +0100 Subject: [PATCH 21/40] rename build step flag Signed-off-by: Moritz Wiesinger --- cmd/goreleaser/main.go | 2 +- scripts/generate-goreleaser.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/goreleaser/main.go b/cmd/goreleaser/main.go index 9695192b..ae9ffcaa 100644 --- a/cmd/goreleaser/main.go +++ b/cmd/goreleaser/main.go @@ -26,7 +26,7 @@ import ( ) var distFlag = flag.String("d", "", "Collector distributions to build") -var contribBuildOrRestFlag = flag.Bool("b", false, "Collector Contrib distribution only - switch between build and package config file - set to true to generate build step, false to generate package step") +var contribBuildOrRestFlag = flag.Bool("generate-build-step", false, "Collector Contrib distribution only - switch between build and package config file - set to true to generate build step, false to generate package step") func main() { flag.Parse() diff --git a/scripts/generate-goreleaser.sh b/scripts/generate-goreleaser.sh index 91144359..e3262bd6 100755 --- a/scripts/generate-goreleaser.sh +++ b/scripts/generate-goreleaser.sh @@ -24,7 +24,7 @@ echo "Distributions to generate: $distributions"; for distribution in $(echo "$distributions" | tr "," "\n") do if [[ "$distribution" == "otelcol-contrib" ]]; then - ${GO} run cmd/goreleaser/main.go -d "${distribution}" -b > "./distributions/${distribution}/.goreleaser-build.yaml" + ${GO} run cmd/goreleaser/main.go -d "${distribution}" --generate-build-step > "./distributions/${distribution}/.goreleaser-build.yaml" fi ${GO} run cmd/goreleaser/main.go -d "${distribution}" > "./distributions/${distribution}/.goreleaser.yaml" From acb1bfdf65dcee5ff9dc0ae086f6ef293733e2ca Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 09:02:50 +0100 Subject: [PATCH 22/40] add conditional Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index f7db0120..6659c342 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -88,6 +88,7 @@ jobs: echo "run_id=$run_id" >> "$GITHUB_OUTPUT" - name: Create artifacts directory to store build artifacts + if: inputs.distribution == 'otelcol-contrib' run: mkdir -p distributions/otelcol-contrib/artifacts - name: Create sub-directory for otelcol-contrib nightly build @@ -129,7 +130,8 @@ jobs: GOAMD64: v1 GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} - - if: inputs.distribution == 'otelcol-contrib' && inputs.nightly != true + - name: Move built artifacts + if: inputs.distribution == 'otelcol-contrib' && inputs.nightly != true run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/ - name: Show built content From 6f778d14160dd3c310a6ec10c3bb1097ec9b0c13 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 09:52:52 +0100 Subject: [PATCH 23/40] better conditionals and namin Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index 6659c342..2575222e 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -96,7 +96,7 @@ jobs: run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1 - name: Download built otelcol-contrib artifact from contrib repo - if: inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' + if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: collector-binaries-linux-amd64 @@ -105,7 +105,7 @@ jobs: run-id: ${{ steps.get-run-id.outputs.run_id }} - name: Move downloaded artifact - if: inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' + if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' run: mv otelcontribcol_linux_amd64 distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1/otelcol-contrib - name: Generate the sources for ${{ inputs.distribution }} @@ -134,7 +134,7 @@ jobs: if: inputs.distribution == 'otelcol-contrib' && inputs.nightly != true run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/ - - name: Show built content + - name: Show built or downloaded content if: inputs.distribution == 'otelcol-contrib' run: ls -laR distributions/otelcol-contrib/artifacts From 8eb85698fb4388008827ee083ad6372fcb7fc825 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 10:12:49 +0100 Subject: [PATCH 24/40] fix workflow reference Signed-off-by: Moritz Wiesinger --- .github/workflows/ci-goreleaser-contrib.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-goreleaser-contrib.yaml b/.github/workflows/ci-goreleaser-contrib.yaml index fed5f85d..a85e0f22 100644 --- a/.github/workflows/ci-goreleaser-contrib.yaml +++ b/.github/workflows/ci-goreleaser-contrib.yaml @@ -36,7 +36,7 @@ jobs: package-tests: name: Package tests needs: check-goreleaser - uses: ./.github/workflows/package-tests.yaml + uses: ./.github/workflows/base-package-tests.yaml with: distribution: otelcol-contrib type: '[ "deb", "rpm" ]' From c9911c7a2462e29b35accd3124c900ff7a9ae911 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 10:15:02 +0100 Subject: [PATCH 25/40] more naming fixes Signed-off-by: Moritz Wiesinger --- .github/workflows/package-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package-test.yaml b/.github/workflows/package-test.yaml index fc1671fe..b0ab6cfc 100644 --- a/.github/workflows/package-test.yaml +++ b/.github/workflows/package-test.yaml @@ -18,7 +18,7 @@ jobs: package-tests: name: Linux Package tests needs: check-goreleaser - uses: ./.github/workflows/package-tests.yaml + uses: ./.github/workflows/base-package-tests.yaml with: distribution: otelcol-contrib type: '[ "deb", "rpm" ]' From 406b0284c4aab0c2640bb88c9a393bad17a2abb4 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 10:18:15 +0100 Subject: [PATCH 26/40] enable package test workflow again for debugging Signed-off-by: Moritz Wiesinger --- .github/workflows/package-test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/package-test.yaml b/.github/workflows/package-test.yaml index b0ab6cfc..674cc662 100644 --- a/.github/workflows/package-test.yaml +++ b/.github/workflows/package-test.yaml @@ -1,6 +1,8 @@ name: Package Tests - Contrib on: + pull_request: + branches: [main] schedule: - cron: "0 2 * * *" # every day at 2am UTC From 0246a3b231c68800c6d80962a3f473d2fd5f7775 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 10:23:03 +0100 Subject: [PATCH 27/40] fix more naming Signed-off-by: Moritz Wiesinger --- .github/workflows/ci-goreleaser-core.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-goreleaser-core.yaml b/.github/workflows/ci-goreleaser-core.yaml index 80a116a8..ae191138 100644 --- a/.github/workflows/ci-goreleaser-core.yaml +++ b/.github/workflows/ci-goreleaser-core.yaml @@ -37,7 +37,7 @@ jobs: package-tests: name: Package tests needs: check-goreleaser - uses: ./.github/workflows/package-tests.yaml + uses: ./.github/workflows/base-package-tests.yaml with: distribution: otelcol type: '[ "deb", "rpm" ]' From 00277a24d88aa5b02fd76a7692b37bd742e38928 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 11:15:32 +0100 Subject: [PATCH 28/40] refactoring Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index 2575222e..6c64922c 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -69,9 +69,13 @@ jobs: go-version: '1.23' check-latest: true + - name: Create artifacts directory to store build artifacts + if: inputs.distribution == 'otelcol-contrib' + run: mkdir -p distributions/otelcol-contrib/artifacts + - name: Get latest finished run ID from contrib repo build-and-test id: get-run-id - if: inputs.nightly == true + if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' env: GH_TOKEN: ${{ github.token }} run: | @@ -87,10 +91,6 @@ jobs: echo "Found run ID: $run_id" echo "run_id=$run_id" >> "$GITHUB_OUTPUT" - - name: Create artifacts directory to store build artifacts - if: inputs.distribution == 'otelcol-contrib' - run: mkdir -p distributions/otelcol-contrib/artifacts - - name: Create sub-directory for otelcol-contrib nightly build if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1 From 5b0723cd149473ff25535bfd0f4fdf6556d44d4c Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 13:10:04 +0100 Subject: [PATCH 29/40] use target template variable Signed-off-by: Moritz Wiesinger --- distributions/otelcol-contrib/.goreleaser.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index 653e0dd6..fdbaa512 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -43,12 +43,12 @@ builds: binary: otelcol-contrib builder: prebuilt prebuilt: - path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} + path: artifacts/otelcol-contrib_{{ .Target }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} archives: - id: otelcol-contrib builds: - otelcol-contrib - name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}' + name_template: '{{ .Binary }}_{{ .Version }}_{{ .Target }}' nfpms: - package_name: otelcol-contrib contents: From ef8776327457977e39d91138541d190699821aca Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 13:27:20 +0100 Subject: [PATCH 30/40] add go386 variable to filenames Signed-off-by: Moritz Wiesinger --- distributions/otelcol-contrib/.goreleaser.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index fdbaa512..7872a31f 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -43,12 +43,12 @@ builds: binary: otelcol-contrib builder: prebuilt prebuilt: - path: artifacts/otelcol-contrib_{{ .Target }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} + path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ with .Go386 }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} archives: - id: otelcol-contrib builds: - otelcol-contrib - name_template: '{{ .Binary }}_{{ .Version }}_{{ .Target }}' + name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}' nfpms: - package_name: otelcol-contrib contents: From 1aade2eee5d7ae3fb47d77b2e3faee8eaa9754c3 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 13:33:28 +0100 Subject: [PATCH 31/40] fix template variable Signed-off-by: Moritz Wiesinger --- distributions/otelcol-contrib/.goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index 7872a31f..b4d85647 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -43,7 +43,7 @@ builds: binary: otelcol-contrib builder: prebuilt prebuilt: - path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ with .Go386 }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} + path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ with .I386 }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} archives: - id: otelcol-contrib builds: From 9953e1837b717d17a081b701d60f22a69ea85b05 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 13:44:33 +0100 Subject: [PATCH 32/40] add goarm64 variable Signed-off-by: Moritz Wiesinger --- distributions/otelcol-contrib/.goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index b4d85647..28817632 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -43,7 +43,7 @@ builds: binary: otelcol-contrib builder: prebuilt prebuilt: - path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ with .I386 }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} + path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ with .I386 }}_{{ . }}{{ end }}{{ with .Arm64 }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} archives: - id: otelcol-contrib builds: From 4a47ab88b940121c8c4d0879204c071c4acc9e18 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 13:48:07 +0100 Subject: [PATCH 33/40] adapt goreleaser generator Signed-off-by: Moritz Wiesinger --- cmd/goreleaser/internal/configure.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index a83fd71a..bafd7c53 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -101,7 +101,7 @@ func Build(dist string, buildOrRest bool) config.Build { ID: dist, Builder: "prebuilt", PreBuilt: config.PreBuiltOptions{ - Path: "artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os \"windows\" }}.exe{{ end }}", + Path: "artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ with .I386 }}_{{ . }}{{ end }}{{ with .Arm64 }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os \"windows\" }}.exe{{ end }}", }, Goos: goos, Goarch: archs, From 64968de89b7948db9dccf7f13d51c1ea585dde7c Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 13:49:16 +0100 Subject: [PATCH 34/40] line breaks Signed-off-by: Moritz Wiesinger --- cmd/goreleaser/internal/configure.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index bafd7c53..41c0847b 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -101,7 +101,13 @@ func Build(dist string, buildOrRest bool) config.Build { ID: dist, Builder: "prebuilt", PreBuilt: config.PreBuiltOptions{ - Path: "artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ with .I386 }}_{{ . }}{{ end }}{{ with .Arm64 }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os \"windows\" }}.exe{{ end }}", + Path: "artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}" + + "{{ with .Amd64 }}_{{ . }}{{ end }}" + + "{{ with .Arm }}_{{ . }}{{ end }}" + + "{{ with .Mips }}_{{ . }}{{ end }}" + + "{{ with .I386 }}_{{ . }}{{ end }}" + + "{{ with .Arm64 }}_{{ . }}{{ end }}" + + "/otelcol-contrib{{- if eq .Os \"windows\" }}.exe{{ end }}", }, Goos: goos, Goarch: archs, From e4a05a5cc6691b1ecff83d09c778e6d6fd13cbcc Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 15:13:38 +0100 Subject: [PATCH 35/40] prefix nightly steps Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index 6c64922c..5c50a8da 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -73,7 +73,7 @@ jobs: if: inputs.distribution == 'otelcol-contrib' run: mkdir -p distributions/otelcol-contrib/artifacts - - name: Get latest finished run ID from contrib repo build-and-test + - name: [Nightly] Get latest finished run ID from contrib repo build-and-test id: get-run-id if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' env: @@ -91,11 +91,11 @@ jobs: echo "Found run ID: $run_id" echo "run_id=$run_id" >> "$GITHUB_OUTPUT" - - name: Create sub-directory for otelcol-contrib nightly build + - name: [Nightly] Create sub-directory for otelcol-contrib nightly build if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1 - - name: Download built otelcol-contrib artifact from contrib repo + - name: [Nightly] Download built otelcol-contrib artifact from contrib repo if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: @@ -104,7 +104,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ steps.get-run-id.outputs.run_id }} - - name: Move downloaded artifact + - name: [Nightly] Move downloaded artifact if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' run: mv otelcontribcol_linux_amd64 distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1/otelcol-contrib From 2daf32ce75674a3bb5f3d04e72010f50ab4ca162 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 15:19:49 +0100 Subject: [PATCH 36/40] add missing quotes Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index 5c50a8da..4e9799f0 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -73,7 +73,7 @@ jobs: if: inputs.distribution == 'otelcol-contrib' run: mkdir -p distributions/otelcol-contrib/artifacts - - name: [Nightly] Get latest finished run ID from contrib repo build-and-test + - name: "[Nightly] Get latest finished run ID from contrib repo build-and-test" id: get-run-id if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' env: @@ -91,11 +91,11 @@ jobs: echo "Found run ID: $run_id" echo "run_id=$run_id" >> "$GITHUB_OUTPUT" - - name: [Nightly] Create sub-directory for otelcol-contrib nightly build + - name: "[Nightly] Create sub-directory for otelcol-contrib nightly build" if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1 - - name: [Nightly] Download built otelcol-contrib artifact from contrib repo + - name: "[Nightly] Download built otelcol-contrib artifact from contrib repo" if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: @@ -104,7 +104,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ steps.get-run-id.outputs.run_id }} - - name: [Nightly] Move downloaded artifact + - name: "[Nightly] Move downloaded artifact" if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux' run: mv otelcontribcol_linux_amd64 distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1/otelcol-contrib From 645ff96e5d8cd4770447bcd9d0776cf45c54d2d0 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 15:23:08 +0100 Subject: [PATCH 37/40] try to use target template var again Signed-off-by: Moritz Wiesinger --- distributions/otelcol-contrib/.goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index 28817632..6323ebea 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -43,7 +43,7 @@ builds: binary: otelcol-contrib builder: prebuilt prebuilt: - path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ with .I386 }}_{{ . }}{{ end }}{{ with .Arm64 }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} + path: artifacts/otelcol-contrib_{{ .Target }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }} archives: - id: otelcol-contrib builds: From 81e2bb0a0e8e32aaeabcf83ee792b3a29cbda56f Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 15:37:19 +0100 Subject: [PATCH 38/40] try to use target env var more Signed-off-by: Moritz Wiesinger --- cmd/goreleaser/internal/configure.go | 9 ++------- distributions/otelcol-contrib/.goreleaser.yaml | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index 41c0847b..e54af381 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -101,12 +101,7 @@ func Build(dist string, buildOrRest bool) config.Build { ID: dist, Builder: "prebuilt", PreBuilt: config.PreBuiltOptions{ - Path: "artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}" + - "{{ with .Amd64 }}_{{ . }}{{ end }}" + - "{{ with .Arm }}_{{ . }}{{ end }}" + - "{{ with .Mips }}_{{ . }}{{ end }}" + - "{{ with .I386 }}_{{ . }}{{ end }}" + - "{{ with .Arm64 }}_{{ . }}{{ end }}" + + Path: "artifacts/otelcol-contrib_{{ .Target }}" + "/otelcol-contrib{{- if eq .Os \"windows\" }}.exe{{ end }}", }, Goos: goos, @@ -171,7 +166,7 @@ func Archives(dist string) []config.Archive { 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 }}", + NameTemplate: "{{ .Binary }}_{{ .Version }}_{{ .Target }}", Builds: []string{dist}, } } diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index 6323ebea..fdbaa512 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -48,7 +48,7 @@ archives: - id: otelcol-contrib builds: - otelcol-contrib - name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}' + name_template: '{{ .Binary }}_{{ .Version }}_{{ .Target }}' nfpms: - package_name: otelcol-contrib contents: From 25f450f8a71964048307398a0883b1dec555ab9d Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 15:39:09 +0100 Subject: [PATCH 39/40] revert name template field Signed-off-by: Moritz Wiesinger --- cmd/goreleaser/internal/configure.go | 2 +- distributions/otelcol-contrib/.goreleaser.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index e54af381..75281bdb 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -166,7 +166,7 @@ func Archives(dist string) []config.Archive { func Archive(dist string) config.Archive { return config.Archive{ ID: dist, - NameTemplate: "{{ .Binary }}_{{ .Version }}_{{ .Target }}", + NameTemplate: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}", Builds: []string{dist}, } } diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index fdbaa512..6323ebea 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -48,7 +48,7 @@ archives: - id: otelcol-contrib builds: - otelcol-contrib - name_template: '{{ .Binary }}_{{ .Version }}_{{ .Target }}' + name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}' nfpms: - package_name: otelcol-contrib contents: From 1b4f00955c4173af2ac3f439d46fe6875fe38e5d Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 28 Nov 2024 16:00:13 +0100 Subject: [PATCH 40/40] remove debug change Signed-off-by: Moritz Wiesinger --- .github/workflows/package-test.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/package-test.yaml b/.github/workflows/package-test.yaml index 674cc662..b0ab6cfc 100644 --- a/.github/workflows/package-test.yaml +++ b/.github/workflows/package-test.yaml @@ -1,8 +1,6 @@ name: Package Tests - Contrib on: - pull_request: - branches: [main] schedule: - cron: "0 2 * * *" # every day at 2am UTC