diff --git a/.chloggen/add_windows_container_images.yaml b/.chloggen/add_windows_container_images.yaml new file mode 100644 index 000000000..868d5aef1 --- /dev/null +++ b/.chloggen/add_windows_container_images.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: packaging + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Start producing container images for Windows 2019 and 2022 on amd64 + +# One or more tracking issues or pull requests related to the change +issues: [339] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/.github/workflows/base-release.yaml b/.github/workflows/base-release.yaml index 02ac86e64..17fde0749 100644 --- a/.github/workflows/base-release.yaml +++ b/.github/workflows/base-release.yaml @@ -12,6 +12,10 @@ on: goarch: required: true type: string + runner_os: + required: false + type: string + default: ubuntu-24.04 env: # renovate: datasource=github-tags depName=goreleaser-pro packageName=goreleaser/goreleaser-pro @@ -21,26 +25,18 @@ jobs: prepare: strategy: matrix: - GOOS: ${{ fromJSON( inputs.goos) }} - GOARCH: ${{ fromJSON( inputs.goarch) }} + GOOS: ${{ fromJSON(inputs.goos) }} + GOARCH: ${{ fromJSON(inputs.goarch) }} exclude: - GOOS: darwin GOARCH: "386" - GOOS: darwin GOARCH: s390x - - GOOS: windows - GOARCH: arm64 - - GOOS: darwin - GOARCH: arm - - GOOS: windows - GOARCH: arm - - GOOS: windows - GOARCH: s390x - GOOS: darwin GOARCH: ppc64le - - GOOS: windows - GOARCH: ppc64le - runs-on: ubuntu-24.04 + - GOOS: darwin + GOARCH: arm + runs-on: ${{ inputs.runner_os }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -52,22 +48,28 @@ jobs: - uses: anchore/sbom-action/download-syft@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0 - uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 + if: runner.os != 'Windows' with: platforms: arm64,ppc64le,linux/arm/v7,s390x - uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 + if: runner.os != 'Windows' + + # Fix slow Go compile and cache restore + # See https://github.com/actions/setup-go/pull/515 + - name: Fix slow setup-go cache restore in Windows + if: runner.os == 'Windows' + run: | + echo "GOCACHE=D:\gocache" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "GOMODCACHE=D:\gomodcache" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "GOTMPDIR=D:\gotmp" | Out-File -FilePath $env:GITHUB_ENV -Append + mkdir D:\gotmp - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: go-version: "~1.24" check-latest: true - - name: Setup wixl # Required to build MSI packages for Windows - if: ${{ matrix.GOOS == 'windows' && ( matrix.GOARCH == '386' || matrix.GOARCH == 'amd64') }} - run: | - sudo apt-get update - sudo apt-get install -y wixl - - name: Generate distribution sources run: make generate-sources @@ -90,6 +92,7 @@ jobs: - name: Create artifacts directory to store build artifacts if: inputs.distribution == 'otelcol-contrib' + shell: bash run: mkdir -p distributions/otelcol-contrib/artifacts # otelcol-contrib is built in a separate stage @@ -113,10 +116,12 @@ jobs: - name: Move built artifacts if: inputs.distribution == 'otelcol-contrib' + shell: bash run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/ - name: Show built or downloaded content if: inputs.distribution == 'otelcol-contrib' + shell: bash run: ls -laR distributions/otelcol-contrib/artifacts - uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 # v6.2.1 @@ -141,7 +146,7 @@ jobs: release: name: ${{ inputs.distribution }} Release - runs-on: ubuntu-24.04 + runs-on: ${{ inputs.runner_os }} needs: prepare permissions: @@ -159,10 +164,22 @@ jobs: - uses: anchore/sbom-action/download-syft@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0 - uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 + if: runner.os != 'Windows' with: platforms: arm64,ppc64le,s390x - uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 + if: runner.os != 'Windows' + + # Fix slow Go compile and cache restore + # See https://github.com/actions/setup-go/pull/515 + - name: Fix slow setup-go cache restore in Windows + if: runner.os == 'Windows' + run: | + echo "GOCACHE=D:\gocache" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "GOMODCACHE=D:\gomodcache" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "GOTMPDIR=D:\gotmp" | Out-File -FilePath $env:GITHUB_ENV -Append + mkdir D:\gotmp - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: @@ -170,12 +187,28 @@ jobs: check-latest: true - uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 + if: runner.os == 'Windows' + with: + pattern: artifacts-${{ inputs.distribution }}-windows-* + path: distributions/${{ inputs.distribution }}/dist + merge-multiple: true + + - uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 + if: runner.os != 'Windows' + with: + pattern: artifacts-${{ inputs.distribution }}-darwin-* + path: distributions/${{ inputs.distribution }}/dist + merge-multiple: true + + - uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 + if: runner.os != 'Windows' with: - pattern: artifacts-${{ inputs.distribution }}-* + pattern: artifacts-${{ inputs.distribution }}-linux-* path: distributions/${{ inputs.distribution }}/dist merge-multiple: true - name: Display structure of downloaded files + shell: bash run: ls -R distributions/${{ inputs.distribution }}/dist - name: Log into Docker.io diff --git a/.github/workflows/release-contrib.yaml b/.github/workflows/release-contrib.yaml index efb6e03e1..a0eb233fe 100644 --- a/.github/workflows/release-contrib.yaml +++ b/.github/workflows/release-contrib.yaml @@ -10,7 +10,17 @@ jobs: uses: ./.github/workflows/base-release.yaml with: distribution: otelcol-contrib - goos: '[ "linux", "windows", "darwin" ]' + goos: '[ "linux", "darwin" ]' goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]' secrets: inherit permissions: write-all + release-windows: + name: Release Contrib (Windows) + uses: ./.github/workflows/base-release.yaml + with: + distribution: otelcol-contrib + goos: '[ "windows" ]' + goarch: '[ "386", "amd64" ]' + runner_os: windows-2022 + secrets: inherit + permissions: write-all diff --git a/.github/workflows/release-core.yaml b/.github/workflows/release-core.yaml index 9c1b7ce70..81699906f 100644 --- a/.github/workflows/release-core.yaml +++ b/.github/workflows/release-core.yaml @@ -10,7 +10,17 @@ jobs: uses: ./.github/workflows/base-release.yaml with: distribution: otelcol - goos: '[ "linux", "windows", "darwin" ]' + goos: '[ "linux", "darwin" ]' goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]' secrets: inherit permissions: write-all + release-windows: + name: Release Core (Windows) + uses: ./.github/workflows/base-release.yaml + with: + distribution: otelcol + goos: '[ "windows" ]' + goarch: '[ "386", "amd64" ]' + runner_os: windows-2022 + secrets: inherit + permissions: write-all diff --git a/.github/workflows/release-k8s.yaml b/.github/workflows/release-k8s.yaml index 20a595f98..b26500e5c 100644 --- a/.github/workflows/release-k8s.yaml +++ b/.github/workflows/release-k8s.yaml @@ -14,3 +14,13 @@ jobs: goarch: '[ "amd64", "arm64", "ppc64le", "s390x" ]' secrets: inherit permissions: write-all + release-windows: + name: Release k8s (Windows) + uses: ./.github/workflows/base-release.yaml + with: + distribution: otelcol-k8s + goos: '[ "windows" ]' + goarch: '[ "386", "amd64" ]' + runner_os: windows-2022 + secrets: inherit + permissions: write-all diff --git a/.github/workflows/release-otlp.yaml b/.github/workflows/release-otlp.yaml index aa96c3689..df0de7300 100644 --- a/.github/workflows/release-otlp.yaml +++ b/.github/workflows/release-otlp.yaml @@ -10,7 +10,17 @@ jobs: uses: ./.github/workflows/base-release.yaml with: distribution: otelcol-otlp - goos: '[ "linux", "windows", "darwin" ]' + goos: '[ "linux", "darwin" ]' goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]' secrets: inherit permissions: write-all + release-windows: + name: Release OTLP (Windows) + uses: ./.github/workflows/base-release.yaml + with: + distribution: otelcol-otlp + goos: '[ "windows" ]' + goarch: '[ "386", "amd64" ]' + runner_os: windows-2022 + secrets: inherit + permissions: write-all diff --git a/cmd/goreleaser/internal/configure.go b/cmd/goreleaser/internal/configure.go index 4b0be8c38..42da497a3 100644 --- a/cmd/goreleaser/internal/configure.go +++ b/cmd/goreleaser/internal/configure.go @@ -22,6 +22,7 @@ package internal import ( "fmt" "path" + "slices" "strings" "github.com/goreleaser/goreleaser-pro/v2/pkg/config" @@ -40,10 +41,11 @@ const ( ) var ( - baseArchs = []string{"386", "amd64", "arm", "arm64", "ppc64le", "s390x"} - winArchs = []string{"386", "amd64", "arm64"} - darwinArchs = []string{"amd64", "arm64"} - k8sArchs = []string{"amd64", "arm64", "ppc64le", "s390x"} + baseArchs = []string{"386", "amd64", "arm", "arm64", "ppc64le", "s390x"} + winArchs = []string{"386", "amd64", "arm64"} + winContainerArchs = []string{"amd64"} + darwinArchs = []string{"amd64", "arm64"} + k8sArchs = []string{"amd64", "arm64", "ppc64le", "s390x"} imageRepos = []string{dockerHub, ghcr} @@ -54,8 +56,14 @@ var ( &fullBuildConfig{targetOS: "darwin", targetArch: darwinArchs}, &fullBuildConfig{targetOS: "windows", targetArch: winArchs}, } - d.containerImages = newContainerImages(d.name, "linux", baseArchs, containerImageOptions{armVersion: "7"}) - d.containerImageManifests = newContainerImageManifests(d.name, "linux", baseArchs) + d.containerImages = slices.Concat( + newContainerImages(d.name, "linux", baseArchs, containerImageOptions{armVersion: "7"}), + newContainerImages(d.name, "windows", winContainerArchs, containerImageOptions{winVersion: "2019"}), + newContainerImages(d.name, "windows", winContainerArchs, containerImageOptions{winVersion: "2022"}), + ) + d.containerImageManifests = slices.Concat( + newContainerImageManifests(d.name, "linux", baseArchs, containerImageOptions{}), + ) }).WithPackagingDefaults().WithDefaultConfigIncluded().Build() // otlp distro @@ -65,8 +73,14 @@ var ( &fullBuildConfig{targetOS: "darwin", targetArch: darwinArchs}, &fullBuildConfig{targetOS: "windows", targetArch: winArchs}, } - d.containerImages = newContainerImages(d.name, "linux", baseArchs, containerImageOptions{armVersion: "7"}) - d.containerImageManifests = newContainerImageManifests(d.name, "linux", baseArchs) + d.containerImages = slices.Concat( + newContainerImages(d.name, "linux", baseArchs, containerImageOptions{armVersion: "7"}), + newContainerImages(d.name, "windows", winContainerArchs, containerImageOptions{winVersion: "2019"}), + newContainerImages(d.name, "windows", winContainerArchs, containerImageOptions{winVersion: "2022"}), + ) + d.containerImageManifests = slices.Concat( + newContainerImageManifests(d.name, "linux", baseArchs, containerImageOptions{}), + ) }).WithPackagingDefaults().Build() // contrib distro @@ -94,8 +108,14 @@ var ( }, }, } - d.containerImages = newContainerImages(d.name, "linux", baseArchs, containerImageOptions{armVersion: "7"}) - d.containerImageManifests = newContainerImageManifests(d.name, "linux", baseArchs) + d.containerImages = slices.Concat( + newContainerImages(d.name, "linux", baseArchs, containerImageOptions{armVersion: "7"}), + newContainerImages(d.name, "windows", winContainerArchs, containerImageOptions{winVersion: "2019"}), + newContainerImages(d.name, "windows", winContainerArchs, containerImageOptions{winVersion: "2022"}), + ) + d.containerImageManifests = slices.Concat( + newContainerImageManifests(d.name, "linux", baseArchs, containerImageOptions{}), + ) }).WithPackagingDefaults().WithDefaultConfigIncluded().Build() // contrib build-only project @@ -111,9 +131,16 @@ var ( k8sDist = newDistributionBuilder(k8sDistro).WithConfigFunc(func(d *distribution) { d.buildConfigs = []buildConfig{ &fullBuildConfig{targetOS: "linux", targetArch: k8sArchs, ppc64Version: []string{"power8"}}, + &fullBuildConfig{targetOS: "windows", targetArch: winContainerArchs}, } - d.containerImages = newContainerImages(d.name, "linux", k8sArchs, containerImageOptions{}) - d.containerImageManifests = newContainerImageManifests(d.name, "linux", k8sArchs) + d.containerImages = slices.Concat( + newContainerImages(d.name, "linux", k8sArchs, containerImageOptions{armVersion: "7"}), + newContainerImages(d.name, "windows", winContainerArchs, containerImageOptions{winVersion: "2019"}), + newContainerImages(d.name, "windows", winContainerArchs, containerImageOptions{winVersion: "2022"}), + ) + d.containerImageManifests = slices.Concat( + newContainerImageManifests(d.name, "linux", k8sArchs, containerImageOptions{}), + ) }).WithDefaultArchives().WithDefaultChecksum().WithDefaultSigns().WithDefaultDockerSigns().WithDefaultSBOMs().Build() ) @@ -368,7 +395,10 @@ func (d *distribution) BuildProject() config.Project { return config.Project{ ProjectName: "opentelemetry-collector-releases", - Checksum: d.checksum, + Release: config.Release{ + ReplaceExistingArtifacts: true, + }, + Checksum: d.checksum, Env: []string{ "COSIGN_YES=true", "LD_FLAGS=-s -w", @@ -392,8 +422,14 @@ func (d *distribution) BuildProject() config.Project { } } -func newContainerImageManifests(dist, os string, archs []string) []config.DockerManifest { +func newContainerImageManifests(dist, os string, archs []string, opts containerImageOptions) []config.DockerManifest { tags := []string{`{{ .Version }}`, "latest"} + if os == "windows" { + for i, tag := range tags { + tags[i] = fmt.Sprintf("%s-%s-%s", tag, os, opts.winVersion) + } + } + var r []config.DockerManifest for _, imageRepo := range imageRepos { for _, tag := range tags { @@ -509,6 +545,16 @@ func dockerImageWithOS(dist, os, arch string, opts containerImageOptions) config if arch == armArch { imageConfig.Goarm = opts.armVersion } + if os == "windows" { + imageConfig.BuildFlagTemplates = slices.Insert( + imageConfig.BuildFlagTemplates, 1, + fmt.Sprintf("--build-arg=WIN_VERSION=%s", opts.winVersion), + ) + imageConfig.Dockerfile = "Windows.dockerfile" + imageConfig.Use = "docker" + imageConfig.SkipBuild = "{{ not (eq .Runtime.Goos \"windows\") }}" + imageConfig.SkipPush = "{{ not (eq .Runtime.Goos \"windows\") }}" + } return imageConfig } @@ -523,6 +569,8 @@ func (o *osArch) buildPlatform() string { case armArch: return fmt.Sprintf("linux/arm/v%s", o.version) } + case "windows": + return fmt.Sprintf("windows/%s", o.arch) } return fmt.Sprintf("linux/%s", o.arch) } @@ -534,6 +582,8 @@ func (o *osArch) imageTag() string { case armArch: return fmt.Sprintf("armv%s", o.version) } + case "windows": + return fmt.Sprintf("windows-%s-%s", o.version, o.arch) } return o.arch } @@ -576,10 +626,14 @@ func osDockerManifest(prefix, version, dist, os string, archs []string) config.D } } - return config.DockerManifest{ + manifest := config.DockerManifest{ NameTemplate: fmt.Sprintf("%s/%s:%s", prefix, imageName(dist), version), ImageTemplates: imageTemplates, } + if os == "windows" { + manifest.SkipPush = "{{ not (eq .Runtime.Goos \"windows\") }}" + } + return manifest } func armVersions(dist string) []string { @@ -593,13 +647,3 @@ func armVersions(dist string) []string { func imageName(dist string) string { return strings.Replace(dist, binaryNamePrefix, imageNamePrefix, 1) } - -// archName translates architecture to docker platform names. -func archName(arch, armVersion string) string { - switch arch { - case armArch: - return fmt.Sprintf("%s/v%s", arch, armVersion) - default: - return arch - } -} diff --git a/distributions/otelcol-contrib/.goreleaser-build.yaml b/distributions/otelcol-contrib/.goreleaser-build.yaml index 2fd481da4..7e1ced8eb 100644 --- a/distributions/otelcol-contrib/.goreleaser-build.yaml +++ b/distributions/otelcol-contrib/.goreleaser-build.yaml @@ -5,6 +5,8 @@ env: - LD_FLAGS=-s -w - CGO_ENABLED=0 - BUILD_FLAGS=-trimpath +release: + replace_existing_artifacts: true builds: - id: otelcol-contrib-linux goos: diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index bd1c23edb..ea0a114a5 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -5,6 +5,8 @@ env: - LD_FLAGS=-s -w - CGO_ENABLED=0 - BUILD_FLAGS=-trimpath +release: + replace_existing_artifacts: true msi: - id: otelcol-contrib name: otelcol-contrib_{{ .Version }}_{{ .Os }}_{{ .MsiArch }} @@ -222,6 +224,52 @@ dockers: - --label=org.opencontainers.image.source={{.GitURL}} - --label=org.opencontainers.image.licenses=Apache-2.0 use: buildx + - goos: windows + goarch: amd64 + dockerfile: Windows.dockerfile + image_templates: + - otel/opentelemetry-collector-contrib:{{ .Version }}-windows-2019-amd64 + - otel/opentelemetry-collector-contrib:latest-windows-2019-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:{{ .Version }}-windows-2019-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest-windows-2019-amd64 + skip_build: '{{ not (eq .Runtime.Goos "windows") }}' + skip_push: '{{ not (eq .Runtime.Goos "windows") }}' + extra_files: + - config.yaml + build_flag_templates: + - --pull + - --build-arg=WIN_VERSION=2019 + - --platform=windows/amd64 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + - --label=org.opencontainers.image.licenses=Apache-2.0 + use: docker + - goos: windows + goarch: amd64 + dockerfile: Windows.dockerfile + image_templates: + - otel/opentelemetry-collector-contrib:{{ .Version }}-windows-2022-amd64 + - otel/opentelemetry-collector-contrib:latest-windows-2022-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:{{ .Version }}-windows-2022-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest-windows-2022-amd64 + skip_build: '{{ not (eq .Runtime.Goos "windows") }}' + skip_push: '{{ not (eq .Runtime.Goos "windows") }}' + extra_files: + - config.yaml + build_flag_templates: + - --pull + - --build-arg=WIN_VERSION=2022 + - --platform=windows/amd64 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + - --label=org.opencontainers.image.licenses=Apache-2.0 + use: docker docker_manifests: - name_template: otel/opentelemetry-collector-contrib:{{ .Version }} image_templates: diff --git a/distributions/otelcol-contrib/Windows.dockerfile b/distributions/otelcol-contrib/Windows.dockerfile new file mode 100644 index 000000000..f6b042725 --- /dev/null +++ b/distributions/otelcol-contrib/Windows.dockerfile @@ -0,0 +1,10 @@ +# escape=` +ARG WIN_VERSION=2019 +FROM mcr.microsoft.com/windows/nanoserver:ltsc${WIN_VERSION} + +COPY otelcol-contrib.exe ./otelcol-contrib.exe +COPY config.yaml ./config.yaml + +ENTRYPOINT ["otelcol-contrib.exe"] +CMD ["--config", "config.yaml"] +EXPOSE 4317 4318 55678 55679 diff --git a/distributions/otelcol-contrib/windows-installer.wxs b/distributions/otelcol-contrib/windows-installer.wxs index 0c7d71353..b3d132e26 100644 --- a/distributions/otelcol-contrib/windows-installer.wxs +++ b/distributions/otelcol-contrib/windows-installer.wxs @@ -43,7 +43,7 @@ diff --git a/distributions/otelcol-k8s/.goreleaser.yaml b/distributions/otelcol-k8s/.goreleaser.yaml index 643d024fe..42d4d2b76 100644 --- a/distributions/otelcol-k8s/.goreleaser.yaml +++ b/distributions/otelcol-k8s/.goreleaser.yaml @@ -5,6 +5,8 @@ env: - LD_FLAGS=-s -w - CGO_ENABLED=0 - BUILD_FLAGS=-trimpath +release: + replace_existing_artifacts: true builds: - id: otelcol-k8s-linux goos: @@ -22,10 +24,22 @@ builds: - '{{ .Env.LD_FLAGS }}' flags: - '{{ .Env.BUILD_FLAGS }}' + - id: otelcol-k8s-windows + goos: + - windows + goarch: + - amd64 + dir: _build + binary: otelcol-k8s + ldflags: + - '{{ .Env.LD_FLAGS }}' + flags: + - '{{ .Env.BUILD_FLAGS }}' archives: - id: otelcol-k8s builds: - otelcol-k8s-linux + - otelcol-k8s-windows name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}' checksum: name_template: '{{ .ProjectName }}_otelcol-k8s_checksums.txt' @@ -102,6 +116,48 @@ dockers: - --label=org.opencontainers.image.source={{.GitURL}} - --label=org.opencontainers.image.licenses=Apache-2.0 use: buildx + - goos: windows + goarch: amd64 + dockerfile: Windows.dockerfile + image_templates: + - otel/opentelemetry-collector-k8s:{{ .Version }}-windows-2019-amd64 + - otel/opentelemetry-collector-k8s:latest-windows-2019-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-windows-2019-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-windows-2019-amd64 + skip_build: '{{ not (eq .Runtime.Goos "windows") }}' + skip_push: '{{ not (eq .Runtime.Goos "windows") }}' + build_flag_templates: + - --pull + - --build-arg=WIN_VERSION=2019 + - --platform=windows/amd64 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + - --label=org.opencontainers.image.licenses=Apache-2.0 + use: docker + - goos: windows + goarch: amd64 + dockerfile: Windows.dockerfile + image_templates: + - otel/opentelemetry-collector-k8s:{{ .Version }}-windows-2022-amd64 + - otel/opentelemetry-collector-k8s:latest-windows-2022-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-windows-2022-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-windows-2022-amd64 + skip_build: '{{ not (eq .Runtime.Goos "windows") }}' + skip_push: '{{ not (eq .Runtime.Goos "windows") }}' + build_flag_templates: + - --pull + - --build-arg=WIN_VERSION=2022 + - --platform=windows/amd64 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + - --label=org.opencontainers.image.licenses=Apache-2.0 + use: docker docker_manifests: - name_template: otel/opentelemetry-collector-k8s:{{ .Version }} image_templates: diff --git a/distributions/otelcol-k8s/Windows.dockerfile b/distributions/otelcol-k8s/Windows.dockerfile new file mode 100644 index 000000000..49a2a6ea8 --- /dev/null +++ b/distributions/otelcol-k8s/Windows.dockerfile @@ -0,0 +1,13 @@ +# escape=` +ARG WIN_VERSION=2019 +FROM mcr.microsoft.com/windows/nanoserver:ltsc${WIN_VERSION} + +COPY otelcol-k8s.exe ./otelcol-k8s.exe + +ENTRYPOINT ["otelcol-k8s.exe"] +# `4137` and `4318`: OTLP +# `55678`: OpenCensus +# `55679`: zpages +# `6831`, `14268`, and `14250`: Jaeger +# `9411`: Zipkin +EXPOSE 4317 4318 55678 55679 6831 14268 14250 9411 diff --git a/distributions/otelcol-otlp/.goreleaser.yaml b/distributions/otelcol-otlp/.goreleaser.yaml index 4b61da350..4b1b9d994 100644 --- a/distributions/otelcol-otlp/.goreleaser.yaml +++ b/distributions/otelcol-otlp/.goreleaser.yaml @@ -5,6 +5,8 @@ env: - LD_FLAGS=-s -w - CGO_ENABLED=0 - BUILD_FLAGS=-trimpath +release: + replace_existing_artifacts: true msi: - id: otelcol-otlp name: otelcol-otlp_{{ .Version }}_{{ .Os }}_{{ .MsiArch }} @@ -201,6 +203,48 @@ dockers: - --label=org.opencontainers.image.source={{.GitURL}} - --label=org.opencontainers.image.licenses=Apache-2.0 use: buildx + - goos: windows + goarch: amd64 + dockerfile: Windows.dockerfile + image_templates: + - otel/opentelemetry-collector-otlp:{{ .Version }}-windows-2019-amd64 + - otel/opentelemetry-collector-otlp:latest-windows-2019-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-otlp:{{ .Version }}-windows-2019-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-otlp:latest-windows-2019-amd64 + skip_build: '{{ not (eq .Runtime.Goos "windows") }}' + skip_push: '{{ not (eq .Runtime.Goos "windows") }}' + build_flag_templates: + - --pull + - --build-arg=WIN_VERSION=2019 + - --platform=windows/amd64 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + - --label=org.opencontainers.image.licenses=Apache-2.0 + use: docker + - goos: windows + goarch: amd64 + dockerfile: Windows.dockerfile + image_templates: + - otel/opentelemetry-collector-otlp:{{ .Version }}-windows-2022-amd64 + - otel/opentelemetry-collector-otlp:latest-windows-2022-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-otlp:{{ .Version }}-windows-2022-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-otlp:latest-windows-2022-amd64 + skip_build: '{{ not (eq .Runtime.Goos "windows") }}' + skip_push: '{{ not (eq .Runtime.Goos "windows") }}' + build_flag_templates: + - --pull + - --build-arg=WIN_VERSION=2022 + - --platform=windows/amd64 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + - --label=org.opencontainers.image.licenses=Apache-2.0 + use: docker docker_manifests: - name_template: otel/opentelemetry-collector-otlp:{{ .Version }} image_templates: diff --git a/distributions/otelcol-otlp/Windows.dockerfile b/distributions/otelcol-otlp/Windows.dockerfile new file mode 100644 index 000000000..fe17faf64 --- /dev/null +++ b/distributions/otelcol-otlp/Windows.dockerfile @@ -0,0 +1,8 @@ +# escape=` +ARG WIN_VERSION=2019 +FROM mcr.microsoft.com/windows/nanoserver:ltsc${WIN_VERSION} + +COPY otelcol-otlp.exe ./otelcol-otlp.exe + +ENTRYPOINT ["otelcol-otlp.exe"] +EXPOSE 4317 4318 diff --git a/distributions/otelcol-otlp/windows-installer.wxs b/distributions/otelcol-otlp/windows-installer.wxs index 81be711ef..628834b5f 100644 --- a/distributions/otelcol-otlp/windows-installer.wxs +++ b/distributions/otelcol-otlp/windows-installer.wxs @@ -43,7 +43,7 @@ diff --git a/distributions/otelcol/.goreleaser.yaml b/distributions/otelcol/.goreleaser.yaml index 670cfa0ab..2167ea897 100644 --- a/distributions/otelcol/.goreleaser.yaml +++ b/distributions/otelcol/.goreleaser.yaml @@ -5,6 +5,8 @@ env: - LD_FLAGS=-s -w - CGO_ENABLED=0 - BUILD_FLAGS=-trimpath +release: + replace_existing_artifacts: true msi: - id: otelcol name: otelcol_{{ .Version }}_{{ .Os }}_{{ .MsiArch }} @@ -217,6 +219,52 @@ dockers: - --label=org.opencontainers.image.source={{.GitURL}} - --label=org.opencontainers.image.licenses=Apache-2.0 use: buildx + - goos: windows + goarch: amd64 + dockerfile: Windows.dockerfile + image_templates: + - otel/opentelemetry-collector:{{ .Version }}-windows-2019-amd64 + - otel/opentelemetry-collector:latest-windows-2019-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:{{ .Version }}-windows-2019-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:latest-windows-2019-amd64 + skip_build: '{{ not (eq .Runtime.Goos "windows") }}' + skip_push: '{{ not (eq .Runtime.Goos "windows") }}' + extra_files: + - config.yaml + build_flag_templates: + - --pull + - --build-arg=WIN_VERSION=2019 + - --platform=windows/amd64 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + - --label=org.opencontainers.image.licenses=Apache-2.0 + use: docker + - goos: windows + goarch: amd64 + dockerfile: Windows.dockerfile + image_templates: + - otel/opentelemetry-collector:{{ .Version }}-windows-2022-amd64 + - otel/opentelemetry-collector:latest-windows-2022-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:{{ .Version }}-windows-2022-amd64 + - ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:latest-windows-2022-amd64 + skip_build: '{{ not (eq .Runtime.Goos "windows") }}' + skip_push: '{{ not (eq .Runtime.Goos "windows") }}' + extra_files: + - config.yaml + build_flag_templates: + - --pull + - --build-arg=WIN_VERSION=2022 + - --platform=windows/amd64 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + - --label=org.opencontainers.image.licenses=Apache-2.0 + use: docker docker_manifests: - name_template: otel/opentelemetry-collector:{{ .Version }} image_templates: diff --git a/distributions/otelcol/Windows.dockerfile b/distributions/otelcol/Windows.dockerfile new file mode 100644 index 000000000..07d094710 --- /dev/null +++ b/distributions/otelcol/Windows.dockerfile @@ -0,0 +1,10 @@ +# escape=` +ARG WIN_VERSION=2019 +FROM mcr.microsoft.com/windows/nanoserver:ltsc${WIN_VERSION} + +COPY otelcol.exe ./otelcol.exe +COPY config.yaml ./config.yaml + +ENTRYPOINT ["otelcol.exe"] +CMD ["--config", "config.yaml"] +EXPOSE 4317 4318 55678 55679 diff --git a/distributions/otelcol/windows-installer.wxs b/distributions/otelcol/windows-installer.wxs index 0c7d71353..b3d132e26 100644 --- a/distributions/otelcol/windows-installer.wxs +++ b/distributions/otelcol/windows-installer.wxs @@ -43,7 +43,7 @@