Build OS and EE image #959
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: 'What should be built' | |
required: true | |
default: 'EE' | |
type: choice | |
options: | |
- ALL | |
- OSS | |
- EE | |
- README | |
IS_LTS_OVERRIDE: | |
description: 'Override is LTS release' | |
required: false | |
type: choice | |
default: '' | |
options: | |
- '' | |
- 'false' | |
- 'true' | |
DRY_RUN: | |
description: 'Skip pushing the images to remote registry' | |
default: 'false' | |
type: choice | |
options: | |
- 'false' | |
- 'true' | |
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 }} | |
should_build_readme_ee: ${{ steps.which_editions.outputs.should_build_readme_ee }} | |
should_build_readme_oss: ${{ steps.which_editions.outputs.should_build_readme_oss }} | |
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") | |
should_build_readme_ee=$(should_build_readme_ee "$release_type") | |
should_build_readme_oss=$(should_build_readme_oss "$release_type") | |
echo "should_build_ee=${should_build_ee}" >> $GITHUB_OUTPUT | |
echo "should_build_oss=${should_build_oss}" >> $GITHUB_OUTPUT | |
echo "should_build_readme_ee=${should_build_readme_ee}" >> $GITHUB_OUTPUT | |
echo "should_build_readme_oss=${should_build_readme_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=${{ env.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: 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@v4 | |
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 | |
if: needs.prepare.outputs.should_build_oss == 'yes' | |
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 ${{ env.HZ_VERSION }} | |
- name: Get EE dist ZIP URL | |
if: needs.prepare.outputs.should_build_ee == 'yes' | |
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 ${{ env.HZ_VERSION }} | |
- 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() && ( needs.prepare.outputs.should_build_ee == 'yes' || needs.prepare.outputs.should_build_oss == 'yes') }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docker-logs${{ env.SUFFIX }}-jdk${{ matrix.jdk }} | |
path: docker-*.log | |
- 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)" | |
# OSS has no LTS releases | |
IS_LATEST_LTS=false | |
TAGS_TO_PUSH=$(get_tags_to_push ${{ env.RELEASE_VERSION }} "${{ env.SUFFIX }}" "${{ matrix.jdk }}" "$DEFAULT_JDK" "$IS_LATEST_LTS") | |
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 }}")" | |
if [ "${{ inputs.DRY_RUN }}" == "true" ] ; then | |
echo "DRY RUN: Build and push for platforms ${PLATFORMS} and tags: $TAGS_TO_PUSH" | |
else | |
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 | |
fi | |
- name: Check if latest EE LTS release | |
id: is_latest_lts | |
uses: ./.github/actions/check-if-latest-lts-release | |
with: | |
release_version: ${{ env.RELEASE_VERSION }} | |
is_lts_override: ${{ inputs.IS_LTS_OVERRIDE }} | |
- 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)" | |
IS_LATEST_LTS="${{ steps.is_latest_lts.outputs.is_latest_lts }}" | |
TAGS_TO_PUSH=$(get_tags_to_push ${{ env.RELEASE_VERSION }} "${{ env.SUFFIX }}" "${{ matrix.jdk }}" "$DEFAULT_JDK" "$IS_LATEST_LTS") | |
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 }}")" | |
if [ "${{ inputs.DRY_RUN }}" == "true" ] ; then | |
echo "DRY RUN: Build and push for platforms ${PLATFORMS} and tags: $TAGS_TO_PUSH" | |
else | |
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 | |
fi | |
- name: Update Docker Hub Description | |
if: needs.prepare.outputs.should_build_readme_ee == 'yes' || needs.prepare.outputs.should_build_readme_oss == 'yes' | |
uses: ./.github/actions/update-dockerhub-description | |
with: | |
docker_username: ${{ secrets.DOCKER_USERNAME }} | |
docker_password: ${{ secrets.DOCKER_PASSWORD }} | |
- 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 }} |