chore: docker-latest tag can be create automatically in cut.sh

This commit is contained in:
Ivan Dyachkov 2023-03-01 16:57:42 +01:00
parent b04f7ecccf
commit 7a154e4d58
3 changed files with 68 additions and 36 deletions

View File

@ -43,9 +43,10 @@ jobs:
- name: Get profiles to build - name: Get profiles to build
id: get_profile id: get_profile
env:
INPUTS_PROFILE: ${{ github.event.inputs.profile }}
run: | run: |
cd source cd source
tag=${{ github.ref }}
# tag docker-latest-ce or docker-latest-ee # tag docker-latest-ce or docker-latest-ee
if git describe --tags --exact --match 'docker-latest-*' 2>/dev/null; then if git describe --tags --exact --match 'docker-latest-*' 2>/dev/null; then
echo 'is_latest=true due to docker-latest-* tag' echo 'is_latest=true due to docker-latest-* tag'
@ -57,38 +58,33 @@ jobs:
echo 'is_latest=false' echo 'is_latest=false'
is_latest=false is_latest=false
fi fi
if git describe --tags --match "[v|e]*" --exact; then # resolve profile
if git describe --tags --match "v*" --exact; then
echo "This is an exact git tag, will publish images" echo "This is an exact git tag, will publish images"
is_exact='true' is_exact='true'
PROFILE=emqx
elif git describe --tags --match "e*" --exact; then
echo "This is an exact git tag, will publish images"
is_exact='true'
PROFILE=emqx-enterprise
else else
echo "This is NOT an exact git tag, will not publish images" echo "This is NOT an exact git tag, will not publish images"
is_exact='false' is_exact='false'
fi fi
case $tag in
refs/tags/v*) case "${PROFILE:-$INPUTS_PROFILE}" in
PROFILE='emqx' emqx)
EDITION='Opensource' EDITION='Opensource'
;; ;;
refs/tags/e*) emqx-enterprise)
PROFILE=emqx-enterprise
EDITION='Enterprise' EDITION='Enterprise'
;; ;;
*) *)
PROFILE=${{ github.event.inputs.profile }} echo "ERROR: Failed to resolve build profile"
case "$PROFILE" in exit 1
emqx)
EDITION='Opensource'
;;
emqx-enterprise)
EDITION='Enterprise'
;;
*)
echo "ERROR: Failed to resolve build profile"
exit 1
;;
esac
;; ;;
esac esac
VSN="$(./pkg-vsn.sh "$PROFILE")" VSN="$(./pkg-vsn.sh "$PROFILE")"
echo "Building emqx/$PROFILE:$VSN image (latest=$is_latest)" echo "Building emqx/$PROFILE:$VSN image (latest=$is_latest)"
echo "Push = $is_exact" echo "Push = $is_exact"

View File

@ -19,15 +19,23 @@ RELEASE_GIT_TAG is a 'v*' or 'e*' tag for example:
e5.0.0-beta.6 e5.0.0-beta.6
options: options:
-h|--help: Print this usage. -h|--help: Print this usage.
-b|--base: Specify the current release base branch, can be one of
release-50 -b|--base: Specify the current release base branch, can be one of
NOTE: this option should be used when --dryrun. release-50
--dryrun: Do not actually create the git tag. NOTE: this option should be used when --dryrun.
--skip-appup: Skip checking appup
Useful when you are sure that appup is already updated' --dryrun: Do not actually create the git tag.
--prev-tag: Provide the prev tag to automatically generate changelogs
If this option is absent, the tag found by git describe will be used --skip-appup: Skip checking appup
Useful when you are sure that appup is already updated'
--prev-tag <tag>: Provide the prev tag to automatically generate changelogs
If this option is absent, the tag found by git describe will be used
--docker-latest: Set this option to assign :latest tag on the corresponding docker image
in addition to regular :<version> one
NOTE: For 5.0 series the current working branch must be 'release-50' for opensource edition NOTE: For 5.0 series the current working branch must be 'release-50' for opensource edition
and 'release-e50' for enterprise edition. and 'release-e50' for enterprise edition.
@ -45,18 +53,21 @@ logmsg() {
} }
TAG="${1:-}" TAG="${1:-}"
DOCKER_LATEST_TAG=
case "$TAG" in case "$TAG" in
v*) v*)
TAG_PREFIX='v' TAG_PREFIX='v'
PROFILE='emqx' PROFILE='emqx'
SKIP_APPUP='yes' SKIP_APPUP='yes'
DOCKER_LATEST_TAG='docker-latest-ce'
;; ;;
e*) e*)
TAG_PREFIX='e' TAG_PREFIX='e'
PROFILE='emqx-enterprise' PROFILE='emqx-enterprise'
#TODO change to no when we are ready to support hot-upgrade #TODO change to no when we are ready to support hot-upgrade
SKIP_APPUP='yes' SKIP_APPUP='yes'
DOCKER_LATEST_TAG='docker-latest-ee'
;; ;;
-h|--help) -h|--help)
usage usage
@ -72,6 +83,7 @@ esac
shift 1 shift 1
DRYRUN='no' DRYRUN='no'
DOCKER_LATEST='no'
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
case $1 in case $1 in
-h|--help) -h|--help)
@ -99,6 +111,10 @@ while [ "$#" -gt 0 ]; do
PREV_TAG="$1" PREV_TAG="$1"
shift shift
;; ;;
--docker-latest)
DOCKER_LATEST='yes'
shift
;;
*) *)
logerr "Unknown option $1" logerr "Unknown option $1"
exit 1 exit 1
@ -180,11 +196,11 @@ assert_release_version() {
assert_release_version "$TAG" assert_release_version "$TAG"
## Check if all upstream branches are merged ## Check if all upstream branches are merged
if [ -z "${BASE_BR:-}" ]; then SYNC_REMOTES_ARGS=
./scripts/rel/sync-remotes.sh [ -n "${BASE_BR:-}" ] && SYNC_REMOTES_ARGS="--base $BASE_BR $SYNC_REMOTES_ARGS"
else [ "$DRYRUN" = 'yes' ] && SYNC_REMOTES_ARGS="--dryrun $SYNC_REMOTES_ARGS"
./scripts/rel/sync-remotes.sh --base "$BASE_BR" # shellcheck disable=SC2086
fi ./scripts/rel/sync-remotes.sh $SYNC_REMOTES_ARGS
## Check if the Chart versions are in sync ## Check if the Chart versions are in sync
./scripts/rel/check-chart-vsn.sh "$PROFILE" ./scripts/rel/check-chart-vsn.sh "$PROFILE"
@ -231,6 +247,9 @@ generate_changelog () {
if [ "$DRYRUN" = 'yes' ]; then if [ "$DRYRUN" = 'yes' ]; then
logmsg "Release tag is ready to be created with command: git tag $TAG" logmsg "Release tag is ready to be created with command: git tag $TAG"
if [ "$DOCKER_LATEST" = 'yes' ]; then
logmsg "Docker latest tag is ready to be created with command: git tag --force $DOCKER_LATEST_TAG"
fi
else else
case "$TAG" in case "$TAG" in
*rc*) *rc*)
@ -252,4 +271,8 @@ else
esac esac
git tag "$TAG" git tag "$TAG"
logmsg "$TAG is created OK." logmsg "$TAG is created OK."
if [ "$DOCKER_LATEST" = 'yes' ]; then
git tag --force "$DOCKER_LATEST_TAG"
logmsg "$DOCKER_LATEST_TAG is created OK."
fi
fi fi

View File

@ -33,6 +33,10 @@ options:
Without this option, the script executes 'git merge' command Without this option, the script executes 'git merge' command
with '--ff-only' option which conveniently pulls remote with '--ff-only' option which conveniently pulls remote
updates if there is any, and fails when fast-forward is not possible updates if there is any, and fails when fast-forward is not possible
--dryrun:
Do not perform merge. Run the checks, fetch from remote,
and show what's going to happen.
EOF EOF
} }
@ -48,6 +52,7 @@ logmsg() {
} }
INTERACTIVE='no' INTERACTIVE='no'
DRYRUN='no'
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
case $1 in case $1 in
-h|--help) -h|--help)
@ -63,6 +68,10 @@ while [ "$#" -gt 0 ]; do
BASE_BRANCH="$1" BASE_BRANCH="$1"
shift shift
;; ;;
--dryrun)
shift
DRYRUN='yes'
;;
*) *)
logerr "Unknown option $1" logerr "Unknown option $1"
exit 1 exit 1
@ -151,6 +160,10 @@ upstream_branches() {
} }
for remote_ref in $(upstream_branches "$BASE_BRANCH"); do for remote_ref in $(upstream_branches "$BASE_BRANCH"); do
logmsg "Merging $remote_ref" if [ "$DRYRUN" = 'yes' ]; then
git merge $MERGE_OPTS "$remote_ref" logmsg "Merge with this command: git merge $MERGE_OPTS $remote_ref"
else
logmsg "Merging $remote_ref"
git merge $MERGE_OPTS "$remote_ref"
fi
done done