Skip to content

Commit

Permalink
ci: build and push release version images also with latest
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Braun <[email protected]>
  • Loading branch information
bluebrown committed Jul 26, 2023
1 parent b310a22 commit 519d229
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ artifacts: bin/kustomize build ## Create all release artifacts and put the in .d
###@ Publish

.PHONY: version-next
version-next: # internal command to set VERSION to the next semver
version-next: # internal command to set VERSION to the next semver and IS_LATEST accordingly
$(if $(filter $(PRE_RELEASE), 0), $(eval IS_LATEST = 1))
$(eval VERSION = $(shell docker run --rm -u "$$(id -u):$$(id -g)" \
-v $(CURDIR):/tmp -w /tmp convco/convco version --bump \
$(if $(filter $(PRE_RELEASE), 1),--prerelease rc)))

.PHONY: image-publish
image-publish: ## Build and push the images to CONTAINER_REGISTRY
$(MAKE) image-build BUILDX_FLAGS='--set *.attest=type=sbom --set=*.output=type=registry'
IS_LATEST=$(IS_LATEST) $(MAKE) image-build BUILDX_FLAGS='--set *.attest=type=sbom --set=*.output=type=registry'

.PHONY: github-pages
github-pages: bin/mdbook ## Build and publish the docs to github pages
Expand Down
14 changes: 9 additions & 5 deletions build/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
variable "CONTAINER_REGISTRY" { default = "docker.io" }
variable "VERSION" { default = "dev" }
variable "IS_LATEST" { default = "0" }

group "default" { targets = ["gitgo", "gitexec"] }

target "gitgo" {
labels = {
"org.opencontainers.image.author" = "Nico Braun"
"org.opencontainers.image.source" = "https://github.com/bluebrown/kobold"
"org.opencontainers.image.created" = timestamp()
}
dockerfile = "build/Dockerfile"
args = { CGO_ENABLED = "1", BUILD_TAG = "gitgo", VERSION = VERSION}
tags = ["${CONTAINER_REGISTRY}/bluebrown/kobold:${VERSION}"]
# attest = ["type=provenance,mode=min", "type=sbom"]
tags = compact([
"${CONTAINER_REGISTRY}/bluebrown/kobold:${VERSION}",
equal(IS_LATEST, "1") ? "${CONTAINER_REGISTRY}/bluebrown/kobold:latest" : null
])
}

target "gitexec" {
inherits = ["gitgo"]
args = { BASE_IMAGE = "docker.io/alpine/git:v2.36.3", CGO_ENABLED = "0", BUILD_TAG = "gitexec", VERSION = VERSION}
tags = ["${CONTAINER_REGISTRY}/bluebrown/kobold:${VERSION}-gitexec"]
# output = ["type=tar,dest=.dist/container-image-kobold-gitexec.tar"]
tags = compact([
"${CONTAINER_REGISTRY}/bluebrown/kobold:${VERSION}-gitexec",
equal(IS_LATEST, "1") ? "${CONTAINER_REGISTRY}/bluebrown/kobold:latest-gitexec" : null
])
}

0 comments on commit 519d229

Please sign in to comment.