Build OS and EE image #983
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build OS and EE image | |
on: | |
push: | |
branches: | |
- "!*" | |
tags: | |
- "v5.*" | |
workflow_dispatch: | |
inputs: | |
HZ_VERSION: | |
description: 'Version of Hazelcast to build the image for, e.g. 5.1.1, 5.0.1, 4.2.3' | |
required: true | |
RELEASE_VERSION: | |
description: 'Version of the docker image e.g. 5.1.1, 5.1.1-1, defaults to HZ_VERSION' | |
required: false | |
RELEASE_TYPE: | |
description: 'Editions to build' | |
required: true | |
default: 'ALL' | |
type: choice | |
options: | |
- ALL | |
- OSS | |
- EE | |
env: | |
test_container_name_oss: hazelcast-oss-test | |
test_container_name_ee: hazelcast-ee-test | |
jobs: | |
push: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- variant: slim | |
suffix: '-slim' | |
- variant: '' | |
suffix: '' | |
env: | |
DOCKER_ORG: hazelcast | |
HZ_VERSION: ${{ github.event.inputs.HZ_VERSION }} | |
RELEASE_VERSION: ${{ github.event.inputs.RELEASE_VERSION }} | |
RELEASE_TYPE: ${{ github.event.inputs.RELEASE_TYPE || 'ALL' }} | |
steps: | |
- name: Set HZ version as environment variable | |
run: | | |
if [ -z "${{ env.HZ_VERSION }}" ]; then | |
HZ_VERSION=${GITHUB_REF:11} | |
else | |
HZ_VERSION=${{ env.HZ_VERSION }} | |
fi | |
echo "HZ_VERSION=${HZ_VERSION}" >> $GITHUB_ENV | |
echo "DOCKER_LOG_FILE_OSS=docker-hazelcast-oss-test${{ matrix.suffix }}.log" >> $GITHUB_ENV | |
echo "DOCKER_LOG_FILE_EE=docker-hazelcast-ee-test${{ matrix.suffix }}.log" >> $GITHUB_ENV | |
- name: Set Release version as environment variable | |
run: | | |
if [ -z "${{ env.RELEASE_VERSION }}" ]; then | |
RELEASE_VERSION=${{ env.HZ_VERSION }} | |
else | |
RELEASE_VERSION=${{ env.RELEASE_VERSION }} | |
fi | |
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Check if latest tag should be pushed | |
run: | | |
FILTERED_TAGS=$(git tag --list "v*" | grep -E -v '*BETA*' ) | |
LATEST_TAG=$((IFS=$'\n' && echo "${FILTERED_TAGS[*]}") | sort | tail -n 1) | |
echo "PUSH_LATEST=$([[ "$LATEST_TAG" = "${GITHUB_REF:10}" ]] && echo yes || echo no)" >> $GITHUB_ENV | |
- name: Print Push Latest | |
run: | | |
echo ${{ env.PUSH_LATEST }} | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
with: | |
version: v0.5.1 | |
- name: Login to Docker Hub | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Build Test OSS image | |
if: env.RELEASE_TYPE == 'ALL' || env.RELEASE_TYPE == 'OSS' | |
run: | | |
docker buildx build --load \ | |
--build-arg HZ_VERSION=${{ env.HZ_VERSION }} \ | |
--build-arg HZ_VARIANT=${{ matrix.variant }} \ | |
--tag hazelcast-oss:test \ | |
hazelcast-oss | |
- name: Run smoke test against OSS image | |
if: env.RELEASE_TYPE == 'ALL' || env.RELEASE_TYPE == 'OSS' | |
timeout-minutes: 2 | |
run: | | |
.github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} | |
- name: Build Test EE image | |
if: env.RELEASE_TYPE == 'ALL' || env.RELEASE_TYPE == 'EE' | |
run: | | |
docker buildx build --load \ | |
--build-arg HZ_VERSION=${{ env.HZ_VERSION }} \ | |
--build-arg HZ_VARIANT=${{ matrix.variant }} \ | |
--tag hazelcast-ee:test \ | |
hazelcast-enterprise | |
- name: Run smoke test against EE image | |
if: env.RELEASE_TYPE == 'ALL' || env.RELEASE_TYPE == 'EE' | |
timeout-minutes: 2 | |
run: | | |
export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }} | |
.github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} | |
- name: Get docker logs | |
if: ${{ always() }} | |
run: | | |
docker logs ${{ env.test_container_name_oss }} > ${{ env.DOCKER_LOG_FILE_OSS }} || true | |
docker logs ${{ env.test_container_name_ee }} > ${{ env.DOCKER_LOG_FILE_EE }} || true | |
- name: Store docker logs as artifact | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docker-logs | |
path: | | |
${{ env.DOCKER_LOG_FILE_OSS }} | |
${{ env.DOCKER_LOG_FILE_EE }} | |
- name: Build and Push OSS image | |
if: env.RELEASE_TYPE == 'ALL' || env.RELEASE_TYPE == 'OSS' | |
run: | | |
. .github/scripts/get-tags-to-push.sh | |
TAGS_TO_PUSH=$(get_tags_to_push ${{ env.RELEASE_VERSION }}) | |
echo "TAGS_TO_PUSH=$TAGS_TO_PUSH" | |
TAGS_ARG="" | |
for tag in ${TAGS_TO_PUSH[@]} | |
do | |
TAGS_ARG="${TAGS_ARG} --tag ${{ env.DOCKER_ORG }}/hazelcast:${tag}${{ matrix.suffix }}" | |
done | |
docker buildx build --push \ | |
--build-arg HZ_VERSION=${{ env.HZ_VERSION }} \ | |
--build-arg HZ_VARIANT=${{ matrix.variant }} \ | |
${TAGS_ARG} \ | |
--platform=linux/arm64,linux/amd64,linux/ppc64le hazelcast-oss | |
- name: Build/Push EE image | |
if: env.RELEASE_TYPE == 'ALL' || env.RELEASE_TYPE == 'EE' | |
run: | | |
. .github/scripts/get-tags-to-push.sh | |
TAGS_TO_PUSH=$(get_tags_to_push ${{ env.RELEASE_VERSION }}) | |
echo "TAGS_TO_PUSH=$TAGS_TO_PUSH" | |
TAGS_ARG="" | |
for tag in ${TAGS_TO_PUSH[@]} | |
do | |
TAGS_ARG="${TAGS_ARG} --tag ${{ env.DOCKER_ORG }}/hazelcast-enterprise:${tag}${{ matrix.suffix }}" | |
done | |
docker buildx build --push \ | |
--build-arg HZ_VERSION=${{ env.HZ_VERSION }} \ | |
--build-arg HZ_VARIANT=${{ matrix.variant }} \ | |
${TAGS_ARG} \ | |
--platform=linux/arm64,linux/amd64,linux/ppc64le,linux/s390x hazelcast-enterprise | |
post-push: | |
runs-on: ubuntu-latest | |
needs: push | |
env: | |
RELEASE_TYPE: ${{ github.event.inputs.RELEASE_TYPE || 'ALL' }} | |
steps: | |
- name: Update Docker Hub Description of OSS image | |
if: env.PUSH_LATEST == 'yes' && (env.RELEASE_TYPE == 'ALL' || env.RELEASE_TYPE == 'OSS' ) | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
repository: hazelcast/hazelcast | |
short-description: Hazelcast Docker Image | |
readme-filepath: ./README.md | |
- name: Update Docker Hub Description of EE image | |
if: env.PUSH_LATEST == 'yes' && (env.RELEASE_TYPE == 'ALL' || env.RELEASE_TYPE == 'EE' ) | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
repository: hazelcast/hazelcast-enterprise | |
short-description: Hazelcast Enterprise Docker Image | |
readme-filepath: ./README.md | |
- name: Create release | |
if: github.event_name == 'push' | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
allowUpdates: true |