diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml index 82a66b4e..27294592 100644 --- a/.github/workflows/dev_builds.yml +++ b/.github/workflows/dev_builds.yml @@ -6,6 +6,10 @@ on: - main - 'release-v[0-9]+.[0-9]+' +permissions: + packages: write + contents: read + env: SIDECAR_IMAGE: "ghcr.io/sumologic/tailing-sidecar" OPERATOR_IMAGE: "ghcr.io/sumologic/tailing-sidecar-operator" @@ -15,7 +19,7 @@ env: LATEST_TAG: "main" jobs: - build-sidecar: + build-fluentbit-sidecar: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 @@ -54,6 +58,36 @@ jobs: run: make build-push-multiplatform TAG=${{ env.SIDECAR_IMAGE_ECR }}:${{ env.LATEST_TAG }} working-directory: ./sidecar/fluentbit + build-otelcol-sidecar: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - name: Setup go + uses: actions/setup-go@v5 + with: + go-version: '1.21' + cache-dependency-path: | + sidecar/otelcol/.otelcol-builder.yaml + sidecar/otelcol/.goreleaser.yaml + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.0.0 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.0.0 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: USERNAME + password: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to AWS Public ECR + run: make login-ecr + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_TAILING_SIDECAR_DEV }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_TAILING_SIDECAR_DEV }} + - name: Build and push otelcol sidecar image + run: make release-dev + working-directory: ./sidecar/otelcol + build-operator: runs-on: ubuntu-20.04 steps: diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index a542edc0..03320e0e 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -58,8 +58,8 @@ jobs: with: go-version: '1.21' cache-dependency-path: | - .otelcol-builder.yaml - .goreleaser.yaml + sidecar/otelcol/.otelcol-builder.yaml + sidecar/otelcol/.goreleaser.yaml - name: Set up QEMU uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx diff --git a/sidecar/otelcol/.goreleaser.yaml b/sidecar/otelcol/.goreleaser.yaml index 0453484d..2d39078a 100644 --- a/sidecar/otelcol/.goreleaser.yaml +++ b/sidecar/otelcol/.goreleaser.yaml @@ -10,6 +10,10 @@ version: 1 project_name: otelcol-sidecar +env: + - GHCR_IMAGE={{ if index .Env "GHCR_IMAGE" }}{{ .Env.GHCR_IMAGE }}{{ else }}ghcr.io/sumologic/tailing-sidecar-otel{{ end }} + - ECR_IMAGE={{ if index .Env "ECR_IMAGE" }}{{ .Env.ECR_IMAGE }}{{ else }}public.ecr.aws/sumologic/tailing-sidecar-otel{{ end }} + before: hooks: - make generate-sources VERSION={{ .Version }} @@ -30,8 +34,10 @@ archives: dockers: - image_templates: - - "ghcr.io/sumologic/tailing-sidecar-otel:{{ .Version }}-amd64" - - "ghcr.io/sumologic/tailing-sidecar-otel:latest-amd64" + - "{{ .Env.ECR_IMAGE }}:{{ .Version }}-amd64" + - "{{ .Env.ECR_IMAGE }}:main-amd64" + - "{{ .Env.GHCR_IMAGE }}:{{ .Version }}-amd64" + - "{{ .Env.GHCR_IMAGE }}:main-amd64" use: buildx goarch: amd64 build_flag_templates: @@ -39,8 +45,10 @@ dockers: extra_files: - "config.yaml" - image_templates: - - "ghcr.io/sumologic/tailing-sidecar-otel:{{ .Version }}-arm64" - - "ghcr.io/sumologic/tailing-sidecar-otel:latest-arm64" + - "{{ .Env.ECR_IMAGE }}:{{ .Version }}-arm64" + - "{{ .Env.ECR_IMAGE }}:main-arm64" + - "{{ .Env.GHCR_IMAGE }}:{{ .Version }}-arm64" + - "{{ .Env.GHCR_IMAGE }}:main-arm64" use: buildx goarch: arm64 build_flag_templates: @@ -49,14 +57,22 @@ dockers: - "config.yaml" docker_manifests: - - name_template: "ghcr.io/sumologic/tailing-sidecar-otel:{{ .Version }}" + - name_template: "{{ .Env.GHCR_IMAGE }}:{{ .Version }}" + image_templates: + - "{{ .Env.GHCR_IMAGE }}:{{ .Version }}-amd64" + - "{{ .Env.GHCR_IMAGE }}:{{ .Version }}-arm64" + - name_template: "{{ .Env.GHCR_IMAGE }}:main" + image_templates: + - "{{ .Env.GHCR_IMAGE }}:main-amd64" + - "{{ .Env.GHCR_IMAGE }}:main-arm64" + - name_template: "{{ .Env.ECR_IMAGE }}:{{ .Version }}" image_templates: - - "ghcr.io/sumologic/tailing-sidecar-otel:{{ .Version }}-amd64" - - "ghcr.io/sumologic/tailing-sidecar-otel:{{ .Version }}-arm64" - - name_template: "ghcr.io/sumologic/tailing-sidecar-otel:latest" + - "{{ .Env.ECR_IMAGE }}:{{ .Version }}-amd64" + - "{{ .Env.ECR_IMAGE }}:{{ .Version }}-arm64" + - name_template: "{{ .Env.ECR_IMAGE }}:main" image_templates: - - "ghcr.io/sumologic/tailing-sidecar-otel:latest-amd64" - - "ghcr.io/sumologic/tailing-sidecar-otel:latest-arm64" + - "{{ .Env.ECR_IMAGE }}:main-amd64" + - "{{ .Env.ECR_IMAGE }}:main-arm64" # we only want to build and publish docker images release: diff --git a/sidecar/otelcol/Makefile b/sidecar/otelcol/Makefile index 34448b3b..d82104f6 100644 --- a/sidecar/otelcol/Makefile +++ b/sidecar/otelcol/Makefile @@ -57,6 +57,20 @@ endif build: ensure-correct-builder-version install-goreleaser @$(GORELEASER) release --snapshot --clean +.PHONY: release-dev +release-dev: TAG = $(shell git describe --tags --always) +release-dev: ensure-correct-builder-version install-goreleaser + git tag "$(TAG)" + GORELEASER_CURRENT_TAG=$(TAG) \ + ECR_IMAGE=public.ecr.aws/sumologic/tailing-sidecar-dev \ + GHCR_IMAGE=ghcr.io/sumologic/tailing-sidecar \ + make release + git tag -d "$(TAG)" + +.PHONY: release +release: ensure-correct-builder-version install-goreleaser + @$(GORELEASER) release --clean + .PHONY: generate-sources generate-sources: $(BUILDER) \