Skip to content

Commit

Permalink
Use .github/release_type for controlling releases of the OSS/EE [5.4.…
Browse files Browse the repository at this point in the history
…z] (#205)

Backport of #204

In order to control which editions (OSS/EE/ALL) should be released
`.github/release_type` file is introduced.

This file is required now for newly created git tags. It should contains
only one of the following values:
- OSS
- EE
- ALL

When a new tag is pushed we read the file to decide which editions
should be released.
For manual runs of the `publish-packages.yml` we ignore this file and
use `RELEASE_TYPE` input from the workflow

`.github/release_type` should be added during the release by the
automation. It's forbidden to add it master or maintenance branches
through PRs.

Fixes: https://hazelcast.atlassian.net/browse/DI-52

Also switches to using internal snapshot maven repository for getting OSS snapshot distribution tar.gz
  • Loading branch information
ldziedziul committed Jul 12, 2024
1 parent ed65c4a commit cb4d628
Show file tree
Hide file tree
Showing 17 changed files with 886 additions and 372 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
JAVA_VERSION=21
JAVA_DISTRIBUTION=temurin
21 changes: 21 additions & 0 deletions .github/workflows/assert.sh/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Márk Török

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
262 changes: 262 additions & 0 deletions .github/workflows/assert.sh/assert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
#!/usr/bin/env bash

#####################################################################
##
## title: Assert Extension
##
## description:
## Assert extension of shell (bash, ...)
## with the common assert functions
## Function list based on:
## http://junit.sourceforge.net/javadoc/org/junit/Assert.html
## Log methods : inspired by
## - https://natelandau.com/bash-scripting-utilities/
## author: Mark Torok
##
## date: 07. Dec. 2016
##
## license: MIT
##
#####################################################################

if command -v tput &>/dev/null && tty -s; then
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
MAGENTA=$(tput setaf 5)
NORMAL=$(tput sgr0)
BOLD=$(tput bold)
else
RED=$(echo -en "\e[31m")
GREEN=$(echo -en "\e[32m")
MAGENTA=$(echo -en "\e[35m")
NORMAL=$(echo -en "\e[00m")
BOLD=$(echo -en "\e[01m")
fi

log_header() {
printf "\n${BOLD}${MAGENTA}========== %s ==========${NORMAL}\n" "$@" >&2
}

log_success() {
printf "${GREEN}✔ %s${NORMAL}\n" "$@" >&2
}

log_failure() {
printf "${RED}✖ %s${NORMAL}\n" "$@" >&2
}


assert_eq() {
local expected="$1"
local actual="$2"
local msg="${3-}"

if [ "$expected" == "$actual" ]; then
log_success "$expected == $actual :: $msg" || true
return 0
else
[ "${#msg}" -gt 0 ] && log_failure "$expected == $actual :: $msg" || true
return 1
fi
}

assert_not_eq() {
local expected="$1"
local actual="$2"
local msg="${3-}"

if [ ! "$expected" == "$actual" ]; then
return 0
else
[ "${#msg}" -gt 0 ] && log_failure "$expected != $actual :: $msg" || true
return 1
fi
}

assert_true() {
local actual="$1"
local msg="${2-}"

assert_eq true "$actual" "$msg"
return "$?"
}

assert_false() {
local actual="$1"
local msg="${2-}"

assert_eq false "$actual" "$msg"
return "$?"
}

assert_array_eq() {

declare -a expected=("${!1-}")
# echo "AAE ${expected[@]}"

declare -a actual=("${!2}")
# echo "AAE ${actual[@]}"

local msg="${3-}"

local return_code=0
if [ ! "${#expected[@]}" == "${#actual[@]}" ]; then
return_code=1
fi

local i
for (( i=1; i < ${#expected[@]} + 1; i+=1 )); do
if [ ! "${expected[$i-1]}" == "${actual[$i-1]}" ]; then
return_code=1
break
fi
done

if [ "$return_code" == 1 ]; then
[ "${#msg}" -gt 0 ] && log_failure "(${expected[*]}) != (${actual[*]}) :: $msg" || true
fi

return "$return_code"
}

assert_array_not_eq() {

declare -a expected=("${!1-}")
declare -a actual=("${!2}")

local msg="${3-}"

local return_code=1
if [ ! "${#expected[@]}" == "${#actual[@]}" ]; then
return_code=0
fi

local i
for (( i=1; i < ${#expected[@]} + 1; i+=1 )); do
if [ ! "${expected[$i-1]}" == "${actual[$i-1]}" ]; then
return_code=0
break
fi
done

if [ "$return_code" == 1 ]; then
[ "${#msg}" -gt 0 ] && log_failure "(${expected[*]}) == (${actual[*]}) :: $msg" || true
fi

return "$return_code"
}

assert_empty() {
local actual=$1
local msg="${2-}"

assert_eq "" "$actual" "$msg"
return "$?"
}

assert_not_empty() {
local actual=$1
local msg="${2-}"

assert_not_eq "" "$actual" "$msg"
return "$?"
}

function join_by() {
local IFS="$1";
shift;
echo "$*";
}

assert_contain() {
local haystack="$1"
local needle="${2-}"
local msg="${3-}"

if [ -z "${needle:+x}" ]; then
return 0;
fi

if [ -z "${haystack##*$needle*}" ]; then
log_success "Array [$(join_by "," $haystack)] contains $needle :: $msg" || true
return 0
else
[ "${#msg}" -gt 0 ] && log_failure "Array [$(join_by "," $haystack)] doesn't contain $needle :: $msg" || true
return 1
fi
}

assert_not_contain() {
local haystack="$1"
local needle="${2-}"
local msg="${3-}"

if [ -z "${needle:+x}" ]; then
return 0;
fi

if [ -z "$haystack" ]; then
log_success "Array [$(join_by "," $haystack)] doesn't contain $needle :: $msg" || true
return 0;
fi

if [ "${haystack##*$needle*}" ]; then
log_success "Array [$(join_by "," $haystack)] doesn't contain $needle :: $msg" || true
return 0
else
[ "${#msg}" -gt 0 ] && log_failure "$haystack contains $needle :: $msg" || true
return 1
fi
}

assert_gt() {
local first="$1"
local second="$2"
local msg="${3-}"

if [[ "$first" -gt "$second" ]]; then
return 0
else
[ "${#msg}" -gt 0 ] && log_failure "$first > $second :: $msg" || true
return 1
fi
}

assert_ge() {
local first="$1"
local second="$2"
local msg="${3-}"

if [[ "$first" -ge "$second" ]]; then
return 0
else
[ "${#msg}" -gt 0 ] && log_failure "$first >= $second :: $msg" || true
return 1
fi
}

assert_lt() {
local first="$1"
local second="$2"
local msg="${3-}"

if [[ "$first" -lt "$second" ]]; then
return 0
else
[ "${#msg}" -gt 0 ] && log_failure "$first < $second :: $msg" || true
return 1
fi
}

assert_le() {
local first="$1"
local second="$2"
local msg="${3-}"

if [[ "$first" -le "$second" ]]; then
return 0
else
[ "${#msg}" -gt 0 ] && log_failure "$first <= $second :: $msg" || true
return 1
fi
}
58 changes: 58 additions & 0 deletions .github/workflows/build.functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

set -euo pipefail ${RUNNER_DEBUG:+-x}

# Checks if we should build the OSS docker image.
# If the workflow was triggered by `pull_request` OSS artifact should be built always.
# For other workflows we should build EE only for 'ALL' and 'OSS' editions.
function should_build_oss() {

local triggered_by=$1
local release_type=$2

if [[ $triggered_by == "pull_request" || $release_type == "ALL" || $release_type == "OSS" ]]; then
echo "yes"
else
echo "no"
fi
}

# Checks if we should build the EE docker image.
# If the workflow was triggered by `pull_request` EE artifact should be built always.
# For other workflows we should build EE only for 'All' and 'EE' editions.
function should_build_ee() {

local triggered_by=$1
local release_type=$2

if [[ $triggered_by == "pull_request" || $release_type == "ALL" || $release_type == "EE" ]]; then
echo "yes"
else
echo "no"
fi
}

function get_hz_dist_tar_gz() {
local hz_version=$1
local distribution=$2
local extension=tar.gz

if [[ $distribution == "hazelcast" ]]; then
if [[ "${hz_version}" == *"SNAPSHOT"* ]]; then
url="https://${HZ_SNAPSHOT_INTERNAL_USERNAME}:${HZ_SNAPSHOT_INTERNAL_PASSWORD}@repository.hazelcast.com/snapshot-internal/com/hazelcast/hazelcast-distribution/${hz_version}/hazelcast-distribution-${hz_version}.$extension"
else
url="https://repo1.maven.org/maven2/com/hazelcast/hazelcast-distribution/${hz_version}/hazelcast-distribution-${hz_version}.$extension"
fi
fi

if [[ $distribution == "hazelcast-enterprise" ]]; then
local repository
if [[ "${hz_version}" == *"SNAPSHOT"* ]]; then
repository=snapshot
else
repository=release
fi
url="https://repository.hazelcast.com/${repository}/com/hazelcast/hazelcast-enterprise-distribution/${hz_version}/hazelcast-enterprise-distribution-${hz_version}.$extension"
fi
echo "$url"
}
Loading

0 comments on commit cb4d628

Please sign in to comment.