Skip to content

Commit

Permalink
chore: add release image action
Browse files Browse the repository at this point in the history
  • Loading branch information
fengluodb committed Aug 4, 2023
1 parent ca39ba4 commit 8b449f1
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/release-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: RELEASE-IMAGE

on:
workflow_dispatch:
inputs:
image_tag:
description: 'The tag name of image'
required: true
default: ''
release:
types:
- published

env:
RELEASE_VERSION: ${{ github.ref_name }}


jobs:
image-tag:
runs-on: ubuntu-latest
outputs:
tag-name: ${{ steps.get_tag_name.outputs.tag_name }}
steps:
- name: Get Tag Name
id: get_tag_name
run: |
TAG_NAME=${{ inputs.image_tag }}
if [ -z "$TAG_NAME" ]; then
TAG_NAME=${{ env.RELEASE_VERSION }}
fi
echo tag_name=$TAG_NAME >> $GITHUB_OUTPUT
release-image:
needs: image-tag
uses: apecloud/apecloud-cd/.github/workflows/[email protected]
with:
MAKE_OPS: "docker-buildx"
IMG: "apecloud/go-ycsb"
VERSION: "${{ needs.image-tag.outputs.tag-name }}"
GO_VERSION: "1.20"
SYNC_ENABLE: false
APECD_REF: "v0.1.11"
secrets: inherit
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Image URL to use all building/pushing image targets
IMG ?= go-ycsb
VERSION ?= latest

FDB_CHECK := $(shell command -v fdbcli 2> /dev/null)
ROCKSDB_CHECK := $(shell echo "int main() { return 0; }" | gcc -lrocksdb -x c++ -o /dev/null - 2>/dev/null; echo $$?)
SQLITE_CHECK := $(shell echo "int main() { return 0; }" | gcc -lsqlite3 -x c++ -o /dev/null - 2>/dev/null; echo $$?)

TAGS =

# CONTAINER_TOOL defines the container tool to be used for building images.
# Be aware that the target commands are only tested with Docker which is
# scaffolded by default. However, you might want to replace it to use other
# tools. (i.e. podman)
CONTAINER_TOOL ?= docker

ifdef FDB_CHECK
TAGS += foundationdb
endif
Expand Down Expand Up @@ -42,3 +52,30 @@ endif
check:
golint -set_exit_status db/... cmd/... pkg/...

# If you wish built the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${IMG}

# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# To properly provided solutions that supports more than one platform you should use this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG}:${VERSION} -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.cross

0 comments on commit 8b449f1

Please sign in to comment.