99
1010env :
1111 PLATFORMS : linux/amd64,linux/arm64,linux/s390x,linux/ppc64le
12+ GHCR_IMAGE : ghcr.io/${{ github.repository_owner }}/opentelemetry-operator/opentelemetry-operator
13+ DOCKERHUB_IMAGE : otel/opentelemetry-operator
1214
1315permissions :
1416 contents : read
2123 id-token : write
2224 name : Publish container images
2325 runs-on : ubuntu-latest
26+ outputs :
27+ digest : ${{ steps.build.outputs.digest }}
28+ image : ${{ steps.release-image.outputs.image }}
2429 steps :
2530 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2631
3237 run : git fetch --prune --unshallow
3338
3439 - name : Describe the current state
35- run : git describe --tags
40+ run : |
41+ # make sure that tags are available, but don't fail the workflow if none exist.
42+ git fetch --tags || true
43+ git describe --tags || echo "no-tag-$(git rev-parse --short HEAD)"
3644
3745 - name : Set env vars for the job
3846 run : |
4755 grep -v '\#' versions.txt | grep autoinstrumentation-apache-httpd | awk -F= '{print "AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION="$2}' >> $GITHUB_ENV
4856 grep -v '\#' versions.txt | grep autoinstrumentation-nginx | awk -F= '{print "AUTO_INSTRUMENTATION_NGINX_VERSION="$2}' >> $GITHUB_ENV
4957 echo "VERSION_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
50- echo "VERSION=$(git describe --tags | sed 's/^v//')" >> $GITHUB_ENV
58+ VERSION="$(git describe --tags 2>/dev/null || echo "no-tag-$(git rev-parse --short HEAD)")"
59+ echo "VERSION=${VERSION#v}" >> $GITHUB_ENV
5160
5261 - name : Build the binary for each supported architecture
5362 run : |
@@ -62,14 +71,18 @@ jobs:
6271 uses : docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
6372 with :
6473 images : |
65- otel/opentelemetry-operator
66- ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
74+ ${{ env.GHCR_IMAGE }}
75+ ${{ env.DOCKERHUB_IMAGE }}
6776 tags : |
6877 type=semver,pattern={{version}}
6978 type=semver,pattern={{major}}.{{minor}}
7079 type=semver,pattern={{raw}}
7180 type=ref,event=branch
7281
82+ - name : Resolve release image name
83+ id : release-image
84+ run : echo "image=${GHCR_IMAGE}" >> "$GITHUB_OUTPUT"
85+
7386 - name : Set up QEMU
7487 uses : docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
7588
@@ -100,6 +113,7 @@ jobs:
100113 password : ${{ secrets.GITHUB_TOKEN }}
101114
102115 - name : Build and push Operator image
116+ id : build
103117 uses : docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
104118 with :
105119 context : .
@@ -110,3 +124,11 @@ jobs:
110124 labels : ${{ steps.docker_meta.outputs.labels }}
111125 cache-from : type=local,src=/tmp/.buildx-cache
112126 cache-to : type=local,dest=/tmp/.buildx-cache
127+
128+ - name : Sign release images
129+ if : ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
130+ env :
131+ DIGEST : ${{ steps.build.outputs.digest }}
132+ run : |
133+ make cosign-sign IMAGE="${GHCR_IMAGE}" DIGEST="${DIGEST}"
134+ make cosign-sign IMAGE="${DOCKERHUB_IMAGE}" DIGEST="${DIGEST}"
0 commit comments