Build OS and EE image #980
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: 'Which editions should be built' | |
required: true | |
default: 'EE' | |
type: choice | |
options: | |
- ALL | |
- OSS | |
- EE | |
env: | |
test_container_name_oss: hazelcast-oss-test | |
test_container_name_ee: hazelcast-ee-test | |
jobs: | |
jdks: | |
uses: ./.github/workflows/get-supported-jdks.yaml | |
prepare: | |
runs-on: ubuntu-latest | |
env: | |
RELEASE_TYPE: ${{ inputs.RELEASE_TYPE || 'EE' }} | |
outputs: | |
should_build_oss: ${{ steps.which_editions.outputs.should_build_oss }} | |
should_build_ee: ${{ steps.which_editions.outputs.should_build_ee }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Read release type from the file | |
if: github.event_name != 'workflow_dispatch' | |
run: | | |
RELEASE_TYPE_FILE=.github/release_type | |
if [ -f $RELEASE_TYPE_FILE ]; then | |
echo "RELEASE_TYPE=$(cat $RELEASE_TYPE_FILE)" >> $GITHUB_ENV | |
else | |
echo "File '$RELEASE_TYPE_FILE' does not exist." | |
exit 1 | |
fi | |
- name: Check which editions should be built | |
id: which_editions | |
run: | | |
. .github/scripts/build.functions.sh | |
release_type=${{ env.RELEASE_TYPE }} | |
triggered_by=${{ github.event_name }} | |
should_build_oss=$(should_build_oss "$release_type") | |
should_build_ee=$(should_build_ee "$release_type") | |
echo "should_build_ee=${should_build_ee}" >> $GITHUB_OUTPUT | |
echo "should_build_oss=${should_build_oss}" >> $GITHUB_OUTPUT | |
push: | |
runs-on: ubuntu-latest | |
needs: [ jdks, prepare ] | |
strategy: | |
matrix: | |
jdk: ${{ fromJSON(needs.jdks.outputs.jdks) }} | |
variant: [ 'slim','' ] | |
include: | |
- variant: slim | |
- variant: '' | |
env: | |
DOCKER_ORG: hazelcast | |
HZ_VERSION: ${{ inputs.HZ_VERSION }} | |
RELEASE_VERSION: ${{ inputs.RELEASE_VERSION }} | |
steps: | |
- name: Set environment variables | |
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 | |
if [ -z "${{ env.RELEASE_VERSION }}" ]; then | |
RELEASE_VERSION=${HZ_VERSION} | |
else | |
RELEASE_VERSION=${{ env.RELEASE_VERSION }} | |
fi | |
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV | |
if [ -n "${{ matrix.variant }}" ]; then | |
SUFFIX=-${{ matrix.variant }} | |
else | |
SUFFIX= | |
fi | |
echo "SUFFIX=${SUFFIX}" >> $GITHUB_ENV | |
echo "DOCKER_LOG_FILE_OSS=docker-${{ env.test_container_name_oss }}${SUFFIX}-jdk${{ matrix.jdk }}.log" >> $GITHUB_ENV | |
echo "DOCKER_LOG_FILE_EE=docker-${{ env.test_container_name_ee }}${SUFFIX}-jdk${{ matrix.jdk }}.log" >> $GITHUB_ENV | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install xmllint | |
uses: ./.github/actions/install-xmllint | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: v0.5.1 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: 'us-east-1' | |
- name: Login to Docker Hub | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Get OSS dist ZIP URL | |
run: | | |
. .github/scripts/oss-build.functions.sh | |
echo "HAZELCAST_OSS_ZIP_URL=$(get_hz_dist_zip "${{ matrix.variant }}" "${{ env.HZ_VERSION }}")" >> $GITHUB_ENV | |
- name: Build Test OSS image | |
if: needs.prepare.outputs.should_build_oss == 'yes' | |
run: | | |
docker buildx build --load \ | |
--build-arg JDK_VERSION=${{ matrix.jdk }} \ | |
--build-arg HAZELCAST_ZIP_URL=$HAZELCAST_OSS_ZIP_URL \ | |
--tag hazelcast-oss:test \ | |
hazelcast-oss | |
- name: Run smoke test against OSS image | |
if: needs.prepare.outputs.should_build_oss == 'yes' | |
timeout-minutes: 2 | |
run: | | |
.github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss | |
- name: Get EE dist ZIP URL | |
run: | | |
. .github/scripts/ee-build.functions.sh | |
echo "HAZELCAST_EE_ZIP_URL=$(get_hz_dist_zip "${{ matrix.variant }}" "${{ env.HZ_VERSION }}")" >> $GITHUB_ENV | |
- name: Build Test EE image | |
if: needs.prepare.outputs.should_build_ee == 'yes' | |
run: | | |
. .github/scripts/ee-build.functions.sh | |
docker buildx build --load \ | |
--build-arg HZ_VERSION=${{ env.HZ_VERSION }} \ | |
--build-arg JDK_VERSION=${{ matrix.jdk }} \ | |
--build-arg HAZELCAST_ZIP_URL=$HAZELCAST_EE_ZIP_URL \ | |
--tag hazelcast-ee:test \ | |
hazelcast-enterprise | |
- name: Run smoke test against EE image | |
if: needs.prepare.outputs.should_build_ee == 'yes' | |
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 }} 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@v4 | |
with: | |
name: docker-logs${{ env.SUFFIX }}-jdk${{ matrix.jdk }} | |
path: | | |
${{ env.DOCKER_LOG_FILE_OSS }} | |
${{ env.DOCKER_LOG_FILE_EE }} | |
- name: Build and Push OSS image | |
if: needs.prepare.outputs.should_build_oss == 'yes' | |
run: | | |
. .github/scripts/get-tags-to-push.sh | |
. .github/scripts/docker.functions.sh | |
DOCKER_DIR=hazelcast-oss | |
IMAGE_NAME=${{ env.DOCKER_ORG }}/hazelcast | |
DEFAULT_JDK="$(get_default_jdk $DOCKER_DIR)" | |
TAGS_TO_PUSH=$(get_tags_to_push ${{ env.RELEASE_VERSION }} "${{ env.SUFFIX }}" "${{ matrix.jdk }}" "$DEFAULT_JDK") | |
echo "TAGS_TO_PUSH=$TAGS_TO_PUSH" | |
TAGS_ARG="" | |
for tag in ${TAGS_TO_PUSH[@]} | |
do | |
TAGS_ARG="${TAGS_ARG} --tag ${IMAGE_NAME}:${tag}" | |
done | |
PLATFORMS="$(get_alpine_supported_platforms "${{ matrix.jdk }}")" | |
docker buildx build --push \ | |
--build-arg JDK_VERSION=${{ matrix.jdk }} \ | |
--build-arg HAZELCAST_ZIP_URL=$HAZELCAST_OSS_ZIP_URL \ | |
${TAGS_ARG} \ | |
--platform=${PLATFORMS} $DOCKER_DIR | |
- name: Build/Push EE image | |
if: needs.prepare.outputs.should_build_ee == 'yes' | |
run: | | |
. .github/scripts/get-tags-to-push.sh | |
. .github/scripts/docker.functions.sh | |
. .github/scripts/ee-build.functions.sh | |
DOCKER_DIR=hazelcast-enterprise | |
IMAGE_NAME=${{ env.DOCKER_ORG }}/hazelcast-enterprise | |
DEFAULT_JDK="$(get_default_jdk $DOCKER_DIR)" | |
TAGS_TO_PUSH=$(get_tags_to_push ${{ env.RELEASE_VERSION }} "${{ env.SUFFIX }}" "${{ matrix.jdk }}" "$DEFAULT_JDK") | |
echo "TAGS_TO_PUSH=$TAGS_TO_PUSH" | |
TAGS_ARG="" | |
for tag in ${TAGS_TO_PUSH[@]} | |
do | |
TAGS_ARG="${TAGS_ARG} --tag ${IMAGE_NAME}:${tag}" | |
done | |
PLATFORMS="$(get_ubi_supported_platforms "${{ matrix.jdk }}")" | |
docker buildx build --push \ | |
--build-arg HZ_VERSION=${{ env.HZ_VERSION }} \ | |
--build-arg JDK_VERSION=${{ matrix.jdk }} \ | |
--build-arg HAZELCAST_ZIP_URL=$HAZELCAST_EE_ZIP_URL \ | |
${TAGS_ARG} \ | |
--platform=${PLATFORMS} $DOCKER_DIR | |
- name: Slack notification | |
uses: ./.github/actions/slack-notification | |
if: failure() | |
with: | |
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK }} | |
post-push: | |
runs-on: ubuntu-latest | |
needs: [ push, prepare ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: .github | |
- name: Generate Docker Hub Description | |
run: | | |
.github/scripts/generate-docker-hub-description.sh | |
- name: Update Docker Hub Description of OSS image | |
if: needs.prepare.outputs.should_build_oss == 'yes' | |
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-docker.md | |
- name: Update Docker Hub Description of EE image | |
if: needs.prepare.outputs.should_build_ee == 'yes' | |
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-docker.md | |
- name: Create release | |
if: github.event_name == 'push' | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
allowUpdates: true | |
- name: Slack notification | |
uses: ./.github/actions/slack-notification | |
if: failure() | |
with: | |
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK }} |