diff --git a/Changelog.md b/Changelog.md index 7c7d6427..6b08d993 100644 --- a/Changelog.md +++ b/Changelog.md @@ -15,13 +15,13 @@ This changelog keeps track of work items that have been completed and are ready ### Breaking Changes -- TODO +- **General**: TODO ([#TODO](https://github.com/kedacore/http-add-on/issues/TODO)) ### New ### Improvements -- **General**: TODO ([#TODO](https://github.com/kedacore/http-add-on/issues/TODO)) +- **General**: Automatically tag Docker image with commit SHA ([#567](https://github.com/kedacore/http-add-on/issues/567)) ### Fixes diff --git a/Makefile b/Makefile index d0887179..df312a6e 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,17 @@ IMAGE_REGISTRY ?= ghcr.io IMAGE_REPO ?= kedacore VERSION ?= main -IMAGE_OPERATOR ?= ${IMAGE_REGISTRY}/${IMAGE_REPO}/http-add-on-operator:$(VERSION) -IMAGE_INTERCEPTOR ?= ${IMAGE_REGISTRY}/${IMAGE_REPO}/http-add-on-interceptor:$(VERSION) -IMAGE_SCALER ?= ${IMAGE_REGISTRY}/${IMAGE_REPO}/http-add-on-scaler:$(VERSION) +IMAGE_OPERATOR ?= ${IMAGE_REGISTRY}/${IMAGE_REPO}/http-add-on-operator +IMAGE_INTERCEPTOR ?= ${IMAGE_REGISTRY}/${IMAGE_REPO}/http-add-on-interceptor +IMAGE_SCALER ?= ${IMAGE_REGISTRY}/${IMAGE_REPO}/http-add-on-scaler + +IMAGE_OPERATOR_VERSIONED_TAG ?= ${IMAGE_OPERATOR}:$(VERSION) +IMAGE_INTERCEPTOR_VERSIONED_TAG ?= ${IMAGE_INTERCEPTOR}:$(VERSION) +IMAGE_SCALER_VERSIONED_TAG ?= ${IMAGE_SCALER}:$(VERSION) + +IMAGE_OPERATOR_SHA_TAG ?= ${IMAGE_OPERATOR}:$(GIT_COMMIT_SHORT) +IMAGE_INTERCEPTOR_SHA_TAG ?= ${IMAGE_INTERCEPTOR}:$(GIT_COMMIT_SHORT) +IMAGE_SCALER_SHA_TAG ?= ${IMAGE_SCALER}:$(GIT_COMMIT_SHORT) ARCH ?=amd64 CGO ?=0 @@ -22,6 +30,7 @@ GO_BUILD_VARS= GO111MODULE=on CGO_ENABLED=$(CGO) GOOS=$(TARGET_OS) GOARCH=$(ARCH GO_LDFLAGS="-X github.com/kedacore/http-add-on/pkg/build.version=${VERSION} -X github.com/kedacore/http-add-on/pkg/build.gitCommit=${GIT_COMMIT}" GIT_COMMIT ?= $(shell git rev-list -1 HEAD) +GIT_COMMIT_SHORT ?= $(shell git rev-parse --short HEAD) # Build targets @@ -45,29 +54,32 @@ e2e-test: # Docker targets docker-build-operator: - DOCKER_BUILDKIT=1 docker build . -t ${IMAGE_OPERATOR} -f operator/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} + DOCKER_BUILDKIT=1 docker build . -t ${IMAGE_OPERATOR_VERSIONED_TAG} -t ${IMAGE_OPERATOR_SHA_TAG} -f operator/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} docker-build-interceptor: - DOCKER_BUILDKIT=1 docker build . -t ${IMAGE_INTERCEPTOR} -f interceptor/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} + DOCKER_BUILDKIT=1 docker build . -t ${IMAGE_INTERCEPTOR_VERSIONED_TAG} -t ${IMAGE_INTERCEPTOR_SHA_TAG} -f interceptor/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} docker-build-scaler: - DOCKER_BUILDKIT=1 docker build . -t ${IMAGE_SCALER} -f scaler/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} + DOCKER_BUILDKIT=1 docker build . -t ${IMAGE_SCALER_VERSIONED_TAG} -t ${IMAGE_SCALER_SHA_TAG} -f scaler/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} docker-build: docker-build-operator docker-build-interceptor docker-build-scaler docker-publish: docker-build ## Push images on to Container Registry (default: ghcr.io). - docker push $(IMAGE_OPERATOR) - docker push $(IMAGE_INTERCEPTOR) - docker push $(IMAGE_SCALER) + docker push $(IMAGE_OPERATOR_VERSIONED_TAG) + docker push $(IMAGE_OPERATOR_SHA_TAG) + docker push $(IMAGE_INTERCEPTOR_VERSIONED_TAG) + docker push $(IMAGE_INTERCEPTOR_SHA_TAG) + docker push $(IMAGE_SCALER_VERSIONED_TAG) + docker push $(IMAGE_SCALER_SHA_TAG) publish-operator-multiarch: - docker buildx build --output=type=${OUTPUT_TYPE} --platform=${BUILD_PLATFORMS} . -t ${IMAGE_OPERATOR} -f operator/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} + docker buildx build --output=type=${OUTPUT_TYPE} --platform=${BUILD_PLATFORMS} . -t ${IMAGE_OPERATOR_VERSIONED_TAG} -t ${IMAGE_OPERATOR_SHA_TAG} -f operator/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} publish-interceptor-multiarch: - docker buildx build --output=type=${OUTPUT_TYPE} --platform=${BUILD_PLATFORMS} . -t ${IMAGE_INTERCEPTOR} -f interceptor/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} + docker buildx build --output=type=${OUTPUT_TYPE} --platform=${BUILD_PLATFORMS} . -t ${IMAGE_INTERCEPTOR_VERSIONED_TAG} -t ${IMAGE_INTERCEPTOR_SHA_TAG} -f interceptor/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} publish-scaler-multiarch: - docker buildx build --output=type=${OUTPUT_TYPE} --platform=${BUILD_PLATFORMS} . -t ${IMAGE_SCALER} -f scaler/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} + docker buildx build --output=type=${OUTPUT_TYPE} --platform=${BUILD_PLATFORMS} . -t ${IMAGE_SCALER_VERSIONED_TAG} -t ${IMAGE_SCALER_SHA_TAG} -f scaler/Dockerfile --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} publish-multiarch: publish-operator-multiarch publish-interceptor-multiarch publish-scaler-multiarch @@ -105,13 +117,13 @@ protoc-gen-go: ## Download protoc-gen-go deploy: manifests kustomize ## Deploy to the K8s cluster specified in ~/.kube/config. cd config/interceptor && \ - $(KUSTOMIZE) edit set image ghcr.io/kedacore/http-add-on-interceptor=${IMAGE_INTERCEPTOR} + $(KUSTOMIZE) edit set image ghcr.io/kedacore/http-add-on-interceptor=${IMAGE_INTERCEPTOR_VERSIONED_TAG} cd config/scaler && \ - $(KUSTOMIZE) edit set image ghcr.io/kedacore/http-add-on-scaler=${IMAGE_SCALER} + $(KUSTOMIZE) edit set image ghcr.io/kedacore/http-add-on-scaler=${IMAGE_SCALER_VERSIONED_TAG} cd config/operator && \ - $(KUSTOMIZE) edit set image ghcr.io/kedacore/http-add-on-operator=${IMAGE_OPERATOR} + $(KUSTOMIZE) edit set image ghcr.io/kedacore/http-add-on-operator=${IMAGE_OPERATOR_VERSIONED_TAG} @sed -i".out" -e 's@version:[ ].*@version: $(VERSION)@g' config/default/kustomize-config/metadataLabelTransformer.yaml rm -rf config/default/kustomize-config/metadataLabelTransformer.yaml.out diff --git a/RELEASE-PROCESS.md b/RELEASE-PROCESS.md index c1cf46d7..0f1b36bd 100644 --- a/RELEASE-PROCESS.md +++ b/RELEASE-PROCESS.md @@ -58,7 +58,7 @@ After your PR is merged, you've completed the release. Congratulations! You can ## 4: Publish release on Artifact Hub -Publish release on Artifact Hub by creating a new version in [kedacore/external-scalers](https://github.com/kedacore/external-scalers/tree/http/artifacthub/add-ons-http). +Publish release on Artifact Hub by creating a new version in [kedacore/external-scalers](https://github.com/kedacore/external-scalers/tree/main/artifacthub/add-ons-http). ## 5: Write a blog post on the documentation site (_optional_)